Package javax.servlet.sip

Examples of javax.servlet.sip.URI


        //Req uri of the request was sips or
        //Top most RR was sips and if none present the contact was sips
        //UAS behaviour
        DialogFragment df = resp.getDialog();

        URI nextTarget = null;

        if ((resp.getRequestImpl() != null) &&
                (resp.getRequestImpl().getRequestURI() != null) &&
                resp.getRequestImpl().getRequestURI().isSipURI()) {
            nextTarget = resp.getRequestImpl().getRequestURI();
        }

        if ((nextTarget != null) && (!((SipURI) nextTarget).isSecure())) {
            Header rr = resp.getRawHeader(Header.RECORD_ROUTE);

            try {
                if ((rr != null) && rr.getAddressValue().getURI().isSipURI()) {
                    nextTarget = rr.getAddressValue().getURI();
                } else { //Get the other

                    Header c = resp.getRequestImpl().getRawHeader(Header.CONTACT);

                    if ((c != null) && (c.getAddressValue() != null)) {
                        nextTarget = c.getAddressValue().getURI();
                    }
                }
            } catch (ServletParseException spe) {
                if (m_Log.isLoggable(Level.FINE)) {
                    m_Log.log(Level.FINE, "Failed eval 12.1.1 rules", spe);
                }
            }
        }

        SipURIImpl uri = null;

        if (nextTarget != null && nextTarget.isSipURI())
        {
            SipURI targetUri = (SipURI) nextTarget;
            boolean isTransportParamTls =
                    targetUri.getTransportParam() != null &&
                            targetUri.getTransportParam().equalsIgnoreCase("tls");
View Full Code Here


     */
    private SipURIImpl getSipOrSipsURI(SipServletRequestImpl req) {
        DialogFragment df = req.getDialog();

        //Do the rfc 3261 sips check 16.6 (4,6,7)
        URI nextTarget = null;
        Header r = req.getRawHeader(Header.ROUTE);

        if (r == null) { //No route headers, next hop ReqURI
            nextTarget = req.getRequestURI();
        } else {
            //TODO maybe not a SipURI!
            try {
                if (r.getAddressValue() != null) {
                    nextTarget = r.getAddressValue().getURI();
                }
            } catch (ServletParseException ignore) {
            }
        }

        SipURIImpl uri = null;

        if (nextTarget != null && nextTarget.isSipURI())
        {
            SipURI targetUri = (SipURI) nextTarget;
            boolean isTransportParamTls =
                    targetUri.getTransportParam() != null &&
                            targetUri.getTransportParam().equalsIgnoreCase("tls");
View Full Code Here

            SipServletRequestImpl req = null;
            String defaultHandler = null;

            if (origRequest == null) {
                URI requestURI = (URI) toCopy.getURI().clone();
                if ("REGISTER".equals(method) && requestURI.isSipURI()) {
                    ((SipURI)requestURI).setUser(null);
                }
                req = new SipServletRequestImpl(method, requestURI,
                        SipFactoryImpl.PROTOCOL_LINE);
               req.setInternalRoutingDirective(
                        SipApplicationRoutingDirective.NEW, null);
               req.setBeKey(appSession.getBeKey());
            } else {
                req = (SipServletRequestImpl) origRequest.clone();
                req.setInternalRoutingDirective(
                        SipApplicationRoutingDirective.CONTINUE, origRequest);
                // copy region in case of CONTINUE as well
                req.setRegion(origRequest.getRegion());
                req.clearApplicationDispatchers();
                // The clone will copy the session-case. For the new request
                // the session-case should be internal.
                req.setSessionCase(SessionCase.INTERNAL);
                req.removeSystemHeaders();
                req.removeRemoteSettings();
                defaultHandler = origRequest.getSessionImpl().getHandler();
            }

            // set CallID
            Header callIDHeader = new SingleLineHeader(Header.CALL_ID, true);

            if ((origRequest == null) || !sameCallID) {
                callIDHeader.setValue(createCallID(), false);
            } else {
                callIDHeader.setValue(origRequest.getCallId(), false);
            }

            req.setHeader(callIDHeader);

            URI fromURI = cleanupFromOrToURI(fromCopy.getURI().clone());
            fromCopy.setURI(fromURI);
            URI toURI = cleanupFromOrToURI(toCopy.getURI().clone());
            toCopy.setURI(toURI);

            // Put protection, lock again
            ((AddressImpl) fromCopy).setReadOnly(true);
            ((AddressImpl) toCopy).setReadOnly(true);
View Full Code Here

        //
        // TODO what about region?

        String subscriberURIStr = info.getSubscriberURI();

        URI subscriberURI = null;
        if (!("".equals(subscriberURIStr)) && subscriberURIStr != null) {
            try {
                subscriberURI = m_sipFactory.createURI(subscriberURIStr);
            } catch (ServletParseException e) {
                if (logger.isLoggable(Level.WARNING)) {
View Full Code Here

        // Found servlet(s) in an application which can handle the request
        // (mapping roles),
        // but if empty WE DO NOT need to do anything here. AD will invoke
        // this method with next the application.
        if (!servlets.isEmpty()) {
            URI subscriberURI = getSubscriberURI(info);
            request.setSubscriberURI(subscriberURI);

            as = TargettedRequestHandler.getApplicationSession(request, info);
            if (as == null) {
                as = m_sipFactory.createApplicationSession(request);
View Full Code Here

                return header;
            }

            // logic to match request.<headerName>.uri
            if (name.endsWith(".uri")) {
                URI normalizedUri = getCanonicalizedNormalizedUri(dcrUtils,
                        header);

                if (normalizedUri != null) {
                    return normalizedUri.toString();
                } else {
                    return null;
                }
            }

            // logic to match the request.<headerName>.uri.user
            if (name.endsWith(headerName + ".uri.user")) {
                String user = getUnresolvedUserPart(dcrUtils, header);

                if (user != null) {
                    return user;
                }

                Matcher matcher = genericUriPattern.matcher(header);

                if (matcher.find()) {
                    // Found matching user in regexp.
                    user = matcher.group(1);

                    if (user == null) {
                        user = matcher.group(2);
                    }

                    return user;
                } else {
                    return null;
                }
            }

            // logic to match the request.<headerName>.uri.host
            if (name.endsWith(headerName + ".uri.host")) {
                String host = getUnresolvedHostPart(dcrUtils, header);

                if (host != null) {
                    return host;
                }

                Matcher matcher = genericUriPattern.matcher(header);

                if (matcher.find()) {
                    // Found matching host in regexp.
                    host = matcher.group(3);

                    if (host == null) {
                        host = matcher.group(5);
                    }

                    return host;
                } else {
                    return null;
                }
            }

            // logic to match the request.<headerName>.uri.resolve
            if (name.endsWith(headerName + ".uri.resolve")) {
                SipURI resolvedUri = dcrUtils.transformURI(dcrUtils.canonicalize(
                            header));

                return (resolvedUri != null) ? resolvedUri.toString() : null;
            }

            // logic to match the request.<headerName>.uri.resolve.user
            if (name.endsWith(headerName + ".uri.resolve.user")) {
                URI canonicalizedUri = dcrUtils.canonicalize(header);
                SipURI resolvedUri = dcrUtils.transformURI(canonicalizedUri);
                String user;

                if (resolvedUri != null) {
                    user = dcrUtils.getUserOrPhoneNumber(resolvedUri);
View Full Code Here

        return null;
    }

    private URI getCanonicalizedNormalizedUri(DcrUtils dcrUtils, String header) {
        URI canonicalizedUri = dcrUtils.canonicalize(header);
        URI normalizedUri = dcrUtils.normalize(canonicalizedUri);

        return normalizedUri;
    }
View Full Code Here

        return normalizedUri;
    }

    private String getUnresolvedHostPart(DcrUtils dcrUtils, String header) {
        URI normalizedUri = getCanonicalizedNormalizedUri(dcrUtils, header);
        String host = ((normalizedUri != null) && normalizedUri.isSipURI())
            ? ((SipURI) normalizedUri).getHost() : null;

        return host;
    }
View Full Code Here

        return host;
    }

    private String getUnresolvedUserPart(DcrUtils dcrUtils,
        String parameterValue) {
        URI normalizedUri = getCanonicalizedNormalizedUri(dcrUtils,
                parameterValue);
        String user = dcrUtils.getUserOrPhoneNumber(normalizedUri);

        return user;
    }
View Full Code Here

        }

        DcrUtils dcrUtils = DcrUtils.getInstance();

        if (name.startsWith("request.uri")) {
            URI uri = dcrUtils.canonicalize(request.getRequestURI());

            if (name.startsWith("request.uri.resolve")) {
                if (UriUtil.isTelephoneNumber(uri)) {
                    URI resolvedUri = dcrUtils.transformURI(uri);

                    if (resolvedUri != null) {
                        uri = resolvedUri;
                    } else {
                        uri = dcrUtils.normalize(uri);
                    }
                }

                if (name.endsWith("uri.resolve")) {
                    return uri.toString();
                }

                if (name.endsWith("uri.resolve.user")) {
                    return dcrUtils.getUserOrPhoneNumber(uri);
                }

                if (name.endsWith("uri.resolve.host")) {
                    if (uri.isSipURI()) {
                        return ((SipURI) uri).getHost();
                    }
                }
            }

            // request.uri
            // request.uri.scheme
            // request.uri.user
            // request.uri.host
            // request.uri.port
            // request.method
            if (name.equals("request.uri")) {
                return uri.toString();
            }

            if (name.equals("request.uri.scheme")) {
                return uri.getScheme();
            }

            if (name.equals("request.uri.user")) {
                return dcrUtils.getUserOrPhoneNumber(dcrUtils.normalize(uri));
            }

            if (name.equals("request.uri.host")) {
                if (uri.isSipURI()) {
                    return ((SipURI) uri).getHost();
                } else {
                    Matcher matcher = genericUriPattern.matcher(uri.toString());

                    if (matcher.find()) {
                        // Found matching user in regexp.
                        String host = matcher.group(3);

                        if (host == null) {
                            host = matcher.group(5);
                        }

                        return host;
                    } else {
                        return null;
                    }
                }
            }

            if (name.equals("request.uri.port")) {
                if (uri.isSipURI()) {
                    return Integer.toString(((SipURI) uri).getPort());
                } else {
                    Matcher matcher = genericUriPattern.matcher(uri.toString());

                    if (matcher.find()) {
                        // Found matching user in regexp.
                        return matcher.group(4);
                    } else {
                        return null;
                    }
                }
            }
        }

        if (name.equals("request.method")) {
            return request.getMethod();
        }
        // General Headers
        //
        // request.<header>
        // request.<header>.uri
        // request.<header>.uri.scheme
        // request.<header>.uri.user
        // request.<header>.uri.host
        // request.<header>.uri.port
        // request.<header>.uri.display-name
        // request.<header>.uri.resolve
        // request.<header>.uri.resolve.user
        // request.<header>.uri.resolve.host
        else if (name.startsWith("request.")) {
            StringTokenizer token = new StringTokenizer(name, ".");
            int ntok = token.countTokens();
            String[] elements = new String[ntok];

            for (int i = 0; i < ntok; i++) {
                elements[i] = token.nextToken();
            }

            // request.<header>
            if (elements.length == 2) {
                return request.getHeader(elements[1]);
            }

            // Use getAddressHeaderImpl to retrieve the AddressImpl.
            // getAddressHeader returns a wrapper around the Address.
            SipServletRequestImpl requestImpl = (SipServletRequestImpl) request;

            // request.<header>.uri
            if ((elements.length > 2) && "uri".equals(elements[2])) {
                try {
                    URI canonicalizedHeaderUri = dcrUtils.canonicalize(requestImpl.getAddressHeaderImpl(
                                elements[1]).getURI());

                    // check if the mapping ends with uri
                    if ((elements.length < 4) && "uri".equals(elements[2])) {
                        return (canonicalizedHeaderUri != null)
                        ? dcrUtils.normalize(canonicalizedHeaderUri).toString()
                        : null;
                    }

                    // Handle request.<header>.uri.scheme
                    if ("scheme".equals(elements[3])) {
                        return canonicalizedHeaderUri.getScheme();
                    }

                    // request.<header>.uri.display-name
                    if ("display-name".equals(elements[3])) {
                        return requestImpl.getAddressHeaderImpl(elements[1])
                                          .getDisplayName();
                    }

                    // Handle request.<header>.uri.user
                    if ("user".equals(elements[3])) {
                        URI normalizedUri = dcrUtils.normalize(canonicalizedHeaderUri);
                        String user = dcrUtils.getUserOrPhoneNumber(normalizedUri);

                        if (user != null) {
                            return user;
                        } else {
                            Matcher matcher = genericUriPattern.matcher(normalizedUri.toString());

                            if (matcher.find()) {
                                // Found matching user in regexp.
                                user = matcher.group(1);

                                if (user == null) {
                                    user = matcher.group(2);
                                }

                                return user;
                            } else {
                                return null;
                            }
                        }
                    }

                    // Handle request.<header>.uri.host
                    if ("host".equals(elements[3])) {
                        if (canonicalizedHeaderUri.isSipURI()) {
                            return ((SipURI) canonicalizedHeaderUri).getHost();
                        } else {
                            Matcher matcher = genericUriPattern.matcher(canonicalizedHeaderUri.toString());

                            if (matcher.find()) {
                                // Found matching user in regexp.
                                String host = matcher.group(3);

                                if (host == null) {
                                    host = matcher.group(5);
                                }

                                return host;
                            } else {
                                return null;
                            }
                        }
                    }

                    // Handle request.<header>.uri.port
                    if ("port".equals(elements[3])) {
                        if (canonicalizedHeaderUri.isSipURI()) {
                            return ((SipURI) canonicalizedHeaderUri).getPort() +
                            "";
                        } else {
                            Matcher matcher = genericUriPattern.matcher(canonicalizedHeaderUri.toString());

                            if (matcher.find()) {
                                // Found matching user in regexp.
                                return matcher.group(4);
                            } else {
                                return null;
                            }
                        }
                    }

                    // Handle request.<header>.uri.resolve
                    if ("resolve".equals(elements[3])) {
                        URI transformedUri = dcrUtils.transformURI(canonicalizedHeaderUri);

                        if ((transformedUri == null) &&
                                UriUtil.isTelephoneNumber(
                                    canonicalizedHeaderUri)) {
                            transformedUri = dcrUtils.normalize(canonicalizedHeaderUri);
                        }

                        if (transformedUri != null) {
                            if (name.endsWith("uri.resolve")) {
                                return transformedUri.toString();
                            }

                            if (name.endsWith("uri.resolve.user")) {
                                return dcrUtils.getUserOrPhoneNumber(transformedUri);
                            }

                            if (name.endsWith("uri.resolve.host")) {
                                if (transformedUri.isSipURI()) {
                                    return ((SipURI) transformedUri).getHost();
                                }
                            }
                        } else {
                            return null;
View Full Code Here

TOP

Related Classes of javax.servlet.sip.URI

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.