Package com.ericsson.ssa.sip.dns

Examples of com.ericsson.ssa.sip.dns.TargetTuple


        @Override
        public void cancel(SelectionKey key) {
            super.cancel(key);

            TargetTuple tt = outboundConnectionsTuple.remove(key);

            if (tt != null) {
                connectionManager.remove(tt);
            }
        }
View Full Code Here


            }

            boolean invokeNextFilter = super.execute(ctx);

            if (!invokeNextFilter) {
                TargetTuple tt = (TargetTuple) ctx.getAttribute("tt");

                if (tt != null) {
                    connectionManager.remove(tt);
                }
            }
View Full Code Here

                }

                ctx.setAttribute(SIP_CERTS, x509Cert);
            }
            try {
                TargetTuple tt =
                        outboundConnectionsTuple.get(ctx.getSelectionKey());
                if (tt != null) {
                    TLSOutboundConnectorHandler oHandler =
                            (TLSOutboundConnectorHandler) connectionManager.get(tt);
                    if ((oHandler != null) && (oHandler.getSSLEngine() == null)) {
View Full Code Here

        }
        if (auth == null) {
            throw new SecurityException("P-Asserted Authenticator not configured");
        }

        TargetTuple remoteHost = ((SipServletRequestImpl) request).getInitialRemote();
        String host = "";
        if (remoteHost != null) {
            host = remoteHost.getIP();
        }
        Principal authPrincipal = auth.authenticate(request, host,
                identityAuthRealm, auth.INTERMEDIATE);
        if (authPrincipal != null) {
            ((SipServletRequestImpl) request).setUserPrincipal(authPrincipal);
View Full Code Here

            Socket s = socketChannel.socket();

            InetSocketAddress remoteAddress =
                    (InetSocketAddress) s.getRemoteSocketAddress();

            TargetTuple remote = new TargetTuple(SipTransports.TCP_PROT,
                    remoteAddress, s.getLocalAddress().getHostAddress());

            outboundConnector.setCallbackHandler(new SharedCallbackHandler(
                    outboundConnector, remote));
View Full Code Here

            Socket s = socketChannel.socket();

            InetSocketAddress remoteAddress =
                    (InetSocketAddress) s.getRemoteSocketAddress();

            TargetTuple remote = new TargetTuple(SipTransports.TLS_PROT,
                    remoteAddress, s.getLocalAddress().getHostAddress());

            outboundConnector.setCallbackHandler(new SSLSharedCallbackHandler(
                    outboundConnector, remote));        
View Full Code Here

        }
   

        private TargetTuple selectBindInterface(TargetTuple tt,
                SipServletMessageImpl sipServletMessage) {           
            TargetTuple bindTT = null;
            OutboundInterface oi = sipServletMessage.getOutboundInterface();
            if (oi != null){
                bindTT = oi.getTargetTuple();
            }
            if (bindTT != null) {
                /*
                 * Resolve the external address to the corresponding
                 * bind address, note that the external address could be a
                 * local address or a LB address according to the 289 Spec
                 */
                if (externalListeners != null && bindTT.getBindIP() != null &&
                        !bindTT.getBindIP().equals("")) {
                    for (TargetTuple listener : externalListeners.keySet()) {
                        if (externalListeners.get(listener).equals(bindTT) ||
                                listener.equals(bindTT)) {
                            return listener;
                        }
View Full Code Here

            SipServletRequestImpl req = resp.getRequestImpl();
            if (req == null || !isProxy(req)) {
                return;
            }
           
            TargetTuple tt = req.getInitialRemote();
            if (!tt.getProtocol().name().equals(SipTransports.UDP_PROT.name())) {               
                resolveTransport(resp, tt);
            } else {
                logger.log(Level.FINER, "UDP transport. RR will be resolved " +
                " from TargetResolver");
            }
View Full Code Here

                throws IOException {
            send(sipServletMessage, true, null);
        }
       
        private TargetTuple getBindTuple(SipServletMessageImpl sipServletMessage) {
            TargetTuple bindtuple = null;
            TargetTuple tt = sipServletMessage.getRemote();
            if (!tt.getIsCLBEndpoint()) {
                // rely on clb to set the bind ip address always
                bindtuple = selectBindInterface(tt, sipServletMessage);
                if (bindtuple != null) {
                    tt.setBindIp(bindtuple.getIP());
                    if (tt.getProtocol() == SipTransports.UDP_PROT) {
                        tt.setBindPort(bindtuple.getPort());
                    }
                } else {
                    if (logger.isLoggable(Level.FINEST))
                    logger.log(Level.FINEST, "Network Manager Routing without" +
                            "bind interface");
View Full Code Here

        }

        private void send(SipServletMessageImpl sipServletMessage,
                boolean useCache, ByteBuffer bb) throws IOException {

            TargetTuple tt = getBindTuple(sipServletMessage);
            //added this check to prevent FT failures
            if(staleConnectionsTimeout > 0 ) {
                if ((tt.getProtocol() == SipTransports.UDP_PROT)
                        && (staleUDPConnections.get(tt) != null)) {
                    Long time = staleUDPConnections.get(tt);
                    if ((System.currentTimeMillis() - time)
                            >= staleConnectionsTimeout) {
                        staleUDPConnections.remove(tt);
                    } else {
                        throw new ConnectException("Connection refused to: " +
                                tt.getSocketAddress());
                    }
                }
            }
            ConnectorHandler handler = null;
            if (useCache) {
                handler = streams.get(tt);
                if ((handler != null) &&
                        (handler.getUnderlyingChannel() == null ||
                        !handler.getUnderlyingChannel().isOpen() ||
                        handler.getSelectorHandler() == null ||
                        handler.getSelectorHandler().getAsyncQueueWriter() ==
                        null)) {
                    // none of these warning should ever happen
                    /*
                     * The following checks are to ensure that we do not
                     * use stale connections after a listener has been
                     * disabled and then enabled.
                     */
                    if (handler.getUnderlyingChannel() == null) {
                        if (logger.isLoggable(Level.FINEST)) {
                            logger.log(Level.FINEST,
                                    "discarding a connector with a null channel " +
                                    "for " + tt.toString());
                        }
                    }
                    if (handler.getSelectorHandler() == null) {
                        if (logger.isLoggable(Level.FINEST)) {
                            logger.log(Level.FINEST,
                                    "discarding a connector with a null " +
                                    "selector handler for " + tt.toString());
                        }
                    } else if (handler.getSelectorHandler().getAsyncQueueWriter() ==
                            null) {
                        if (logger.isLoggable(Level.FINEST)) {

                            logger.log(Level.FINEST,
                                    "discarding a connector with a null async " +
                                    "writer for " + tt.toString());
                        }
                    }

                    try {
                        handler.close();
                    } catch (Exception e) {
                        if (logger.isLoggable(Level.FINE)) {
                            logger.log(Level.FINE,
                                    "sip.network.grizzly.handler.close.error",
                                    new Object[]{handler});
                        }
                    }

                    connectionManager.remove(tt); //Cleanup a broken connection

                    handler = null;
                }
            }

            if (handler == null) {
                handler = createConnectorHandler(tt, sipServletMessage);
            }

            // The connection failed, returning null.
            if (handler == null && useCache) {
                if (sipServletMessage.getRetryPolicy() ==
                        SipServletMessageImpl.RetryPolicy.RESOLVE_AND_RETRY) {
                    if (sipServletMessage.getMessageType() ==
                            SipServletMessageImpl.SipMessageType.SipResponse) {
                        try {
                            resolve((SipServletResponseImpl) sipServletMessage);
                            //try again
                            tt = getBindTuple(sipServletMessage);
                            handler = createConnectorHandler(tt, sipServletMessage);
                        } catch (Exception e) {
                            logSendFailed((SipServletResponseImpl) sipServletMessage,
                                    e);
                        }
                    }
                } else {
                //then we have already tried with the first createConnectorHandler(...) invocation
                }
            }

            //after any potential retry
            if (handler == null) {
                throw new ConnectException("Connection refused to: " +
                        tt.getSocketAddress());
            }

            boolean cacheBuffer = false;
            if (bb == null) {
                sipServletMessage.toBufferInit();
View Full Code Here

TOP

Related Classes of com.ericsson.ssa.sip.dns.TargetTuple

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.