本文整理汇总了Java中javax.sip.address.URI类的典型用法代码示例。如果您正苦于以下问题:Java URI类的具体用法?Java URI怎么用?Java URI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
URI类属于javax.sip.address包,在下文中一共展示了URI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:MultipleContactsTest.java
示例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();
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:27,代码来源:ViaRPortTest.java
示例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();
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:8,代码来源:NonSipUriRouter.java
示例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()");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:HeaderFactoryTest.java
示例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()");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:HeaderFactoryTest.java
示例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()");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:HeaderFactoryTest.java
示例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();
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:18,代码来源:SipClient.java
示例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;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:30,代码来源:RegisterMessage.java
示例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);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:44,代码来源:DigestServerAuthenticationHelper.java
示例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();
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:12,代码来源:SIPRequest.java
示例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;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:20,代码来源:SIPRequest.java
示例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);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:13,代码来源:PAssociatedURI.java
示例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;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:12,代码来源:GenericURI.java
示例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
}
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:11,代码来源:JainSipUriTest.java
示例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;
}
开发者ID:sip3io,项目名称:tapir,代码行数:10,代码来源:HeaderAddressUtil.java
示例16: getURI
import javax.sip.address.URI; //导入依赖的package包/类
private static URI getURI(HeaderAddress header) {
if (header == null) {
return null;
}
Address address = header.getAddress();
if (address == null) {
return null;
}
return address.getURI();
}
开发者ID:sip3io,项目名称:tapir,代码行数:11,代码来源:HeaderAddressUtil.java
示例17: MakeRequest
import javax.sip.address.URI; //导入依赖的package包/类
/**
*
* @param sipManager - SipManager object
* @param to - To identifies receiver IP
* @param message Message that should be send
* @return Return SIP Message.
* @throws ParseException
* @throws InvalidArgumentException
*/
public Request MakeRequest(SipManager sipManager, String to, String message) throws ParseException, InvalidArgumentException {
AddressFactory addressFactory = sipManager.addressFactory;
sipManager.setCseqNumber((long)sipManager.getCseqNumber()+1l);
Address fromNameAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
FromHeader fromHeader = sipManager.headerFactory.createFromHeader(fromNameAddress, "SyMPHOnY");
URI toAddress = sipManager.addressFactory.createURI(to);
Address toNameAddress = sipManager.addressFactory.createAddress(toAddress);
ToHeader toHeader = sipManager.headerFactory.createToHeader(toNameAddress, null);
URI requestURI = sipManager.addressFactory.createURI(to);
ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
CallIdHeader callIdHeader = sipManager.sipProvider.getNewCallId();
CSeqHeader cSeqHeader = sipManager.headerFactory.createCSeqHeader(sipManager.getCseqNumber(),Request.MESSAGE);
MaxForwardsHeader maxForwards = sipManager.headerFactory
.createMaxForwardsHeader(70);
Request request = sipManager.messageFactory.createRequest(requestURI,
Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
toHeader, viaHeaders, maxForwards);
SupportedHeader supportedHeader = sipManager.headerFactory
.createSupportedHeader("replaces, outbound");
request.addHeader(supportedHeader);
SipURI routeUri = sipManager.addressFactory.createSipURI(null,
SipManager.proxyIp);
routeUri.setTransportParam(SipManager.transport);
routeUri.setLrParam();
routeUri.setPort(SipManager.proxyPort);
Address routeAddress = sipManager.addressFactory
.createAddress(routeUri);
RouteHeader route = sipManager.headerFactory
.createRouteHeader(routeAddress);
request.addHeader(route);
ContentTypeHeader contentTypeHeader = sipManager.headerFactory
.createContentTypeHeader("text", "plain");
request.setContent(message, contentTypeHeader);
System.out.println(request);
return request;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:48,代码来源:MessageMessage.java
示例18: 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;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:34,代码来源:RegisterMessage.java
示例19: getDisplayName
import javax.sip.address.URI; //导入依赖的package包/类
/**
* Returns a human readable name representing this peer.
*
* @return a String containing a name for that peer.
*/
public String getDisplayName()
{
String displayName = getPeerAddress().getDisplayName();
if(displayName == null)
{
Contact contact = getContact();
if (contact != null)
displayName = contact.getDisplayName();
else
{
URI peerURI = getPeerAddress().getURI();
if (peerURI instanceof SipURI)
{
String userName = ((SipURI) peerURI).getUser();
if (userName != null && userName.length() > 0)
displayName = userName;
}
else
{
displayName = peerURI.toString();
}
}
}
if(displayName.startsWith("sip:"))
displayName = displayName.substring(4);
return displayName;
}
开发者ID:zhaozw,项目名称:android-1,代码行数:39,代码来源:CallPeerSipImpl.java
示例20: getDisplayName
import javax.sip.address.URI; //导入依赖的package包/类
/**
* Returns a human readable name representing this peer.
*
* @return a String containing a name for that peer.
*/
public String getDisplayName()
{
String displayName = getPeerAddress().getDisplayName();
if(displayName == null)
{
Contact contact = getContact();
if (contact != null)
displayName = contact.getDisplayName();
else
{
URI peerURI = getPeerAddress().getURI();
if (peerURI instanceof SipURI)
{
String userName = ((SipURI) peerURI).getUser();
if (userName != null && userName.length() > 0)
displayName = userName;
}
if (displayName == null)
{
displayName = peerURI.toString();
}
}
}
if(displayName.startsWith("sip:"))
displayName = displayName.substring(4);
return displayName;
}
开发者ID:jitsi,项目名称:jitsi,代码行数:39,代码来源:CallPeerSipImpl.java
注:本文中的javax.sip.address.URI类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论