I am trying to monitor SIP devices located on Cisco Call manager via JTAPI. I have installed JTAPI plugin and try to run its sample makeCall scenario.
CUCM version : 9.1.2.10000-28
When I list the controlled device addresses of the provider, it only returns devices with SCCP protocol (skinny phones) but not return devices with SIP device protocol. There are already SIP based devices added into the controlled device list of the provider on CUCM.
JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
/* connect to the provider */
String providerString = hostname;
providerString += ";login=" + login;
providerString += ";passwd=" + passwd;
Provider provider = peer.getProvider(providerString);
/* wait for it to come into service */
final Condition inService = new Condition();
provider.addObserver(new ProviderObserver() {
public void providerChangedEvent (ProvEv [] eventList) {
if (eventList == null) return;
for (int i = 0; i < eventList.length; ++i) {
if (eventList[i] instanceof ProvInServiceEv) {
inService.set();
}
}
}
});
inService.waitTrue();
for(Address address : provider.getAddresses()){
System.out.println(address.getName());
}
Is there any other config, etc.. that I need to do in order to list SIP phones as well?
Thanks.
JTAPI applications can only control Cisco Unified IP Phone 7900 Series that run SIP, which includes Cisco Unified IP 7970 phones. Which model you are using?
http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cucm/jtapi_dev/9_1_1/jtapidevguide/featsupported.html#wp1148307
Related
I am using AngularJS v1.2.32.
I want to source IP based white-listing to legitimate systems. I have searched but found examples using third party json application.
Need to get client IP in JavaScript , angularjs and restrict access to other users.
Your help is highly appreciated.
Firefox and Chrome have implemented WebRTC that allow requests to STUN servers be made that will return the local and public IP addresses for the user. These request results are available to javascript, so you can now obtain a users local and public IP addresses in javascript. This demo is an example implementation of that.
for more
https://github.com/diafygi/webrtc-ips
How to get client's IP address using JavaScript only?
//get the IP addresses associated with an account
function getIPs(callback){
var ip_dups = {};
//compatibility for firefox and chrome
var RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
var useWebKit = !!window.webkitRTCPeerConnection;
//bypass naive webrtc blocking using an iframe
if(!RTCPeerConnection){
//NOTE: you need to have an iframe in the page right above the script tag
//
//<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
//<script>...getIPs called in here...
//
var win = iframe.contentWindow;
RTCPeerConnection = win.RTCPeerConnection
|| win.mozRTCPeerConnection
|| win.webkitRTCPeerConnection;
useWebKit = !!win.webkitRTCPeerConnection;
}
//minimal requirements for data connection
var mediaConstraints = {
optional: [{RtpDataChannels: true}]
};
var servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
//construct a new RTCPeerConnection
var pc = new RTCPeerConnection(servers, mediaConstraints);
function handleCandidate(candidate){
//match just the IP address
var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/
var ip_addr = ip_regex.exec(candidate)[1];
//remove duplicates
if(ip_dups[ip_addr] === undefined)
callback(ip_addr);
ip_dups[ip_addr] = true;
}
//listen for candidate events
pc.onicecandidate = function(ice){
//skip non-candidate events
if(ice.candidate)
handleCandidate(ice.candidate.candidate);
};
//create a bogus data channel
pc.createDataChannel("");
//create an offer sdp
pc.createOffer(function(result){
//trigger the stun server request
pc.setLocalDescription(result, function(){}, function(){});
}, function(){});
//wait for a while to let everything done
setTimeout(function(){
//read candidate info from local description
var lines = pc.localDescription.sdp.split('\n');
lines.forEach(function(line){
if(line.indexOf('a=candidate:') === 0)
handleCandidate(line);
});
}, 1000);
}
//Test: Print the IP addresses into the console
getIPs(function(ip){console.log(ip);});
The following code is working fine for Android Devices bt it doesn't works in ios using codenameOne.
public static boolean checkNetwork(){
boolean online = false;
String net = NetworkManager.getInstance().getCurrentAccessPoint();
if (net == null || net == "" || net.equals(null)) {
online = false;
} else {
online = true;
}
return online;
}
Note : It seems No Connection Error Even data was connected to ios device
There is a CN1 library written by LittleMonkey that you can use to check connectivity. Search for connectivity in Codename One Extensions and download it to your project.
You can check for connection like this:
if (Connectivity.isConnected()) {
//we have some connection
} else {
// we have no connection
}
And you can check what type of connection
ConnectionState status = Connectivity.getConnectionState();
switch (status) {
case DISCONNECTED:
Log.p("Disconnected");
break;
case WIFI:
Log.p("On Wifi");
break;
case MOBILE:
Log.p("On Mobile Data");
break;
default:
//shouldn't be possible
}
Read more about this on GitHub.
I am verifying in-app-purchase receipts using the following code:
- (void) completeTransaction:(SKPaymentTransaction*) transaction
{
NSData* receipt = nil;
// 1. Attempt <app receipt> first (iOS 7.x)
NSBundle* mainBundle = [NSBundle mainBundle];
if ([mainBundle respondsToSelector:#selector(appStoreReceiptURL)]) {
NSURL* appStoreReceiptURL = [mainBundle appStoreReceiptURL]; // <- CRASH
receipt = [NSData dataWithContentsOfURL:appStoreReceiptURL];
}
// 2. Fallback to <transaction receipt> (iOS < 7.0)
if (!receipt) {
receipt = [transaction transactionReceipt];
}
// 3. Have server verify it with iTunes:
[self verifyReceipt:receipt forTransaction:transaction];
}
On an iOS 6 device, the execution stops at the line NSURL* appStoreReceiptURL = [mainBundle appStoreReceiptURL]; and the console spits:
-[NSBundle appStoreReceiptURL]: unrecognized selector sent to instance 0x208492d0
Am I missing something? Wasn't -respondsToSelector: supposed to take care of this? Must I fall back to checking the OS version directly??
YES you should check version number directly in case of this appStoreReceiptURL Method.
appStoreReceiptURL
In iOS, use the following code to detect whether this method is available:
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
} else {
// Load resources for iOS 7 or later
}
Note: The general best practice of weak linking using the respondsToSelector: method cannot be used here. Prior to iOS 7, the method (appStoreReceiptURL) was implemented as private API, but that implementation called the doesNotRecognizeSelector: method.
Reference:NSBundle Class reference
Is there anyway to know which user is calling the WCF Ria service on server side? Client side is siverlight, user has to be authenticated first in order to use the system.
I need to know which user is actually calling the service in my current task, thanks, i searched a lot, but seems no good findings.
Once the client side has successfully cleared your authentication challenge, the server can issue a token to the caller on the client side. In subsequent calls to the server, the client would send the token as one of the arguments and the server would verify the token and respond accordingly.
The token can contain a segment of information that identifies a given user, and implementing this will provide the functionality you are seeking.
The only guidelines for generating tokens is that they are unique, non-predictable and expirable. I have always encrypted my tokens so that they appear as gibberish, but step this is optional.
I've also done very much "googleing" and got a lot of headache before I got the solution.
I don't use RIA-Services - but it should be (hopefully) the same...:
The SL-Client sends a "login-request" to the server.
On the (WCF) server-side, I do the following (LoginData = Return-Info for SL-Client):
public LoginData LoginRequest() {
(...)
OperationContext context = OperationContext.Current;
System.ServiceModel.Channels.MessageProperties prp = context.IncomingMessageProperties;
System.ServiceModel.Channels.RemoteEndpointMessageProperty endPrp = prp[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
(...)
try {
clientIP = endPrp.Address;
System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse(clientIP);
System.Net.IPHostEntry ipHostEntry = System.Net.Dns.GetHostEntry(ipAddress);
(...)
If you want to check the users WindowsPrincipal, you can do the following (securityGroup = server-side setting, which users can login):
(...)
switch (securityGroup) {
case SecurityGroup.AllClientsCanAccess: {
clientCanLogin = true;
} break;
case SecurityGroup.UseWindowsCredentials: {
if (OperationContext.Current.ServiceSecurityContext != null && OperationContext.Current.ServiceSecurityContext.WindowsIdentity != null) {
if (OperationContext.Current.ServiceSecurityContext.WindowsIdentity.IsAuthenticated) {
if (subSecurityInfo1 == true) { // only clients in specific roles can log in
bool userRoleFound = false;
WindowsPrincipal userPrincipal = new WindowsPrincipal(OperationContext.Current.ServiceSecurityContext.WindowsIdentity);
if (userPrincipal == null)
break;
foreach (string userRoleToPass in subSecurityList) { // subSecurityList = settings, which roles can pass
loginError.ErrorInfo += string.Format("{0}\n", userRoleToPass);
if (userPrincipal.IsInRole(userRoleToPass)) {
clientCanLogin = userRoleFound = true;
break;
}
}
if (userRoleFound) {
loginError.ErrorInfo = string.Empty;
break;
}
else {
loginError.ErrorNo = LoginErrorCodeNoEnum.UserIsNotInRole;
}
}
(...)
Hope it helps...
I'm using C-style TCP sockets with send() and recv(). I have a connection running between user A and user B, where user A acts as a server and user B acts as a client.
I want to have a passive user C, which does not communicate anything, but receives data from user A. However, the new passive user C can join the session at any time. A might send C different packets than what it would send B.. I imagine it would be best for A-C to communicate on a different port than A-B
How can this connection be made (without threading, or the like) in an arbitrary point of communication?
edit still unsolved.
You could setup a listener that detects new connections, and mirror traffic to all open sockets. I recently wrote what I mean in C#: (i'll see whether I can quickly turn that into a C sample)
This example only accepts a fixed nr of incoming connections at the start, but it is dead easy to change that.
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Linq;
public class Demo
{
static IList<Socket> StartServer(int numberOfClients)
{
using(Socket main = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
main.Bind(new IPEndPoint(IPAddress.Any, 9050));
main.Listen(numberOfClients);
var clients = Enumerable
.Range(1,numberOfClients)
.Select(i => {
Console.WriteLine("Waiting for 1 more client...");
Socket client = main.Accept();
Console.WriteLine("Connected to {0}", client.RemoteEndPoint);
return client; })
.ToList();
main.Close();
return clients;
}
}
public static void Main()
{
var clients = StartServer(4);
while(clients.Count()>1) // still a conversation
{
var copyList = clients.ToList();
Console.WriteLine("Monitoring {0} sockets...", copyList.Count);
Socket.Select(copyList, null, null, 10000000);
foreach(Socket client in copyList)
{
byte[] data = new byte[1024];
int recv = client.Receive(data);
if (recv == 0)
{
Console.WriteLine("Client {0} disconnected.", client.RemoteEndPoint);
client.Close();
clients.Remove(client);
}
else
foreach (var other in clients.Except(new [] {client}))
other.Send(data, recv, SocketFlags.None);
}
}
Console.WriteLine("Last client disconnected, bye");
}
}
You can simply open 2 sockets on the server A, and bind them on 2 different ports.
Then use select function on the 2 created socket file descriptors.
Select will return first time when one of the 2 clients make a connect. Remember that on server side, after accepting a connect, you should set the returned new file descriptor (with FD_SET) in order to make select listen to events that will happen on the new socket( which returned from accept).