Package javax.sip.message

Examples of javax.sip.message.Response

  • 2xx: Success -- the action was successfully received, understood, and accepted.
  • 3xx: Redirection -- further action needs to be taken in order to complete the request; 3xx responses give information about the user's new location, or about alternative services that might be able to satisfy the call.
  • 4xx: Client Error -- the request contains bad syntax or cannot be fulfilled at this server; 4xx responses are definite failure responses from a particular server. The client SHOULD NOT retry the same request without modification. However, the same request to a different server might be successful.
  • 5xx: Server Error -- the server failed to fulfill an apparently valid request; 5xx responses are failure responses given when a server itself has erred.
  • 6xx: Global Failure -- the request cannot be fulfilled at any server; 6xx responses indicate that a server has definitive information about a particular user, not just the particular instance indicated in the Request-URI. SIP status codes are extensible. The response codes are consistent with, and extend, HTTP/1.1 response codes. Not all HTTP/1.1 response codes are appropriate, and only those that are appropriate are given here. Other HTTP/1.1 response codes SHOULD NOT be used. Also, SIP defines a new class, 6xx.

    SIP applications are not required to understand the meaning of all registered response codes, though such understanding is obviously desirable. However, applications must understand the class of any status code, as indicated by the first digit and outlined above. Applications treat any unrecognized status code as being equivalent to the x00 status code of that class, with the exception that an unrecognized status code must not be cached. For example, if a client receives an unrecognized status code of 431, it can safely assume that there was something wrong with its request and treat the Response as if it had received a BAD_REQUEST(400) status code. In such cases, user agents should present to the user the message body returned with the Response, since that message body is likely to include human-readable information which will explain the unusual status.

    This specification supports the response codes defined in RFC3261 and also the response code extensions for the event notification framework and PUBLISH, documented in RFC3265 and RFC3909, these are highlighted in italic. Class status codes (x00, i.e. 100) are are highlighted in bold.

    Class Code
    PROVISIONAL (1xx)
  • TRYING - 100
  • RINGING - 180
  • CALL_IS_BEING_FORWARDED - 181
  • QUEUED - 182
  • SESSION_PROGRESS - 183
  • SUCCESS (2xx)
  • OK - 200
  • ACCEPTED - 202 (Extension RFC3265)
  • REDIRECTION (3xx)
  • MULTIPLE_CHOICES - 300
  • MOVED_PERMANENTLY - 301
  • MOVED_TEMPORARILY - 302
  • USE_PROXY - 305
  • ALTERNATIVE_SERVICE - 380
  • CLIENT_ERROR (4xx)
  • BAD_REQUEST - 400
  • UNAUTHORIZED - 401
  • PAYMENT_REQUIRED - 402
  • FORBIDDEN - 403
  • NOT_FOUND - 404
  • METHOD_NOT_ALLOWED - 405
  • NOT_ACCEPTABLE - 406
  • PROXY_AUTHENTICATION_REQUIRED - 407
  • REQUEST_TIMEOUT - 408
  • GONE - 410
  • CONDITIONAL_REQUEST_FAILED - 412 (Extension RFC3909)
  • REQUEST_ENTITY_TOO_LARGE - 413
  • REQUEST_URI_TOO_LONG - 414
  • UNSUPPORTED_MEDIA_TYPE - 415
  • UNSUPPORTED_URI_SCHEME - 416
  • BAD_EXTENSION - 420
  • EXTENSION_REQUIRED - 421
  • INTERVAL_TOO_BRIEF - 423
  • TEMPORARILY_UNAVAILABLE - 480
  • CALL_OR_TRANSACTION_DOES_NOT_EXIST - 481
  • LOOP_DETECTED - 482
  • TOO_MANY_HOPS - 483
  • ADDRESS_INCOMPLETE - 484
  • AMBIGUOUS - 485
  • BUSY_HERE - 486
  • REQUEST_TERMINATED - 487
  • NOT_ACCEPTABLE_HERE - 488
  • BAD EVENT - 489 (Extension RFC3265)
  • REQUEST_PENDING - 491
  • UNDECIPHERABLE - 493
  • SERVER_ERROR (5xx)
  • SERVER_INTERNAL_ERROR - 500
  • NOT_IMPLEMENTED - 501
  • BAD_GATEWAY - 502
  • SERVICE_UNAVAILABLE - 503
  • SERVER_TIMEOUT - 504
  • VERSION_NOT_SUPPORTED - 505
  • MESSAGE_TOO_LARGE - 513
  • GLOBAL_ERROR (6xx)
  • BUSY_EVERYWHERE - 600
  • DECLINE - 603
  • DOES_NOT_EXIST_ANYWHERE - 604
  • SESSION_NOT_ACCEPTABLE - 606
  • @author BEA Systems, NIST @version 1.2

  •             // we have to reply an eventual error code statelessly

                if (!checkURIScheme(request))
                {
                    // Let's return a 416 Unsupported URI scheme
                    Response response = messageFactory.createResponse(
                            Response.UNSUPPORTED_URI_SCHEME, request);
                    if (serverTransaction != null)
                        serverTransaction.sendResponse(response);
                    else
                        sipProvider.sendResponse(response);
                    return false;
                }

                if (!checkMaxForwards(request))
                {
                    // Let's return a 483 too many hops
                    Response response = messageFactory.createResponse(
                            Response.TOO_MANY_HOPS, request);
                    if (serverTransaction != null)
                        serverTransaction.sendResponse(response);
                    else
                        sipProvider.sendResponse(response);
                    return false;
                }

                if (!checkLoopDetection(request))
                {
                    // Let's return a 482 Loop detection
                    Response response = messageFactory.createResponse(
                            Response.LOOP_DETECTED, request);
                    if (serverTransaction != null)
                        serverTransaction.sendResponse(response);
                    else
                        sipProvider.sendResponse(response);
                    return false;
                }

                if (!checkProxyRequire(request))
                {
                    // Let's return a 420 Bad Extension
                    Response response = messageFactory.createResponse(
                            Response.BAD_EXTENSION, request);

                    // We have to add a Unsupported header listing the Option tags
                    // that we don't support:
                    HeaderFactory headerFactory = proxy.getHeaderFactory();
                    ProxyRequireHeader prh = (ProxyRequireHeader) request
                            .getHeader(ProxyRequireHeader.NAME);
                    if (prh != null)
                    {
                        UnsupportedHeader unsupportedHeader = headerFactory
                                .createUnsupportedHeader(prh.getOptionTag());
                        response.setHeader(unsupportedHeader);
                    }

                    if (serverTransaction != null)
                        serverTransaction.sendResponse(response);
                    else
                        sipProvider.sendResponse(response);

                    return false;
                }

                // Let's add some more important basics checks:
                // - From tag presence.

                if (!checkFromTag(request))
                {
                    // Let's return a 400 BAD_REQUEST
                    Response response = messageFactory.createResponse(
                            Response.BAD_REQUEST, request);
                    if (serverTransaction != null)
                        serverTransaction.sendResponse(response);
                    else
                        sipProvider.sendResponse(response);
                    return false;
                }

                // For Event notifications:
                if (presenceServer)
                {
                    String method = request.getMethod();
                    if (method.equals("SUBSCRIBE"))
                    {

                        // RFC 3265 3.1.1:
                        /*
                         * Subscribers MUST include exactly one "Event" header in
                         * SUBSCRIBE requests, indicating to which event or class of
                         * events they are subscribing.
                         */
                        if (!checkEventHeader(request))
                        {
                            // Let's return a 400 BAD_REQUEST
                            Response response = messageFactory.createResponse(
                                    Response.BAD_REQUEST, request);
                            if (serverTransaction != null)
                                serverTransaction.sendResponse(response);
                            else
                                sipProvider.sendResponse(response);
    View Full Code Here


        {
            ServerTransaction transaction = event.getServerTransaction();

            try
            {
                Response resp = jiplet.getMessageFactory().createResponse(response,
                        event.getRequest());

                if (reason != null)
                {
                    resp.setReasonPhrase(reason);
                }

                if (authHeader != null)
                {
                    resp.addHeader(authHeader);
                }

                if (transaction != null)
                {
                    transaction.sendResponse(resp);
    View Full Code Here

         * @param response
         *                       response object.
         */
        public void processResponse(JipletResponse response)
        {
            Response rsp_msg = response.getResponseEvent().getResponse();
            if (isDebugEnabled() == true)
            {
                debug("Response event received. Status Code="
                        + rsp_msg.getStatusCode() + "\n "
                        + rsp_msg.getHeader(FromHeader.NAME) + "\n "
                        + rsp_msg.getHeader(ToHeader.NAME) + "\n "
                        + rsp_msg.getHeader(CallIdHeader.NAME) + "\n"
                        + rsp_msg.getHeader(CSeqHeader.NAME));
            }
        }
    View Full Code Here

         */
        public void processResponse(ResponseEvent ev)
        {
            try
            {
                Response response = ev.getResponse();

                // find out if the response is the final response.
                boolean del = true;
                int status_code = response.getStatusCode();
                if ((status_code >= 100) && (status_code < 200))
                {
                    del = false;
                }

    View Full Code Here

                if (LOG.isDebugEnabled()) {
                    LOG.debug("SipPresenceAgentListener: Received a Publish request, sending OK");
                    LOG.debug("SipPresenceAgentListener request: " + request);
                }
                EventHeader eventHeader = (EventHeader) requestEvent.getRequest().getHeader(EventHeader.NAME);
                Response response = sipPresenceAgent.getConfiguration().getMessageFactory().createResponse(202, request);
                sipPresenceAgent.getProvider().sendResponse(response);

                // Send notification to subscriber
                sendNotification(eventHeader, false, request.getContent());
                        
    View Full Code Here

                    }
                    return;
                }

                // Always create a ServerTransaction, best as early as possible in the code
                Response response = null;
                ServerTransaction st = requestEvent.getServerTransaction();
                if (st == null) {
                    st = sipProvider.getNewServerTransaction(request);
                }

                // Check if it is an initial SUBSCRIBE or a refresh / unsubscribe
                boolean isInitial = requestEvent.getDialog() == null;
                if (isInitial) {
                    String toTag = UUID.randomUUID().toString();
                    response = sipPresenceAgent.getConfiguration().getMessageFactory().createResponse(202, request);
                    ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
                    toHeader.setTag(toTag); // Application is supposed to set.

                    this.dialog = st.getDialog();
                    // subscribe dialogs do not terminate on bye.
                    this.dialog.terminateOnBye(false);
                } else {
                    response = sipPresenceAgent.getConfiguration().getMessageFactory().createResponse(200, request);
                }

                // Both 2xx response to SUBSCRIBE and NOTIFY need a Contact
                response.addHeader(sipPresenceAgent.getConfiguration().getContactHeader());

                // Expires header is mandatory in 2xx responses to SUBSCRIBE
                response.addHeader(sipPresenceAgent.getConfiguration().getExpiresHeader());
                st.sendResponse(response);
               
                if (LOG.isDebugEnabled()) {
                    LOG.debug("SipPresenceAgentListener: Sent OK Message");
                    LOG.debug("SipPresenceAgentListener response: " + response);
    View Full Code Here

                LOG.error("Exception thrown during Notify processing in the SipPresenceAgentListener.", e);
            }
        }

        public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
            Response response = responseReceivedEvent.getResponse();
            Integer statusCode = response.getStatusCode();
            if (SIP_MESSAGE_CODES.containsKey(statusCode)) {
                LOG.debug(SIP_MESSAGE_CODES.get(statusCode) + " received from Subscriber");
            }
        }
    View Full Code Here

                }
                //Dispatch the response along the route
                dispatchExchange(notify.getContent());
               
                // Send back an success response
                Response response = sipSubscriber.getConfiguration().getMessageFactory().createResponse(200, notify);           
                response.addHeader(sipSubscriber.getConfiguration().getContactHeader());
                serverTransactionId.sendResponse(response);

                SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify
                        .getHeader(SubscriptionStateHeader.NAME);
    View Full Code Here

            ClientTransaction clientTransaction = responseReceivedEvent
                    .getClientTransaction();
            if (clientTransaction == null) {
                return;
            }
            Response response = responseReceivedEvent.getResponse();
            String method = ((CSeqHeader) response.getHeader(CSeqHeader.NAME))
                    .getMethod();

            // OK
            if (response.getStatusCode() == Response.OK) {
                // REGISTER
                if (method.equals(Request.REGISTER)) {
                    registerProcessing.processOK(clientTransaction, response);
                }
            }
            // NOT_FOUND
            else if (response.getStatusCode() == Response.NOT_FOUND) {
                if (method.equals(Request.REGISTER)) {
                    try {
                        unregister();
                        registrationFailed(RegistrationEvent.Type.NotFound);
                    }
                    catch (CommunicationsException e) {
                        Log.error("NOT FOUND", e);
                    }
                    Log.debug("REGISTER NOT FOUND");
                }
            }
            // NOT_IMPLEMENTED
            else if (response.getStatusCode() == Response.NOT_IMPLEMENTED) {
                if (method.equals(Request.REGISTER)) {
                    // Fixed typo issues - Reported by pizarro
                    registerProcessing.processNotImplemented(clientTransaction,
                            response);
                }
            }
            // REQUEST_TERMINATED
            // 401 UNAUTHORIZED
            else if (response.getStatusCode() == Response.UNAUTHORIZED
                    || response.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED) {
                if (method.equals(Request.REGISTER)) {
                    CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
                    if (cseq.getSequenceNumber() < 2)
                        registerProcessing.processAuthenticationChallenge(
                                clientTransaction, response);
                    else
                        registrationFailed(RegistrationEvent.Type.WrongPass);
                }
            }
            // 403 Wrong Authorization user for this account
            else if(response.getStatusCode() == Response.FORBIDDEN){
                registrationFailed(RegistrationEvent.Type.Forbidden);
            }
        } // process response
    View Full Code Here

                LOG.error("Exception thrown during Notify processing in the SipPresenceAgentListener.", e);
            }
        }

        public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
            Response response = responseReceivedEvent.getResponse();
            Integer statusCode = response.getStatusCode();
            if (SIP_MESSAGE_CODES.containsKey(statusCode)) {
                LOG.debug(SIP_MESSAGE_CODES.get(statusCode) + " received from Subscriber");
            }
        }
    View Full Code Here

    TOP

    Related Classes of javax.sip.message.Response

    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.