本文整理汇总了Java中javax.sip.address.URI类的典型用法代码示例。如果您正苦于以下问题:Java URI类的具体用法?Java URI怎么用?Java URI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
URI类属于javax.sip.address包,在下文中一共展示了URI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMultipleContactRegistration
import javax.sip.address.URI; //导入依赖的package包/类
public void sendMultipleContactRegistration() throws Exception {
Address fromAddress = addressFactory.createAddress("[email protected]:5070");
ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
CallIdHeader callId = provider.getNewCallId();
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.REGISTER);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
List via = Arrays.asList(((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader());
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
Request request = messageFactory.createRequest(requestURI, Request.REGISTER, callId, cSeq, from, to, via, maxForwards);
request.setRequestURI(requestURI);
request.addHeader(contactHeader1);
request.addHeader(contactHeader2);
ClientTransaction ctx = this.provider.getNewClientTransaction(request);
ctx.sendRequest();
}
示例2: sendInviteWithRPort
import javax.sip.address.URI; //导入依赖的package包/类
public void sendInviteWithRPort() throws Exception {
Address fromAddress = addressFactory.createAddress("[email protected]:5070");
ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
CallIdHeader callId = provider.getNewCallId();
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.INVITE);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
ViaHeader via = ((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader();
via.setRPort();
List vias = Arrays.asList(via);
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
Request request = messageFactory.createRequest(requestURI, Request.INVITE, callId, cSeq, from, to, vias, maxForwards);
System.out.println(request);
assertTrue(request.toString().indexOf("rport=") == -1);
request.setRequestURI(requestURI);
request.addHeader(contactHeader1);
request.addHeader(contactHeader2);
ClientTransaction ctx = this.provider.getNewClientTransaction(request);
ctx.sendRequest();
}
示例3: getNextHops
import javax.sip.address.URI; //导入依赖的package包/类
public ListIterator getNextHops(Request request) {
URI uri = request.getRequestURI();
ScenarioHarness.assertTrue("Expected to be consulted only for tel uri",uri.getScheme().equals("tel"));
LinkedList llist = new LinkedList();
llist.add(new HopImpl());
return llist.listIterator();
}
示例4: testHeaderParams
import javax.sip.address.URI; //导入依赖的package包/类
/**
* This tests that header parameters are properly assigned to the header, not the URI,
* when there are no angle brackets
*/
public void testHeaderParams() {
try {
Header h = tiHeaderFactory.createHeader( "m", "sip:[email protected]:1234;param1" );
System.err.println( h );
assertTrue( h instanceof ContactHeader );
ContactHeader c = (ContactHeader) h;
URI u = c.getAddress().getURI();
assertTrue( u.isSipURI() );
assertNull( "URI must have no params", ((SipURI)u).getParameter("param1") );
assertNotNull( "Parameter 'param1' must be assigned to the header", c.getParameter("param1") );
} catch (ParseException e) {
e.printStackTrace();
fail( e.getMessage() );
} finally {
logTestCompleted("testHeaderParams()");
}
}
示例5: testHeaderParams2
import javax.sip.address.URI; //导入依赖的package包/类
/**
* This tests that header parameters are properly assigned to the header, not the URI,
* when there are no angle brackets - in particular for 'tag'
*/
public void testHeaderParams2() {
try {
Header h = tiHeaderFactory.createHeader( "From", "sip:[email protected];tag=gc2zbu" );
System.err.println( h );
assertTrue( h instanceof FromHeader );
FromHeader c = (FromHeader) h;
URI u = c.getAddress().getURI();
assertTrue( u.isSipURI() );
assertFalse( "URI must have no params", ((SipURI)u).getParameterNames().hasNext() );
assertNotNull( "Parameter 'tag' must be assigned to the header", c.getTag() );
} catch (ParseException e) {
e.printStackTrace();
fail( e.getMessage() );
} finally {
logTestCompleted("testHeaderParams2()");
}
}
示例6: testHeaderParams3
import javax.sip.address.URI; //导入依赖的package包/类
/**
* This tests that header parameters are properly assigned to the header, not the URI,
* when there are no angle brackets - in particular for 'tag'
*/
public void testHeaderParams3() {
try {
Header h = tiHeaderFactory.createHeader( "From", "tel:07077004201;tag=gc2zbu" );
System.err.println( h );
assertTrue( h instanceof FromHeader );
FromHeader c = (FromHeader) h;
URI u = c.getAddress().getURI();
assertTrue( u instanceof TelURL );
assertFalse( "URI must have no params", ((TelURL)u).getParameterNames().hasNext() );
assertNotNull( "Parameter 'tag' must be assigned to the header", c.getTag() );
} catch (ParseException e) {
e.printStackTrace();
fail( e.getMessage() );
} finally {
logTestCompleted("testHeaderParams3()");
}
}
示例7: sendRegister
import javax.sip.address.URI; //导入依赖的package包/类
public void sendRegister(UserCredentials userCredentials,String serverIP,int serverPort) throws SipException, ParseException, InvalidArgumentException {
mUserCredentials = userCredentials;
URI requestURI = mAddressFactory.createURI("sip:[email protected]"+serverIP+":"+serverPort);
CallIdHeader callId = mSipProvider.getNewCallId();
CSeqHeader cSeq = mHeaderFactory.createCSeqHeader(1l, Request.REGISTER);
FromHeader from = mHeaderFactory.createFromHeader(mAddressFactory.createAddress("sip:"+userCredentials.getUserName()+"@"+serverIP+":"+serverPort), "1234");
ToHeader to = mHeaderFactory.createToHeader(mAddressFactory.createAddress("sip:[email protected]"+serverIP+":"+serverPort), null);
List via = Arrays.asList(((ListeningPointImpl)mSipProvider.getListeningPoint(mProtocol)).getViaHeader());
MaxForwardsHeader maxForwards = mHeaderFactory.createMaxForwardsHeader(10);
Request request = mMessageFactory.createRequest(requestURI, Request.REGISTER, callId, cSeq, from, to, via, maxForwards);
ContactHeader contactHeader = mHeaderFactory.createContactHeader(mAddressFactory.createAddress("sip:"+userCredentials.getUserName()+"@"+mIPAddress+":"+mUdpPort));
request.addHeader(contactHeader);
ClientTransaction ctx = mSipProvider.getNewClientTransaction(request);
ctx.sendRequest();
}
示例8: makeRequest
import javax.sip.address.URI; //导入依赖的package包/类
public Request makeRequest(SipManager sipManager, long cseqNumber, int expiresTime) throws ParseException, InvalidArgumentException {
AddressFactory addressFactory = sipManager.addressFactory;
SipProvider sipProvider = sipManager.sipProvider;
MessageFactory messageFactory = sipManager.messageFactory;
HeaderFactory headerFactory = sipManager.headerFactory;
// Create addresses and via header for the request
Address fromAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
fromAddress.setDisplayName(SipManager.sipUserName);
Address toAddress = addressFactory.createAddress("sip:" + SipManager.sipUserName + "@" + SipManager.registrarIp);
toAddress.setDisplayName(SipManager.sipUserName);
Address contactAddress = sipManager.createContactAddress();
ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
URI requestURI = addressFactory.createAddress("sip:" + SipManager.registrarIp).getURI();
// Build the request
final Request request = messageFactory.createRequest(requestURI,
Request.REGISTER, sipProvider.getNewCallId(),
headerFactory.createCSeqHeader(cseqNumber, Request.REGISTER),
headerFactory.createFromHeader(fromAddress, "c3ff411e"),
headerFactory.createToHeader(toAddress, null), viaHeaders,
headerFactory.createMaxForwardsHeader(70));
// Add the contact header
request.addHeader(headerFactory.createContactHeader(contactAddress));
ExpiresHeader eh = headerFactory.createExpiresHeader(expiresTime);
request.addHeader(eh);
// Print the request
System.out.println(request.toString());
return request;
}
示例9: doAuthenticateHashedPassword
import javax.sip.address.URI; //导入依赖的package包/类
/**
* Authenticate the inbound request.
*
* @param request - the request to authenticate.
* @param hashedPassword -- the MD5 hashed string of username:realm:plaintext password.
*
* @return true if authentication succeded and false otherwise.
*/
public boolean doAuthenticateHashedPassword(Request request, String hashedPassword) {
ProxyAuthorizationHeader authHeader = (ProxyAuthorizationHeader) request.getHeader(ProxyAuthorizationHeader.NAME);
if ( authHeader == null ) return false;
String realm = authHeader.getRealm();
String username = authHeader.getUsername();
if ( username == null || realm == null ) {
return false;
}
String nonce = authHeader.getNonce();
URI uri = authHeader.getURI();
if (uri == null) {
return false;
}
String A2 = request.getMethod().toUpperCase() + ":" + uri.toString();
String HA1 = hashedPassword;
byte[] mdbytes = messageDigest.digest(A2.getBytes());
String HA2 = toHexString(mdbytes);
String KD = HA1 + ":" + nonce;
KD += ":" + HA2;
mdbytes = messageDigest.digest(KD.getBytes());
String mdString = toHexString(mdbytes);
String response = authHeader.getResponse();
return mdString.equals(response);
}
示例10: getRequestURI
import javax.sip.address.URI; //导入依赖的package包/类
/**
* A conveniance function to access the Request URI.
*
* @return the requestURI if it exists.
*/
public javax.sip.address.URI getRequestURI() {
if (this.requestLine == null)
return null;
else
return (javax.sip.address.URI) this.requestLine.getUri();
}
示例11: setRequestURI
import javax.sip.address.URI; //导入依赖的package包/类
/**
* Sets the RequestURI of Request. The Request-URI is a SIP or SIPS URI or a general URI. It
* indicates the user or service to which this request is being addressed. SIP elements MAY
* support Request-URIs with schemes other than "sip" and "sips", for example the "tel" URI
* scheme. SIP elements MAY translate non-SIP URIs using any mechanism at their disposal,
* resulting in SIP URI, SIPS URI, or some other scheme.
*
* @param uri the new Request URI of this request message
*/
public void setRequestURI(URI uri) {
if ( uri == null ) {
throw new NullPointerException("Null request URI");
}
if (this.requestLine == null) {
this.requestLine = new RequestLine();
}
this.requestLine.setUri((GenericURI) uri);
this.nullRequest = false;
}
示例12: setAssociatedURI
import javax.sip.address.URI; //导入依赖的package包/类
/**
* <p>Set the URI on this address</p>
* @param associatedURI - GenericURI to be set in the address of this header
* @throws NullPointerException when supplied URI is null
*/
public void setAssociatedURI(URI associatedURI) throws NullPointerException
{
if (associatedURI == null)
throw new NullPointerException("null URI");
this.address.setURI(associatedURI);
}
示例13: equals
import javax.sip.address.URI; //导入依赖的package包/类
public boolean equals(Object that) {
if (this==that) return true;
else if (that instanceof URI) {
final URI o = (URI) that;
// This is not sufficient for equality; revert to String equality...
// return this.getScheme().equalsIgnoreCase( o.getScheme() )
return this.toString().equalsIgnoreCase( o.toString() );
}
return false;
}
示例14: testBadURIs
import javax.sip.address.URI; //导入依赖的package包/类
public void testBadURIs() throws Exception {
for (int i = 0; i < badURIs.length; i++) {
try {
URI uri = uri(badURIs[i]);
fail(uri + " should throw parse exception");
} catch (ParseException e) {
// ok
}
}
}
示例15: get
import javax.sip.address.URI; //导入依赖的package包/类
private static String get(HeaderAddress header, Function<SipUri, String> getter) {
URI uri = getURI(header);
if (uri instanceof SipUri) {
return getter.apply((SipUri) uri);
} else if (uri instanceof TelURL) {
return ((TelURL) uri).getPhoneNumber();
}
return null;
}