Package gov.nist.javax.sip.address

Examples of gov.nist.javax.sip.address.SipUri


     * @throws ParseException if there was a problem parsing.
     */
    public SipUri sipURL( boolean inBrackets ) throws ParseException {
        if (debug)
            dbg_enter("sipURL");
        SipUri retval = new SipUri();
        // pmusgrave - handle sips case
        Token nextToken = lexer.peekNextToken();
        int sipOrSips = TokenTypes.SIP;
        String scheme = TokenNames.SIP;
        if ( nextToken.getTokenType() == TokenTypes.SIPS)
        {
            sipOrSips = TokenTypes.SIPS;
            scheme = TokenNames.SIPS;
        }

        try {
            lexer.match(sipOrSips);
            lexer.match(':');
            retval.setScheme(scheme);
            int startOfUser = lexer.markInputPosition();
            String userOrHost = user();// Note: user may contain ';', host may not...
            String passOrPort = null;

            // name:password or host:port
            if ( lexer.lookAhead() == ':' ) {
                lexer.consume(1);
                passOrPort = password();
            }

            // name@hostPort
            if ( lexer.lookAhead() == '@' ) {
                lexer.consume(1);
                retval.setUser( userOrHost );
                if (passOrPort!=null) retval.setUserPassword( passOrPort );
            } else {
                // then userOrHost was a host, backtrack just in case a ';' was eaten...
                lexer.rewindInputPosition( startOfUser );
            }

            HostNameParser hnp = new HostNameParser(this.getLexer());
            HostPort hp = hnp.hostPort( false );
            retval.setHostPort(hp);

            lexer.selectLexer("charLexer");
            while (lexer.hasMoreChars()) {
              // If the URI is not enclosed in brackets, parameters belong to header
                if (lexer.lookAhead(0) != ';' || !inBrackets)
                    break;
                lexer.consume(1);
                NameValue parms = uriParam();
                if (parms != null) retval.setUriParameter(parms);
            }

            if (lexer.hasMoreChars() && lexer.lookAhead(0) == '?') {
                lexer.consume(1);
                while (lexer.hasMoreChars()) {
                    NameValue parms = qheader();
                    retval.setQHeader(parms);
                    if (lexer.hasMoreChars() && lexer.lookAhead(0) != '&')
                        break;
                    else
                        lexer.consume(1);
                }
View Full Code Here


     * @throws ParseException if there was a problem parsing.
     */
    public SipUri sipURL( boolean inBrackets ) throws ParseException {
        if (debug)
            dbg_enter("sipURL");
        SipUri retval = new SipUri();
        // pmusgrave - handle sips case
        Token nextToken = lexer.peekNextToken();
        int sipOrSips = TokenTypes.SIP;
        String scheme = TokenNames.SIP;
        if ( nextToken.getTokenType() == TokenTypes.SIPS)
        {
            sipOrSips = TokenTypes.SIPS;
            scheme = TokenNames.SIPS;
        }

        try {
            lexer.match(sipOrSips);
            lexer.match(':');
            retval.setScheme(scheme);
            int startOfUser = lexer.markInputPosition();
            String userOrHost = user();// Note: user may contain ';', host may not...
            String passOrPort = null;

            // name:password or host:port
            if ( lexer.lookAhead() == ':' ) {
                lexer.consume(1);
                passOrPort = password();
            }

            // name@hostPort
            if ( lexer.lookAhead() == '@' ) {
                lexer.consume(1);
                retval.setUser( userOrHost );
                if (passOrPort!=null) retval.setUserPassword( passOrPort );
            } else {
                // then userOrHost was a host, backtrack just in case a ';' was eaten...
                lexer.rewindInputPosition( startOfUser );
            }

            HostNameParser hnp = new HostNameParser(this.getLexer());
            HostPort hp = hnp.hostPort( false );
            retval.setHostPort(hp);

            lexer.selectLexer("charLexer");
            while (lexer.hasMoreChars()) {
              // If the URI is not enclosed in brackets, parameters belong to header
                if (lexer.lookAhead(0) != ';' || !inBrackets)
                    break;
                lexer.consume(1);
                NameValue parms = uriParam();
                if (parms != null) retval.setUriParameter(parms);
            }

            if (lexer.hasMoreChars() && lexer.lookAhead(0) == '?') {
                lexer.consume(1);
                while (lexer.hasMoreChars()) {
                    NameValue parms = qheader();
                    retval.setQHeader(parms);
                    if (lexer.hasMoreChars() && lexer.lookAhead(0) != '&')
                        break;
                    else
                        lexer.consume(1);
                }
View Full Code Here

    public ContactHeader createContactHeader() {
        try {
            String ipAddress = this.getIPAddress();
            int port = this.getPort();
            SipURI sipURI = new SipUri();
            sipURI.setHost(ipAddress);
            sipURI.setPort(port);
            sipURI.setTransportParam(this.transport);
            Contact contact = new Contact();
            AddressImpl address = new AddressImpl();
            address.setURI(sipURI);
            contact.setAddress(address);
           
View Full Code Here

            }

            if (requestLine.getUri() instanceof SipUri) {
                String scheme = ((SipUri) requestLine.getUri()).getScheme();
                if ("sips".equalsIgnoreCase(scheme)) {
                    SipUri sipUri = (SipUri) this.getContactHeader().getAddress().getURI();
                    if (!sipUri.getScheme().equals("sips")) {
                        throw new ParseException("Scheme for contact should be sips:" + sipUri, 0);
                    }
                }
            }
        }
View Full Code Here

        GenericURI u = requestLine.getUri();
        if (u == null)
            return;
        if (method.compareTo(Request.REGISTER) == 0 || method.compareTo(Request.INVITE) == 0) {
            if (u instanceof SipUri) {
                SipUri sipUri = (SipUri) u;
                sipUri.setUserParam(DEFAULT_USER);
                try {
                    sipUri.setTransportParam(DEFAULT_TRANSPORT);
                } catch (ParseException ex) {
                }
            }
        }
    }
View Full Code Here

         * Forgive the sins of B2BUA's that like to record route ACK's
         */
        if (dialog != null && sipProvider != dialog.getSipProvider()) {
            final Contact contact = dialog.getMyContactHeader();
            if (contact != null) {
                SipUri contactUri = (SipUri) (contact.getAddress().getURI());
                String ipAddress = contactUri.getHost();
                int contactPort = contactUri.getPort();
                String contactTransport = contactUri.getTransportParam();
                if (contactTransport == null)
                    contactTransport = "udp";
                if (contactPort == -1) {
                    if (contactTransport.equals("udp")
                            || contactTransport.equals("tcp"))
                        contactPort = 5060;
                    else
                        contactPort = 5061;
                }
                // Check if the dialog contact is the same as the provider on
                // which we got the request. Otherwise, dont assign this
                // dialog to the request.
                if (ipAddress != null
                        && (!ipAddress.equals(listeningPoint.getIPAddress()) || contactPort != listeningPoint
                                .getPort())) {
                    if (sipStack.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
                        sipStack.getStackLogger().logDebug(
                                "nulling dialog -- listening point mismatch!  "
                                        + contactPort + "  lp port = "
                                        + listeningPoint.getPort());

                    }
                    dialog = null;
                }

            }
        }

        /*
         * RFC 3261 8.2.2.2 Merged requests: If the request has no tag in the To
         * header field, the UAS core MUST check the request against ongoing
         * transactions. If the From tag, Call-ID, and CSeq exactly match those
         * associated with an ongoing transaction, but the request does not
         * match that transaction (based on the matching rules in Section
         * 17.2.3), the UAS core SHOULD generate a 482 (Loop Detected) response
         * and pass it to the server transaction. This support is only enabled
         * when the stack has been instructed to function with Automatic Dialog
         * Support.
         */
        if (sipProvider.isDialogErrorsAutomaticallyHandled()
                && sipRequest.getToTag() == null) {
            if (sipStack.findMergedTransaction(sipRequest)) {
                this.sendLoopDetectedResponse(sipRequest, transaction);
                return;
            }
        }

        if (sipStack.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
            sipStack.getStackLogger().logDebug("dialogId = " + dialogId);
            sipStack.getStackLogger().logDebug("dialog = " + dialog);
        }

        /*
         * RFC 3261 Section 16.4 If the first value in the Route header field
         * indicates this proxy,the proxy MUST remove that value from the
         * request .
         */

        // If the message is being processed
        // by a Proxy, then the proxy will take care of stripping the
        // Route header. If the request is being processed by an
        // endpoint, then the stack strips off the route header.
        if (sipRequest.getHeader(Route.NAME) != null
                && transaction.getDialog() != null) {
            final RouteList routes = sipRequest.getRouteHeaders();
            final Route route = (Route) routes.getFirst();
            final SipUri uri = (SipUri) route.getAddress().getURI();
            final HostPort hostPort = uri.getHostPort();
            int port;
            if (hostPort.hasPort()) {
                port = hostPort.getPort();
            } else {
                if (listeningPoint.getTransport().equalsIgnoreCase(
View Full Code Here

           * assigned to the dialog. Forgive the sins of B2BUA's that like to record route ACK's
           */
          if (dialog != null && sipProvider != dialog.getSipProvider()) {
              final Contact contact = dialog.getMyContactHeader();
              if (contact != null) {
                  SipUri contactUri = (SipUri) (contact.getAddress().getURI());
                  String ipAddress = contactUri.getHost();
                  int contactPort = contactUri.getPort();
                  String contactTransport = contactUri.getTransportParam();
                  if (contactTransport == null)
                      contactTransport = "udp";
                  if (contactPort == -1) {
                      if (contactTransport.equals("udp") || contactTransport.equals("tcp"))
                          contactPort = 5060;
                      else
                          contactPort = 5061;
                  }
                  // Check if the dialog contact is the same as the provider on
                  // which we got the request. Otherwise, dont assign this
                  // dialog to the request.
                  if (ipAddress != null
                          && (!ipAddress.equals(listeningPoint.getIPAddress()) || contactPort != listeningPoint
                                  .getPort())) {
                      if (sipStack.isLoggingEnabled()) {
                          sipStack.getStackLogger().logDebug(
                                  "nulling dialog -- listening point mismatch!  " + contactPort
                                          + "  lp port = " + listeningPoint.getPort());
 
                      }
                      dialog = null;
                  }
 
              }
          }
 
          /*
           * RFC 3261 8.2.2.2 Merged requests: If the request has no tag in the To header field, the
           * UAS core MUST check the request against ongoing transactions. If the From tag, Call-ID,
           * and CSeq exactly match those associated with an ongoing transaction, but the request
           * does not match that transaction (based on the matching rules in Section 17.2.3), the
           * UAS core SHOULD generate a 482 (Loop Detected) response and pass it to the server
           * transaction. This support is only enabled when the stack has been instructed to
           * function with Automatic Dialog Support.
           */
          if ( sipProvider.isDialogErrorsAutomaticallyHandled()
                  && sipRequest.getToTag() == null) {
              if ( sipStack
                      .findMergedTransaction(sipRequest)) {
                  this.sendLoopDetectedResponse(sipRequest, transaction);
                  return;
              }
          }
 
          if (sipStack.isLoggingEnabled()) {
              sipStack.getStackLogger().logDebug("dialogId = " + dialogId);
              sipStack.getStackLogger().logDebug("dialog = " + dialog);
          }
 
          /*
           * RFC 3261 Section 16.4 If the first value in the Route header field indicates this
           * proxy,the proxy MUST remove that value from the request .
           */
 
          // If the message is being processed
          // by a Proxy, then the proxy will take care of stripping the
          // Route header. If the request is being processed by an
          // endpoint, then the stack strips off the route header.
          if (sipRequest.getHeader(Route.NAME) != null && transaction.getDialog() != null) {
              final RouteList routes = sipRequest.getRouteHeaders();
              final Route route = (Route) routes.getFirst();
              final SipUri uri = (SipUri) route.getAddress().getURI();
              final HostPort hostPort = uri.getHostPort();
              int port;
              if (hostPort.hasPort()) {
                  port = hostPort.getPort();
              } else {
                  if (listeningPoint.getTransport().equalsIgnoreCase(ListeningPoint.TLS))
View Full Code Here

                || (this.isServer() && this.getState().getValue() == EARLY_STATE && method
                        .equalsIgnoreCase(Request.BYE)))
            throw new SipException("Dialog  " + getDialogId()
                    + " not yet established or terminated " + this.getState());

        SipUri sipUri = null;
        if (this.getRemoteTarget() != null)
            sipUri = (SipUri) this.getRemoteTarget().getURI().clone();
        else {
            sipUri = (SipUri) this.getRemoteParty().getURI().clone();
            sipUri.clearUriParms();
        }

        CSeq cseq = new CSeq();
        try {
            cseq.setMethod(method);
View Full Code Here

                || (this.isServer() && this.getState().getValue() == EARLY_STATE && method
                        .equalsIgnoreCase(Request.BYE)))
            throw new SipException("Dialog  " + getDialogId()
                    + " not yet established or terminated " + this.getState());

        SipUri sipUri = null;
        if (this.getRemoteTarget() != null)
            sipUri = (SipUri) this.getRemoteTarget().getURI().clone();
        else {
            sipUri = (SipUri) this.getRemoteParty().getURI().clone();
            sipUri.clearUriParms();
        }

        CSeq cseq = new CSeq();
        try {
            cseq.setMethod(method);
View Full Code Here

TOP

Related Classes of gov.nist.javax.sip.address.SipUri

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.