Package javax.servlet.sip

Examples of javax.servlet.sip.SipServletRequest


                eventType = "refer" + resp.getCSeqNumber();
                ua.addDialogSession(method, eventType);
            } else {
                // need to get Event header from request of response
                // because there is no Event header in response
                SipServletRequest req = resp.getRequest();
                eventType = getEventType(req);

                if (eventType != null) {
                    if (method.equals("SUBSCRIBE")) {
                        setDerivedOrOriginalSession(resp, ua);
View Full Code Here


                ua.addDialogSession(method, eventType);
            }
        } else {
            // need to get Event header from request of response
            // because there is no Event header in response
            SipServletRequest req = resp.getRequest();
            eventType = getEventType(req);

            int status = resp.getStatus();

            if (eventType != null) {
View Full Code Here

     *        The object to evaluate
     * @return True if the value of the variable equals the specified literal
     *         value
     */
    public boolean evaluate(Object object) {
        SipServletRequest request = (SipServletRequest) object;
        String a = request.getMethod();

        return ignoreCase
        ? this.value.equalsIgnoreCase(getAttributeValue(variable, request))
        : this.value.equals(getAttributeValue(variable, request));
    }
View Full Code Here

    public void doReport(ServletRequest request, ServletResponse response) {
        Reporter reporter = ApplicationDispatcher.getInstance().getServletReporters();
        if (reporter != null) {
            if (request != null) {
                SipServletRequest sipreq = (SipServletRequest) request;
                String interceptedAt = sipreq.getApplicationSession().getApplicationName() + "/" + servlet.getServletName();
                reporter.logIncomingRequest(Reporter.InterceptionType.SERVLET, sipreq, interceptedAt);
            } else {
                SipServletResponse sipresp = (SipServletResponse) response;
                String interceptedAt = sipresp.getApplicationSession().getApplicationName() + "/" + servlet.getServletName();
                reporter.logIncomingResponse(Reporter.InterceptionType.SERVLET, sipresp, interceptedAt);
View Full Code Here

    public void doReportPost(ServletRequest request, ServletResponse response, Exception exceptionInCaseOfException) {
        Reporter reporter = ApplicationDispatcher.getInstance().getServletReporters();
        if (reporter != null) {
            if (request != null) {
                SipServletRequest sipreq = (SipServletRequest) request;
                String interceptedAt = sipreq.getApplicationSession().getApplicationName() + "/" + servlet.getServletName();
                reporter.logPostIncomingRequest(Reporter.InterceptionType.SERVLET, sipreq, interceptedAt, exceptionInCaseOfException);
            }
        }
    }
View Full Code Here

            break;

        case TimerLong:

            SipServletRequest byeRequest = null;
            ReplicationUnitOfWork uow = new ReplicationUnitOfWork();
            try {
                synchronized (this) {
                    if (m_State == CONFIRMED_UAS) {
                        m_State = TIMEOUT_UAS;
                        if (m_TimerShort != null) {
                            m_TimerShort.cancel();
                            m_TimerShort = null;
                        }
                        if (m_Log.isLoggable(Level.FINE)) {
                            m_Log.log(Level.FINE,
                                    "Timer fired after 64*T1s - end dialog");
                        }
                        // Lock the DS for the entire duration.
                        SipSession session = m_RetransmitResponse.getSession();
                        DialogFragment dialog = ((SipSessionImplBase) session).getDF();
                        if (dialog != null) { // to be on the safe side
                            uow.lockDialog(dialog);
                        }
                        // issue 1085 :: create byeRequest before invoking the listeners.
                        // issue 1350 :: check that session is still valid. If app is undeployed it will not be
                        if(session.isValid()){
                          byeRequest = session.createRequest("BYE");
                        }
                        else {
                          if (m_Log.isLoggable(Level.FINE)) {
                                m_Log.log(Level.FINE,
                                        "Skipping to send BYE since SipSession is no longer valid");
                            }
                        }
                        // invoke the listeners first, then they will still be done if anything
                        // goes wrong later with the actual creating or sending of the bye
                        // XXX ? should we not check if the SAS is still valid at this point?
                        SipApplicationSessionImpl sas = m_RetransmitResponse.getSessionImpl().getApplicationSessionImpl();
                        if(sas!=null){
                          SipApplicationListeners sipAppListeners = sas.getSipApplicationListeners();
                          if (sipAppListeners != null) {
                              ArrayList<SipErrorListener> sipErrorList =
                                      sipAppListeners.getSipErrorListeners();
                              for (SipErrorListener listener : sipErrorList) {
                                  try {
                                      listener.noAckReceived(new SipErrorEvent(
                                              m_RetransmitResponse.getRequest(),
                                              m_RetransmitResponse));
                                  } catch (Throwable t) {
                                      m_Log.log(Level.WARNING, t.getMessage(), t);
                                  }
                              }
                          }
                      }
                    }
                }
                // send after synchronization...
                if (byeRequest != null) {
                    if (disableByeOnNoAckReceived) {
                        if (m_Log.isLoggable(Level.FINE)) {
                            m_Log.log(Level.FINE, "BYE is not automatically sent by the container for no ACK recieved.");
                        }
                    } else {
                        byeRequest.send();
                    }
                }
            } catch (IncompleteDialogException e) { // uow.lockdialog can cause this.
                if (m_Log.isLoggable(Level.FINE)) {
                    m_Log.log(Level.FINE, "The dialog was incomplete while handling TimerLong. Skipping send", e);
View Full Code Here

    public SipDigestParamGenerator() {
    }

    public DigestAlgorithmParameter[] generateParameters(
            AlgorithmParameterSpec param) throws InvalidAlgorithmParameterException {
        SipServletRequest request = null;

        if (param instanceof SipAlgorithmParamImpl) {
            request = ((SipAlgorithmParamImpl) param).getRequest();
        } else {
            throw new InvalidAlgorithmParameterException(param.getClass().toString());
        }
        boolean isProxy = ((SipAlgorithmParamImpl) param).isProxy();

       
        List<String> params = null;
        AuthHeaderProcessor ahp = new AuthHeaderProcessor();
        if (!isProxy) {           
            params = ahp.getHeaderValues(request, "Authorization");
        } else {          
            params = ahp.getHeaderValues(request, "Proxy-Authorization");
        }

        if (params == null) {
            return null;
        }

       
        method = request.getMethod();
        boolean matchedRealm = false;
       
        String configuredRealm = ((SipAlgorithmParamImpl) param).getRealm();
        Iterator<String> itr = params.iterator();
       
        HeaderParser dhp = new HeaderParser();
        while (itr.hasNext()) {
            String value = itr.next();  

            if (matchedRealm) {
                break;
            } else {
                userName = null;
                realmName = null;
                nOnce = null;
                nc = null;
                cnonce = null;
                qop = null;
                uri = null;
                response = null;
            }
            values = dhp.parse(value);

            realmName = values.getProperty("realm");
            if (realmName != null && realmName.equals(configuredRealm)) {
                matchedRealm = true;
            }
            userName = values.getProperty("username");
            nc = values.getProperty("nc");
            qop = values.getProperty("qop");
            uri = values.getProperty("uri");
            response = values.getProperty("response");
            nOnce = values.getProperty("nonce");
            cnonce = values.getProperty("cnonce");
           
        }


        ServletInputStream sis = null;

        if ("auth-int".equals(qop)) {
            try {
                sis = request.getInputStream();

                java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();

                while (true) {
                    byte[] data = new byte[1024];
View Full Code Here

        throws ServletParseException {
        if (getRemoteTarget() == null) {
            synchronized (this) {
                // double-checked locking pattern
                if (getRemoteTarget() == null) {
                    SipServletRequest req = resp.getRequest();
                    // save route set and remote target
                    // RFC 3261, 12.1.1
                    saveRouteSet(req);

                    saveContactRemoteTarget(resp);
View Full Code Here

                throw new IllegalArgumentException();
            }
        }

        // time to give birth to a new request...
        SipServletRequest copiedReq = null;

        // need special treatment for from and to headers
        // Set<String> from = headerMap != null ? headerMap.remove("From") : null;
        // Set<String> to = headerMap != null ? headerMap.remove("To") : null;
        SipFactoryFacade sfImpl = (SipFactoryFacade) _sf;
        SipApplicationSessionImpl sappSessImpl = (SipApplicationSessionImpl) origRequest.getApplicationSession();

        try {
            if ((from != null) && (to != null)) {
                copiedReq = sfImpl.createRequestImpl(sappSessImpl,
                        origRequest.getMethod(),
                        sfImpl.createAddress(from.iterator().next()),
                        sfImpl.createAddress(to.iterator().next()), false,
                        origRequestImpl);
            } else if (from != null) {
                copiedReq = sfImpl.createRequestImpl(sappSessImpl,
                        origRequest.getMethod(),
                        sfImpl.createAddress(from.iterator().next()),
                        origRequestImpl.getToImpl(), false, origRequestImpl);
            } else if (to != null) {
                copiedReq = sfImpl.createRequestImpl(sappSessImpl,
                        origRequest.getMethod(), origRequestImpl.getFromImpl(),
                        sfImpl.createAddress(to.iterator().next()), false,
                        origRequestImpl);
            } else {
                copiedReq = sfImpl.createRequestImpl(sappSessImpl,
                        origRequest.getMethod(), origRequestImpl.getFromImpl(),
                        origRequestImpl.getToImpl(), false, origRequestImpl);
            }
        } catch (ServletParseException e) {
            throw new IllegalArgumentException(e);
        }

        SipServletRequestImpl copiedReqImpl = (SipServletRequestImpl) copiedReq;

        // lets add non system headers
        if ((clonedHeaderMap != null) && !clonedHeaderMap.isEmpty()) {
            Iterator<String> names = clonedHeaderMap.keySet().iterator();
            Iterator<List<String>> values = clonedHeaderMap.values().iterator();

            while (names.hasNext()) {
                setHeader(names.next(), values.next(), copiedReqImpl);
            }
        }

        if (route != null) {
            MultiLineHeader rHdr = new MultiLineHeader(Header.ROUTE, true);
            for (String s: route) {
                rHdr.setValue(s, false);
            }
            copiedReqImpl.setHeader(rHdr);
        } else {
            Header rt = origRequestImpl.getRawHeader(Header.ROUTE);

            if (rt != null) {
                copiedReqImpl.setHeader((Header) rt.clone());
            }
        }

        if (contact != null) {
            if (origRequest.getMethod().equals("REGISTER")) {
                copiedReqImpl.setHeader("Contact", contact.iterator().next());
            } else { // change only parameters and user part of the URI

                try {
                    Address cnctAddr = new AddressImpl(contact.iterator().next());
                    Address contactAddr = copiedReqImpl.getAddressHeaderImpl(
                            "Contact");

                    if (contactAddr != null && !contactAddr.isWildcard()) {
                        ((AddressImpl) contactAddr).modifyContactParameters(cnctAddr);
                    }
                } catch (ServletParseException ex) {
                    if (_log.isLoggable(Level.FINE)) {
                        _log.log(Level.FINE,
                            " Exception while parsing Contact address ", ex);
                    }
                }
            }
        }


        if (linkedSessions) {
            SipSession session1 = origRequest.getSession();
            SipSession session2 = copiedReq.getSession();

            if ((session1 == null) || (session2 == null)) {
                throw new NullPointerException();
            }
View Full Code Here

            // ...lets link them later.
            shouldLinkSessions = true;
        }

        SipServletRequest newRequest = session2.createRequest(origRequest.getMethod());

        // set Routing directive to CONTINUE (will also copy the stateInfo)
        // only in case of initial requests (JSR289)
        if (origRequest.isInitial()) {
            // set implicit routing directive (will be overridden by app if it feels like it
View Full Code Here

TOP

Related Classes of javax.servlet.sip.SipServletRequest

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.