Package com.ericsson.ssa.sip

Examples of com.ericsson.ssa.sip.AddressImpl


            Header contactHeader = request.getRawHeader(Header.CONTACT);
            if (contactHeader != null) {
                // There is a contact, we need to add the BE-KEY to it
                try {
                    AddressImpl addressValue = (AddressImpl) contactHeader.getAddressValue();
                    if (addressValue != null) {
                        // Fetch current read-only status
                        boolean readOnly = addressValue.isReadOnly();
                        // Allow writes on Address object
                        addressValue.setReadOnly(false);
                        URIImpl uriImpl = (URIImpl) addressValue.getURI();
                        if(uriImpl != null){
                            uriImpl.encodeBeKey(hashkey);
                        }
                        // Reset read-only status
                        addressValue.setReadOnly(readOnly);
                    }
                } catch (ServletParseException e) {
                    throw new SipRoutingException("Malformed Contact", e);
                }
            }

            replaceTopVia(request, via);

            if (logger.isLoggable(Level.FINER)) {
                logger.log(Level.FINER,
                        "The request originates from this instance, altered request: " + request);
            }

            return null;
        } else if (request.isRecordRouteIndicated()) {
            // This request was proxied, save ID of incoming connection.
            String encodedConnection;
            if ((encodedConnection=getEncondedConnection(request)) == null) {
                throw new SipRoutingException("Could not find connection information in a proxied request, shall never happen!");
            } else {
                via.setParameter(CLBConstants.CONNID_PARAM, encodedConnection);
            }


            Header rrHeader = request.getRawHeader(Header.RECORD_ROUTE);
            AddressImpl rrAddr;
            try {
                rrAddr = (AddressImpl) rrHeader.getAddressValue();
            } catch (ServletParseException e) {
                throw new SipRoutingException("Malformed record-Route", e);
            }

            // The R-R was added by the application, thus we shall set 'bekey'
            // Fetch current read-only status
            boolean readOnly = rrAddr.isReadOnly();
            // Allow writes on Address object
            rrAddr.setReadOnly(false);
            URIImpl uriImpl = (URIImpl) rrAddr.getURI();
            if (uriImpl != null) {
                uriImpl.encodeBeKey(hashkey);
            }
            // Reset read-only status
            rrAddr.setReadOnly(readOnly);

            replaceTopVia(request, via);

            if (logger.isLoggable(Level.FINER)) {
                logger.log(Level.FINER,
View Full Code Here


            if (response.isContactIndicated()) {
                // This is a UAS.
                Header contactHeader = response.getRawHeader(Header.CONTACT);

                if (contactHeader != null) {
                    AddressImpl contactAddress;

                    try {
                        contactAddress = (AddressImpl) (contactHeader.getAddressValue());
                    } catch (ServletParseException e) {
                        throw new SipRoutingException("Malformed Contact", e);
                    }

                    URIImpl contactUri = ((URIImpl) contactAddress.getURI());

                    contactAddress = ((AddressImpl) contactAddress.clone(true, true));
                    contactUri = (URIImpl) contactUri.clone();
                    contactUri.encodeBeKey(hashkey);
                    // Allow writes on cloned Address object
                    contactAddress.setReadOnly(false);
                    contactAddress.setURI(contactUri);
                    contactHeader.setReadOnly(false);
                    contactHeader.removeValues();
                    contactHeader.setValue(contactAddress.toString(), true);
                    contactHeader.setReadOnly(true);
                }
            } else if (response.getMethod().equalsIgnoreCase("INVITE") && response.getStatus() >= 300){
                // This is a non-2xx response to an INVITE, set bekey in the To-header
                Header toHeader = response.getRawHeader(Header.TO);

                if (toHeader != null) {
                    AddressImpl toAddress;

                    try {
                        toAddress = (AddressImpl) (toHeader.getAddressValue());
                    } catch (ServletParseException e) {
                        throw new SipRoutingException("Malformed To-header", e);
                    }

                    URIImpl toUri = ((URIImpl) toAddress.getURI());

                    toAddress = ((AddressImpl) toAddress.clone(true, true));
                    toUri = (URIImpl) toUri.clone();
                    toUri.encodeBeKey(hashkey);
                    // Allow writes on cloned Address object
                    toAddress.setReadOnly(false);
                    toAddress.setURI(toUri);
                    toHeader.setReadOnly(false);
                    toHeader.removeValues();
                    toHeader.setValue(toAddress.toString(), true);
                    toHeader.setReadOnly(true);
                }
            }
        }
View Full Code Here

        }
    }
   
    private boolean isInternal(String aRoute) throws ServletParseException {
        // precondition: aRoute != null
         AddressImpl adr = (AddressImpl)SipFactoryImpl.getInstance().createAddress(aRoute);
        return adr.isLocal();
    }
View Full Code Here

        throws Exception {
        URI uri = null;
        String uriStr = null;

        if ((uriStr = req.getHeader(Header.ROUTE)) != null) {
            AddressImpl address = new AddressImpl(uriStr);
            uri = address.getURI();
        } else {
            uri = req.getRequestURI();
        }

        if (myDnsResolver.isTelephoneNumber(uri)) {
View Full Code Here

TOP

Related Classes of com.ericsson.ssa.sip.AddressImpl

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.