Package javax.servlet.sip

Examples of javax.servlet.sip.Address


            String sp = getPolicyFromApp(req);
            if (sp.equals("")) {               
                return;
            }

            Address rrHeader = req.getAddressHeaderImpl(Header.RECORD_ROUTE);

            if (rrHeader == null) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, "Record-Route is null. Returning");
                }               
                return;
            }

            SipURI uri = null;
            if (rrHeader.getURI().isSipURI()) {
                uri = (SipURI) rrHeader.getURI();
            }

            if (uri == null) {               
                if (logger.isLoggable(Level.FINER)) {
                    logger.log(Level.FINER, "Record-Route URI is not SIP?");
View Full Code Here


                failureResp.popDispatcher().dispatch(failureResp);

                return;
            }

            Address a = it_a.next();
            URIImpl uri = (URIImpl) a.getURI();

            // Session Case handling
            // TODO move constants
            final String CALL_PARAM = "call";
            final String CALL_PARAM_ORIG = "orig";
            final String CALL_PARAM_TERMINATING = "term_registered";
            final String CALL_PARAM_TERMINATING_UNREG = "term_unregistered";

            String callParam = uri.getParameter(CALL_PARAM);

            // if(callParam == null) callParam = uri.getParameter(CALL_PARAM);
            if (callParam == null) {
                req.setSessionCase(SessionCase.EXTERNAL);
            } else {
                if (callParam.equals(CALL_PARAM_ORIG)) {
                    req.setSessionCase(SessionCase.ORIGINATING);
                } else if (callParam.equals(CALL_PARAM_TERMINATING)) {
                    req.setSessionCase(SessionCase.TERMINATING);
                } else if (callParam.equals(CALL_PARAM_TERMINATING_UNREG)) {
                    req.setSessionCase(SessionCase.TERMINATING_UNREGISTERED);
                } else {
                    req.setSessionCase(SessionCase.EXTERNAL);
                    logger.log(Level.WARNING,
                        "Assigned SessionCase external due to unknown value of " +
                        CALL_PARAM + " :" + callParam);
                }
            }

            // end Session Case handling
            if (uri.getLrParam()) {
                // Before removing the Route header extract the fragment-id.
                // This code needs BASIC TESTING in an extended
                // spiraling scenario, such as
                //
                // UAC/EAS --> proxy/external --> proxy/EAS --> UAS/external
                //
                // logger.log(Level.FINE, "+++ Route header with ;lr seen in resolver");
                // logger.log(Level.FINE, "+++ try setting frag info from the Route header
                // URI");
                // logger.log(Level.FINE, "+++ URI: "+(SipURIImpl)a.getURI());
                // logger.log(Level.FINE, "+++ and the id is:
                // "+((SipURIImpl)a.getURI()).getFragmentId());
                // logger.log(Level.FINE, "+++ let's set it in the request then");
                req.setFragmentId(((URIImpl) a.getURI()).getFragmentId());

                if (remove) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "Removing route = " + a);
                    }
View Full Code Here

                    if (!resp487.getSessionImpl().hasNoToTag()) {
                        Header to = resp487.getRawHeader(Header.TO);
                        Header toC = resp200.getRawHeader(Header.TO);

                        try {
                            Address adr = to.getAddressValue();
                            ((AddressImpl) adr).setReadOnly(false);
                            adr.setParameter(AddressImpl.TAG_PARAM,
                                resp487.getSessionImpl().getToTag());
                            ((AddressImpl) adr).setReadOnly(true);

                            Address adrC = toC.getAddressValue();
                            ((AddressImpl) adrC).setReadOnly(false);
                            adrC.setParameter(AddressImpl.TAG_PARAM,
                                resp487.getSessionImpl().getToTag());
                            ((AddressImpl) adrC).setReadOnly(true);
                        } catch (ServletParseException e) {
                            throw new IllegalStateException(
                                "Parse problem of To Header");
                        }
                    }

                    /**
                     * Since the resp487.popDispatcher().dispatch(resp487) does
                     * not go though the FSM, instead goes directly to DialogManager,
                     * the updateSipSessionState was never called.
                     *
                     * Hence, we need to call updateSipSessionState from here
                     * so that the session is marked for readyToInvalidate.
                     */
                    resp487.getSessionImpl().updateSipSessionState(resp487, uas.getType());
                    resp487.popDispatcher().dispatch(resp487);
                    m_INVITE.setSentResponse(resp487.getStatus());
                    resp200.popDispatcher().dispatch(resp200);
                } else if (method.equals("UPDATE")) {
                    if (!req.getSessionImpl().setUpdateOngoing()) {
                        resp = req.createTerminatingResponse(500);
                        resp.setHeader("Retry-After", "5");
                    }
                }
                // Can't sent response on ACK, cf
                // SipServletResponseImpl.populateResponse()
                else if (!method.equals("PRACK") && !method.equals("ACK")) {
                    // Forbidden
                    resp = req.createTerminatingResponse(403);
                }

                break;
            }

            case TRYING_UAS: {
                if (method.equals("CANCEL")) {
                    m_State = TERMINATED_UAS;
                    // lets inform that this session is ending
                    uas.removeDialogSession(method, null);

                    // 200 OK
                    SipServletResponseImpl resp200 = req.createTerminatingResponse(200);

                    // Request Terminated
                    SipServletResponseImpl resp487 = m_INVITE.createTerminatingResponse(487);

                    // lets respond 200 CANCEL and 487 INVITE
                    if (!resp487.getSessionImpl().hasNoToTag()) {
                        Header to = resp487.getRawHeader(Header.TO);
                        Header toC = resp200.getRawHeader(Header.TO);

                        try {
                            Address adr = to.getAddressValue();
                            ((AddressImpl) adr).setReadOnly(false);
                            adr.setParameter(AddressImpl.TAG_PARAM,
                                resp487.getSessionImpl().getToTag());
                            ((AddressImpl) adr).setReadOnly(true);

                            Address adrC = toC.getAddressValue();
                            ((AddressImpl) adrC).setReadOnly(false);
                            adrC.setParameter(AddressImpl.TAG_PARAM,
                                resp487.getSessionImpl().getToTag());
                            ((AddressImpl) adrC).setReadOnly(true);
                        } catch (ServletParseException e) {
                            throw new IllegalStateException(
                                "Parse problem of To Header");
                        }
                    }

                    resp487.popDispatcher().dispatch(resp487);
                    m_INVITE.setSentResponse(resp487.getStatus());
                    resp200.popDispatcher().dispatch(resp200);
                } else if (method.equals("UPDATE")) {
                    if (!req.getSessionImpl().setUpdateOngoing()) {
                        resp = req.createTerminatingResponse(500);
                        resp.setHeader("Retry-After", "5");
                    }
                }
                // Can't sent response on ACK, cf
                // SipServletResponseImpl.populateResponse()
                else if (!method.equals("ACK")) {
                    // Forbidden
                    resp = req.createTerminatingResponse(403);
                }

                break;
            }

            case CONFIRMED_UAS: {
                if (method.equals("ACK")) {
                    // Lets stop the timer which triggers re-sending of 200
                    // (RFC 3261 13.3.1)
                    if (m_TimerShort != null) {
                        m_TimerShort.cancel();
                        m_TimerShort = null;
                    }

                    if (m_TimerLong != null) {
                        m_TimerLong.cancel();
                        m_TimerLong = null;
                    }

                    m_State = RUNNING;
                    //dereference to release memory
                    m_RetransmitResponse = null;
                } else if (method.equals("UPDATE")) {
                    if (!req.getSessionImpl().setUpdateOngoing()) {
                        resp = req.createTerminatingResponse(500);
                        resp.setHeader("Retry-After", "5");
                    }
                } else if (method.equals("BYE")) {
                    // HH20098
                    // Lets stop the timer which triggers re-sending of 200
                    // (RFC 3261 13.3.1)
                    if (m_TimerShort != null) {
                        m_TimerShort.cancel();
                        m_TimerShort = null;
                    }

                    if (m_TimerLong != null) {
                        m_TimerLong.cancel();
                        m_TimerLong = null;
                    }

                    m_State = CLOSING_UAS;
                } else if (method.equals("CANCEL")) {
                    resp = req.createTerminatingResponse(481);
                } else if (method.equals("INVITE")) {
                    resp = req.createTerminatingResponse(491);
                } else if (!method.equals("PRACK")) {
                    resp = req.createTerminatingResponse(403);
                }

                break;
            }

            case TERMINATED_UAS: {
                if (method.equals("CANCEL")) {
                    // Forbidden
                    resp = req.createTerminatingResponse(403);
                }
                // Can't sent response on ACK, cf
                // SipServletResponseImpl.populateResponse()
                else if (!method.equals("ACK")) {
                    // Request Terminated
                    resp = req.createTerminatingResponse(487);
                }

                break;
            }

            case RUNNING: {
                if (method.equals("BYE")) {
                    m_State = CLOSING_UAS;
                } else if (method.equals("INVITE")) {
                    m_State = RE_INVITE_UAS;
                    m_INVITE = req;
                } else if (method.equals("PRACK")) {
                    // A 1XX is pending and a 200OK(INVITE) have been sent before
                    // receiving
                    // the PRACK request.
                    String rackPrack = req.getHeader(Header.RACK);

                    // The Rack Header in the PRACK must match the RSeq + CSeq of the
                    // prov response
                    if (!((rackPrack != null) && (m_Rack != null) &&
                            m_Rack.equalsIgnoreCase(rackPrack))) {
                        resp = req.createTerminatingResponse(481);
                    }
                } else if (method.equals("UPDATE")) {
                    if (!req.getSessionImpl().setUpdateOngoing()) {
                        resp = req.createTerminatingResponse(500);
                        resp.setHeader("Retry-After", "5");
                    }
                }
                // Can't sent response on ACK, cf
                // SipServletResponseImpl.populateResponse()
                else {
                     isInvokeServlet = false;
                     if (!method.equals("ACK")) {
                        // Forbidden
                        resp = req.createTerminatingResponse(403);
                     }
                }

                break;
            }

            case RE_INVITE_INITIAL_UAC:
            case RE_INVITE_TRYING_UAC:
            case RE_INVITE_EARLY_UAC: {
                if (method.equals("BYE")) {
                    m_State = CLOSING_UAS;
                } else if (method.equals("INVITE")) {
                    // OK, a remote INVITE arrived while processing
                    // a locally generated INVITE already
                    m_State = RUNNING;
                    // need to immediately respond with a pending response
                    resp = req.createTerminatingResponse(491);
                }
                // Can't sent response on ACK, cf
                // SipServletResponseImpl.populateResponse()
                else if (!method.equals("PRACK") && !method.equals("UPDATE") &&
                        !method.equals("ACK")) {
                    resp = req.createTerminatingResponse(403);
                }

                break;
            }

            case RE_INVITE_UAS: {
                if (method.equals("BYE")) {
                    m_State = CLOSING_UAS;
                } else if (method.equals("INVITE")) {
                    // OK, the second remote INVITE
                    // respond with an 500 error
                    // TODO add Retry-After Header
                    // random value between 0-10s
                    resp = req.createTerminatingResponse(500);
                } else if (method.equals("UPDATE")) {
                    if (!req.getSessionImpl().setUpdateOngoing()) {
                        resp = req.createTerminatingResponse(500);
                        resp.setHeader("Retry-After", "5");
                    }
                } else if (method.equals("CANCEL")) {
                    m_State = RUNNING;
                    // lets inform that this session is ending
                    uas.removeDialogSession(method, null);

                    // 200 OK
                    SipServletResponseImpl resp200 = req.createTerminatingResponse(200);

                    // Request Terminated
                    SipServletResponseImpl resp487 = m_INVITE.createTerminatingResponse(487);

                    // lets respond 200 CANCEL and 487 INVITE
                    if (!resp487.getSessionImpl().hasNoToTag()) {
                        Header to = resp487.getRawHeader(Header.TO);

                        try {
                            Address adr = to.getAddressValue();
                            ((AddressImpl) adr).setReadOnly(false);
                            adr.setParameter(AddressImpl.TAG_PARAM,
                                resp487.getSessionImpl().getToTag());
                            ((AddressImpl) adr).setReadOnly(true);
                        } catch (ServletParseException e) {
                            throw new IllegalStateException(
                                "Parse problem of To Header");
View Full Code Here

                setDerivedOrOriginalSession(resp, uas);
            } else {
                Header to = resp.getRawHeader(Header.TO);

                try {
                    Address adr = to.getAddressValue();
                    ((AddressImpl) adr).setReadOnly(false);
                    adr.setParameter(AddressImpl.TAG_PARAM, toTag);
                    ((AddressImpl) adr).setReadOnly(true);
                } catch (ServletParseException e) {
                    throw new IllegalStateException(
                        "Parse problem of To Header");
                }
View Full Code Here

     * @param x
     * @return
     * @throws ServletParseException
     */
    private URI nameAddrCreateURI(String x) throws ServletParseException {
        Address a = sf.createAddress(x);
        URI u = a.getURI();

        if (logger.isLoggable(Level.FINER)) {
            logger.log(Level.FINER, "string: " + x + ", parsed to Address: " + a + ", and URI: " + u);
        }

View Full Code Here

    }
   
    private boolean isRegisterOutbound(Header contactHeader) {
        try {
            if (contactHeader != null) {
                Address address = contactHeader.getAddressValue();
                if (address != null) {
                    String instanceId = address.getParameter(INSTANCE_ID_PARAM);
                    String regId = address.getParameter(REG_ID_PARAM);
                    if (instanceId != null) {
                        return true;
                    } else {
                        return false;
                    }
View Full Code Here

                TargetTuple flowTuple = flowToken.getRemote();

                //connectionView.getInstance().getConnectionView()
                if (getConnectioView().contains(flowTuple)) {
                    //remove the route header
                    Address poppedRoute = req.popRouteHeader();
                   
                    //remove if exists, exists for incoming dialog creational requests
                    poppedRoute.getURI().removeParameter(OUTBOUND_PARAM);
                    //we must check if there is already a value in route. eg put by clb.
                    if (SipFactoryImpl.isDialogCreational(req.getMethod())) {
                        //make sure we stay in the path
                        updateRecordRouteHeader(req, poppedRoute);
                    }
View Full Code Here

    }

    private void removeAlreadyUsedRecursiveContacts(SipServletResponseImpl resp) {
        // make sure that the targets have not been used before
        if ((resp.getStatus() / 100) == 3) {
            Address contact = null;
            URI uri = null;

            Header contacts = resp.getRawHeader(Header.CONTACT);
            contacts.setReadOnly(false);

            try {
                for (ListIterator<Address> li = contacts.getAddressValues();
                        li.hasNext();) {
                    contact = li.next();
                    uri = contact.getURI();

                    if ((uri != null) && (findBranch(uri) != null)) {
                        // remove contact
                        li.remove();
                    }
View Full Code Here

                if (m_logger.isLoggable(Level.FINE)) {
                    m_logger.log(Level.FINE, "Request should stay in container.");
                }

                // Pop route header
                Address a = req.popRouteHeader();
                if (a != null) {
                    // Add this layer as dispatcher
                    req.setInitialPoppedRoute(a);
                    req.pushApplicationDispatcher(this);
                    req.setFirstInvocation(true);
                   
                    try {
                        req.setLocal(TargetResolver.getInstance().resolveReq3263_4((SipURI) a.getURI(), req.getMessageSize()).getSocketAddress());
                        //req.setLocal(new InetSocketAddress(InetAddress.getLocalHost(),port));
                    } catch (Exception e) {
                        m_logger.log(Level.SEVERE, "Cannot resolve local address. ");
                    }
                    // Send onwards
View Full Code Here

        return m_InviteFsm;
    }

    private void saveRemoteTarget(SipServletMessageImpl m,
        boolean contactIsMandatory) throws ServletParseException {
        Address contact = m.getAddressHeaderImpl(Header.CONTACT);

        if (contact != null) {
            findSipSession()
                .setRemoteTarget(m.getAddressHeaderImpl(Header.CONTACT).getURI());
        } else {
View Full Code Here

TOP

Related Classes of javax.servlet.sip.Address

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.