Package javax.servlet.sip

Examples of javax.servlet.sip.SipURI


            throw new ServletParseException(t);
        }
    }

    public SipURI createSipURI(String user, String host) {
        SipURI uri = new SipURIImpl();
        uri.setHost(host);
        uri.setUser(user);

        return uri;
    }
View Full Code Here


        fromOrTo.removeParameter("ttl");
        fromOrTo.removeParameter("transport");
        fromOrTo.removeParameter("lr");

        if (fromOrTo.isSipURI()) {
            SipURI sURI = (SipURI)fromOrTo;
            Iterator<String> headerNames = sURI.getHeaderNames();
            while (headerNames.hasNext()) {
                sURI.removeHeader(headerNames.next());
            }
        }
        return fromOrTo;
    }
View Full Code Here

                    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?");
                }  
                return;
            }

            RecordRoutePolicy policy = getPolicy(sp);

            switch (policy) {               
                case TCP:
                    uri.setTransportParam("tcp");
                    break;
                case UDP:
                    uri.setTransportParam("udp");
                    break;
                case REWRITE:
                    String transport = getTransport(tt);
                    if (transport != null) {
                        uri.setTransportParam(transport);
                    }
                    break;
            }
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE,
View Full Code Here

            ListIterator<Address> rrs =
            resp.getAddressHeaders(Header.RECORD_ROUTE);
            while (rrs.hasNext()) {
                AddressImpl a = (AddressImpl) rrs.next();
                if (a.isContainerAddress()) { // Should we also check fid
                    SipURI uri = (SipURI) a.getURI();                   
                    RecordRoutePolicy policy = getPolicy(sp);

                    switch (policy) {                       
                        case TCP:
                            uri.setTransportParam("tcp");
                            break;
                        case UDP:
                            uri.setTransportParam("udp");
                            break;
                        case REWRITE:
                            String transport = getTransport(tt);
                            if (transport != null) {                               
                                uri.setTransportParam(transport);                               
                            }
                            break;
                    }
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE,
View Full Code Here

                }
            }

            // 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);
                } else {
                    user = dcrUtils.getUserOrPhoneNumber(dcrUtils.normalize(
                                canonicalizedUri));
                }

                return user;
            }

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

                if (resolvedURI != null) {
                    return resolvedURI.getHost();
                } else {
                    return null;
                }
            }
        }

        if (name.startsWith("parameter.")) {
            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();
            }

            String parameterName = null;

            if (ntok > 0) {
                parameterName = elements[1];
            }

            String parameterValue = request.getParameters()
                                           .getParameter(parameterName);

            // logic to match the parameter.<parameterName>
            if (name.endsWith(elements[1])) {
                return parameterValue;
            }

            // logic to match the parameter.<parameterName>.uri
            if (name.endsWith(".uri")) {
                return dcrUtils.canonicalize(parameterValue).toString();
            }

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

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

                Matcher matcher = genericUriPattern.matcher(parameterValue);

                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 parameter.<parameterName>.uri.host
            if (name.endsWith(parameterName + ".uri.host")) {
                String host = getUnresolvedHostPart(dcrUtils, parameterValue);

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

                Matcher matcher = genericUriPattern.matcher(parameterValue);

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

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

                    return host;
                } else {
                    return null;
                }
            }

            // logic to match the parameter.<parameterName>.uri.resolve
            if (name.endsWith(parameterName + ".uri.resolve")) {
                SipURI transformedUri = dcrUtils.transformURI(dcrUtils.canonicalize(
                            parameterValue));

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

            // logic to match the parameter.<parameterName>.uri.resolve.user
            // HH19522: we need to deal with multiple URIs and take the
            // leftmost SIP URI if present, or the leftmost TEL URI otherwise
            // Note that the format is proprietary param=uri_1,uri_2,..,uri_n
            if (name.endsWith(parameterName + ".uri.resolve.user")) {
                return dcrUtils.canonicalizeAndTransformMultiURIgetUser(parameterValue);
            }

            // logic to match the parameter.<parameterName>.resolve.host
            if (name.endsWith(parameterName + ".uri.resolve.host")) {
                SipURI resolvedURI = dcrUtils.transformURI(dcrUtils.canonicalize(
                            parameterValue));

                if (resolvedURI != null) {
                    return resolvedURI.getHost();
                } else {
                    return null;
                }
            }
        }
View Full Code Here

                    }

                    if (returnCondition.equals("match.resolve.user")) {
                        DcrUtils dcrUtils = DcrUtils.getInstance();
                        URI canonicalizedUri = dcrUtils.canonicalize(m.group(1));
                        SipURI resolvedUri = dcrUtils.transformURI(canonicalizedUri);
                        if (resolvedUri != null) {
                            return dcrUtils.getUserOrPhoneNumber(resolvedUri);
                        } else {
                            return dcrUtils.getUserOrPhoneNumber(dcrUtils.normalize(canonicalizedUri));
                        }
View Full Code Here

     *
     * @param uri the URI to resolve
     * @return SipURI or null
     */
    public SipURI transformURI(URI uri) {
        SipURI sipUri = null;

        if (logger.isLoggable(Level.FINER)) {
            logger.log(Level.FINER, "transformURI uri: " + uri);
        }

View Full Code Here

     * The URI will be canonicalized.
     *
     * @return
     */
    public String canonicalizeAndTransformMultiURIgetUser(String uris) {
        SipURI su = getUsableSipUri(new AddressTokenizer(uris), true, uris);

        if (su == null) {
            return getBestTelUriPhoneNumber(new AddressTokenizer(uris));
        } else {
            return su.getUser();
        }
    }
View Full Code Here

            }

            if ((u0 == null) || (u0.isSipURI() && !considerSipUris) || (!u0.isSipURI() && considerSipUris)) {
                return getUsableSipUri(t, considerSipUris, uris);
            } else {
                SipURI su0 = transformURI(u0);

                if ((su0 == null) || (su0.getUser() == null) || su0.getUser().equals("")) {
                    return getUsableSipUri(t, considerSipUris, uris);
                } else {
                    return su0;
                }
            }
View Full Code Here

                telUrl.removeParameter(TelURLImpl.PHONE_CONTEXT);
            }
        }

        if (uri.isSipURI()) {
            SipURI sipUri = (SipURI) uri.clone();
            sipUri.setUser(UriUtil.getAsSipUriUser(telUrl));

            return sipUri;
        } else {
            return telUrl;
        }
View Full Code Here

TOP

Related Classes of javax.servlet.sip.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.