Register a listener that waits until the ssl context factory has started. Once it has
started we can grab the fully initialized context so we can log the parameters.
549355
protected AbstractLifeCycle.AbstractLifeCycleListener logSslInfoOnStart(final SslContextFactory sslContextFactory) {
        return new AbstractLifeCycle.AbstractLifeCycleListener() {
            @Override
            public void lifeCycleStarted(LifeCycle event) {
                logSupportedParameters(sslContextFactory);
            }
        };
    }
822392
def start_listener(self):
        ''''''
        if self.sock is not None:
            self.sock.close()
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.sock.bind(('', self.asterix_settings.port))
        self.sock.setblocking(False)
        print("Started on port %u" % self.asterix_settings.port)
667904
@Activate
    protected void activate(ComponentContext context, Map<String, Object> config) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Activating ", config);
        }

        // handle config (such as TCP factory info) before registering
        // factories, as the register will trigger an automatic load of any
        // delayed configuration, and we need the config before that happens
        modified(config);

        this.chfw.registerFactory("TCPChannel", TCPChannelFactory.class);
        this.chfw.registerFactory("UDPChannel", UDPChannelFactory.class);

        instance.get().set(this); // required components have been activated
    }
108004
@Override
    public synchronized void start(final StartContext context) throws StartException {
        final ModelController modelController = modelControllerSupplier.get();
        final ControlledProcessStateService controlledProcessStateService = controlledProcessStateServiceSupplier.get();
        socketBindingManager = socketBindingManagerSupplier != null ? socketBindingManagerSupplier.get() : null;

        final SecurityRealm securityRealm = securityRealmSupplier != null ? securityRealmSupplier.get() : null;
        final HttpAuthenticationFactory httpAuthenticationFactory = httpAuthFactorySupplier != null ? httpAuthFactorySupplier.get() : null;
        SSLContext sslContext = sslContextSupplier != null ? sslContextSupplier.get() : null;
        final SslClientAuthMode sslClientAuthMode;
        if (sslContext == null && securityRealm != null) {
            sslContext = securityRealm.getSSLContext();
            sslClientAuthMode = getSslClientAuthMode(securityRealm);
        } else {
            sslClientAuthMode = null;
        }

        InetSocketAddress bindAddress = null;
        InetSocketAddress secureBindAddress = null;

        final SocketBinding basicBinding = socketBindingSupplier != null ? socketBindingSupplier.get() : null;
        final SocketBinding secureBinding = secureSocketBindingSupplier != null ? secureSocketBindingSupplier.get() : null;
        final NetworkInterfaceBinding interfaceBinding = interfaceBindingSupplier != null ? interfaceBindingSupplier.get() : null;
        final NetworkInterfaceBinding secureInterfaceBinding = secureInterfaceBindingSupplier != null ? secureInterfaceBindingSupplier.get() : null;
        if (interfaceBinding != null) {
            useUnmanagedBindings = true;
            assert this.port != null;
            final int port = this.port;
            if (port > 0) {
                bindAddress = new InetSocketAddress(interfaceBinding.getAddress(), port);
            }
            assert this.securePort != null;
            final int securePort = this.securePort;
            if (securePort > 0) {
                InetAddress secureAddress = secureInterfaceBinding == null ? interfaceBinding.getAddress() : secureInterfaceBinding.getAddress();
                secureBindAddress = new InetSocketAddress(secureAddress, securePort);
            }
        } else {
            if (basicBinding != null) {
                bindAddress = basicBinding.getSocketAddress();
            }
            if (secureBinding != null) {
                secureBindAddress = secureBinding.getSocketAddress();
            }
        }
        List<ListenerRegistry.Listener> listeners = new ArrayList<>();
        //TODO: rethink this whole ListenerRegistry business
        if(bindAddress != null) {
            ListenerRegistry.Listener http = new ListenerRegistry.Listener("http", HTTP_MANAGEMENT, SERVER_NAME, bindAddress);
            http.setContextInformation("socket-binding", basicBinding);
            listeners.add(http);
        }
        if(secureBindAddress != null) {
            ListenerRegistry.Listener https = new ListenerRegistry.Listener("https", HTTPS_MANAGEMENT, SERVER_NAME, bindAddress);
            https.setContextInformation("socket-binding", secureBinding);
            listeners.add(https);
        }

        final ChannelUpgradeHandler upgradeHandler = new ChannelUpgradeHandler();
        final ServiceBuilder<?> builder = context.getChildTarget().addService(HTTP_UPGRADE_SERVICE_NAME);
        final Consumer<Object> upgradeHandlerConsumer = builder.provides(HTTP_UPGRADE_SERVICE_NAME, HTTPS_UPGRADE_SERVICE_NAME);
        builder.setInstance(org.jboss.msc.Service.newInstance(upgradeHandlerConsumer, upgradeHandler));
        builder.install();
        for (ListenerRegistry.Listener listener : listeners) {
            listener.addHttpUpgradeMetadata(new ListenerRegistry.HttpUpgradeMetadata(JBOSS_REMOTING, MANAGEMENT_ENDPOINT));
        }

        if (listenerRegistrySupplier.get() != null) {
            for(ListenerRegistry.Listener listener : listeners) {
                listenerRegistrySupplier.get().addListener(listener);
            }
        }

        try {
            serverManagement = ManagementHttpServer.builder()
                    .setBindAddress(bindAddress)
                    .setSecureBindAddress(secureBindAddress)
                    .setModelController(modelController)
                    .setSecurityRealm(securityRealm)
                    .setSSLContext(sslContext)
                    .setSSLClientAuthMode(sslClientAuthMode)
                    .setHttpAuthenticationFactory(httpAuthenticationFactory)
                    .setControlledProcessStateService(controlledProcessStateService)
                    .setConsoleMode(consoleMode)
                    .setConsoleSlot(consoleSlot)
                    .setChannelUpgradeHandler(upgradeHandler)
                    .setManagementHttpRequestProcessor(requestProcessorSupplier.get())
                    .setAllowedOrigins(allowedOrigins)
                    .setWorker(workerSupplier.get())
                    .setExecutor(executorSupplier.get())
                    .build();

            serverManagement.start();

            // Register the now-created sockets with the SBM
            if (socketBindingManager != null) {
                if (useUnmanagedBindings) {
                    SocketBindingManager.UnnamedBindingRegistry registry = socketBindingManager.getUnnamedRegistry();
                    if (bindAddress != null) {
                        final InetSocketAddress boundAddress = serverManagement.getLocalAddress(InetSocketAddress.class);
                        basicManagedBinding = ManagedBinding.Factory.createSimpleManagedBinding("management-http", boundAddress, null);
                        registry.registerBinding(basicManagedBinding);
                    }
                    if (secureBindAddress != null) {
                        final InetSocketAddress boundAddress = serverManagement.getSecureLocalAddress(InetSocketAddress.class);
                        secureManagedBinding = ManagedBinding.Factory.createSimpleManagedBinding("management-https", boundAddress, null);
                        registry.registerBinding(secureManagedBinding);
                    }
                } else {
                    SocketBindingManager.NamedManagedBindingRegistry registry = socketBindingManager.getNamedRegistry();
                    if (basicBinding != null) {
                        final InetSocketAddress boundAddress = serverManagement.getLocalAddress(InetSocketAddress.class);
                        basicManagedBinding = ManagedBinding.Factory.createSimpleManagedBinding(basicBinding.getName(), boundAddress, null);
                        registry.registerBinding(basicManagedBinding);
                    }
                    if (secureBinding != null) {
                        final InetSocketAddress boundAddress = serverManagement.getSecureLocalAddress(InetSocketAddress.class);
                        secureManagedBinding = ManagedBinding.Factory.createSimpleManagedBinding(secureBinding.getName(), boundAddress, null);
                        registry.registerBinding(secureManagedBinding);
                    }
                }
            }
        } catch (Exception e) {
            Throwable cause = e.getCause();
            if (e instanceof BindException || cause instanceof BindException) {
                final StringBuilder sb = new StringBuilder().append(e.getLocalizedMessage());
                if (bindAddress != null)
                    sb.append(" ").append(bindAddress);
                if (secureBindAddress != null)
                    sb.append(" ").append(secureBindAddress);
                throw new StartException(sb.toString());
            } else {
                throw ServerLogger.ROOT_LOGGER.failedToStartHttpManagementService(e);
            }
        }
        httpManagementConsumer.accept(httpManagement);
    }
347294
@Override
    public boolean notifySipContextListeners(SipContextEvent event) {
        boolean ok = true;
        if (logger.isDebugEnabled()) {
            logger.debug(this.deploymentInfoFacade.getSipServlets().size() + " container to notify of " + event.getEventType());
        }
        if (event.getEventType() == SipContextEventType.SERVLET_INITIALIZED) {
            //fixes https://github.com/RestComm/sip-servlets/issues/165
            //now the SipService is totally ready/started, we prepare 
            //the context again just in case some att was not properly
            //initiated
            try {
                prepareServletContext();
            } catch (Exception e) {
                logger.warn("Couldnt prepare context", e);
            }              
            if (!timerService.isStarted()) {
                timerService.start();
            }
            if (!proxyTimerService.isStarted()) {
                proxyTimerService.start();
            }
            if (!sasTimerService.isStarted()) {
                sasTimerService.start();
            }
        }

        // if(this.available) {
        enterSipApp(null, null, false, true);
        boolean batchStarted = enterSipAppHa(true);
        try {

            for (String servletName : this.deploymentInfoFacade.getSipServlets().keySet()) {
                SipServletImpl managedServlet = (SipServletImpl) this.getChildrenMap().get(servletName);
                if (logger.isDebugEnabled()) {
                    logger.debug("managedServlet " + managedServlet.getServletInfo().getName() + ", class : "
                            + managedServlet.getClass().getName());
                }
                try {
                    final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();

                    try {
                        final ClassLoader cl = this.getSipContextClassLoader();
                        Thread.currentThread().setContextClassLoader(cl);
                        // http://code.google.com/p/sipservlets/issues/detail?id=135
                        // kakonyii: in SipStandardContext, there was a threadBindingListener which handled thread context switches (to get proper jndi context namespace selector, etc),
                        // in wildfly we use threadSetupAction from the deployment object for that purpose:
                        bindThreadBindingListener();

                        Servlet sipServlet = managedServlet.getServlet().getInstance();
                        if (sipServlet instanceof SipServlet) {
                            // Fix for issue 1086 (http://code.google.com/p/mobicents/issues/detail?id=1086) :
                            // Cannot send a request in SipServletListener.initialize() for servlet-selection applications
                            boolean servletHandlerWasNull = false;
                            if (this.getServletHandler() == null) {
                                this.setServletHandler(managedServlet.getServletInfo().getName());
                                servletHandlerWasNull = true;
                            }

                            switch (event.getEventType()) {
                                case SERVLET_INITIALIZED: {
                                    SipServletContextEvent sipServletContextEvent = new SipServletContextEvent(
                                            getServletContext(), (SipServlet) sipServlet);
                                    List<SipServletListener> sipServletListeners = sipListeners.getSipServletsListeners();
                                    if (logger.isDebugEnabled()) {
                                        logger.debug(sipServletListeners.size()
                                                + " SipServletListener to notify of servlet initialization");
                                    }
                                    for (SipServletListener sipServletListener : sipServletListeners) {
                                        sipServletListener.servletInitialized(sipServletContextEvent);
                                    }
                                    break;
                                }
                                case SIP_CONNECTOR_ADDED: {
                                    // reload the outbound interfaces if they have changed
                                    this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.OUTBOUND_INTERFACES,
                                            sipApplicationDispatcher.getOutboundInterfaces());
                                    // https://code.google.com/p/sipservlets/issues/detail?id=246
                                    this.getServletContext().setAttribute("org.mobicents.servlet.sip.SIP_CONNECTORS",
                                            sipApplicationDispatcher.getSipService().findSipConnectors());

                                    List<SipConnectorListener> sipConnectorListeners = sipListeners.getSipConnectorListeners();
                                    if (logger.isDebugEnabled()) {
                                        logger.debug(sipConnectorListeners.size()
                                                + " SipConnectorListener to notify of sip connector addition");
                                    }
                                    for (SipConnectorListener sipConnectorListener : sipConnectorListeners) {
                                        sipConnectorListener.sipConnectorAdded((SipConnector) event.getEventObject());
                                    }
                                    break;
                                }
                                case SIP_CONNECTOR_REMOVED: {
                                    // reload the outbound interfaces if they have changed
                                    this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.OUTBOUND_INTERFACES,
                                            sipApplicationDispatcher.getOutboundInterfaces());
                                    // https://code.google.com/p/sipservlets/issues/detail?id=246
                                    this.getServletContext().setAttribute("org.mobicents.servlet.sip.SIP_CONNECTORS",
                                            sipApplicationDispatcher.getSipService().findSipConnectors());

                                    List<SipConnectorListener> sipConnectorListeners = sipListeners.getSipConnectorListeners();
                                    if (logger.isDebugEnabled()) {
                                        logger.debug(sipConnectorListeners.size()
                                                + " SipConnectorListener to notify of sip connector removal");
                                    }
                                    for (SipConnectorListener sipConnectorListener : sipConnectorListeners) {
                                        sipConnectorListener.sipConnectorRemoved((SipConnector) event.getEventObject());
                                    }
                                    break;
                                }
                            }
                            if (servletHandlerWasNull) {
                                this.setServletHandler("");
                            }
                        }
                    } finally {
                        // http://code.google.com/p/sipservlets/issues/detail?id=135
                        // kakonyii: in SipStandardContext, there was a threadBindingListener which handled thread context switches (to get proper jndi context namespace selector, etc),
                        // in wildfly we use threadSetupAction from the deployment object for that purpose:
                        unbindThreadBindingListener();
                        Thread.currentThread().setContextClassLoader(oldClassLoader);
                    }
                } catch (ServletException e) {
                    logger.error("Cannot allocate the servlet " + managedServlet.getClass() + " for notifying the listener "
                            + " of the event " + event.getEventType(), e);
                    ok = false;
                } catch (Throwable e) {
                    logger.error("An error occured when notifying the servlet " + managedServlet.getClass() + " of the event "
                            + event.getEventType(), e);
                    ok = false;
                }

                // FIXME: kakonyii: do we need this deallocation in wildfly?
                // try {
                // if(sipServlet != null) {
                // wrapper.deallocate(sipServlet);
                // }
                // } catch (ServletException e) {
                // logger.error("Deallocate exception for servlet" + wrapper.getName(), e);
                // ok = false;
                // } catch (Throwable e) {
                // logger.error("Deallocate exception for servlet" + wrapper.getName(), e);
                // ok = false;
                // }
            }
        } finally {
            exitSipAppHa(null, null, batchStarted);
            exitSipApp(null, null);
        }
        // }
        return ok;
    }
188570
public static void registerListener(Context context, PlaybackListener listener) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(PlaybackListener.ACTION_ON_TRACK_PLAYED);
        filter.addAction(PlaybackListener.ACTION_ON_PLAYER_PAUSED);
        filter.addAction(PlaybackListener.ACTION_ON_SEEK_COMPLETE);
        filter.addAction(PlaybackListener.ACTION_ON_PLAYER_DESTROYED);
        filter.addAction(PlaybackListener.ACTION_ON_BUFFERING_STARTED);
        filter.addAction(PlaybackListener.ACTION_ON_BUFFERING_ENDED);
        filter.addAction(PlaybackListener.ACTION_ON_PROGRESS_CHANGED);

        LocalBroadcastManager.getInstance(context.getApplicationContext())
                .registerReceiver(listener, filter);
    }
1319095
public void init(HttpInboundServiceContext context) {
        this.isc = context;
        this.message = context.getResponse();
        this.body = null;
    }
221495
private void registerLockScreenReceiver(Context context) {
        mLockScreenReceiver = new LockScreenReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(ACTION_TOGGLE_PLAYBACK);
        intentFilter.addAction(ACTION_NEXT_TRACK);
        intentFilter.addAction(ACTION_PREVIOUS_TRACK);
        mLocalBroadcastManager = LocalBroadcastManager.getInstance(context);
        mLocalBroadcastManager.registerReceiver(mLockScreenReceiver, intentFilter);
    }
8410
public void init() throws SSLException {
        if (sslEngine != null) {
            // We already have a SSL engine created, no need to create a new one
            return;
        }

        InetSocketAddress peer = (InetSocketAddress) session
                .getAttribute(SslFilter.PEER_ADDRESS);
        
        // Create the SSL engine here
        if (peer == null) {
            sslEngine = sslContext.createSSLEngine();
        } else {
            sslEngine = sslContext.createSSLEngine(peer.getHostName(), peer.getPort());
        }
        
        // Initialize the engine in client mode if necessary
        sslEngine.setUseClientMode(parent.isUseClientMode());

        // Initialize the different SslEngine modes
        if (parent.isWantClientAuth()) {
            sslEngine.setWantClientAuth(true);
        }

        if (parent.isNeedClientAuth()) {
            sslEngine.setNeedClientAuth(true);
        }

        if (parent.getEnabledCipherSuites() != null) {
            sslEngine.setEnabledCipherSuites(parent.getEnabledCipherSuites());
        }

        if (parent.getEnabledProtocols() != null) {
            sslEngine.setEnabledProtocols(parent.getEnabledProtocols());
        }

        // TODO : we may not need to call this method...
        sslEngine.beginHandshake();
        
        
        handshakeStatus = sslEngine.getHandshakeStatus();

        handshakeComplete = false;
        initialHandshakeComplete = false;
        writingEncryptedData = false;
    }
512598
protected synchronized void activate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Activating");
        }
        bContext = context.getBundleContext();
        instance.set(this);

        sslConfigs.activate(context);
        cfwBundle.getFramework().registerFactories(this);
    }
240297
public void onStartWithServer(ExecutionContext<I> context, ExecutionInfo info) {
        for (ExecutionListener<I, O> listener: listeners) {
            try {
                if (!isListenerDisabled(listener)) {
                    listener.onStartWithServer(context.getChildContext(listener), info);
                }
            } catch (Throwable e) {
                if (e instanceof AbortExecutionException) {
                    throw (AbortExecutionException) e;
                }
                logger.error("Error invoking listener " + listener, e);
            }
        }
    }
515331
public static void initialise(AcceptListenerFactory _acceptListenerFactory) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "initalise");

        acceptListenerFactory = _acceptListenerFactory;

        // Create the maintainer of the configuration.
        Framework framework = Framework.getInstance();
        if (framework == null) {
            state = State.INITIALISATION_FAILED;
        } else {
            state = State.INITIALISED;

            // Extract the chain reference.
            connectionTracker = new OutboundConnectionTracker(framework);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "initalise");
    }
414658
private void trackListeners(final BundleContext bundleContext) {
		final ServiceTracker<EventListener, ListenerWebElement> listenerTracker = ListenerTracker
				.createTracker(extenderContext, bundleContext);

		listenerTracker.open();
		trackers.add(0, listenerTracker);

		// FIXME needed?
		final ServiceTracker<ListenerMapping, ListenerMappingWebElement> listenerMappingTracker = ListenerMappingTracker
				.createTracker(extenderContext, bundleContext);

		listenerMappingTracker.open();
		trackers.add(0, listenerMappingTracker);
	}
342458
protected SQLListenerContextImpl startContext(Connection connection, QueryMetadata metadata, RelationalPath<?> entity) {
        SQLListenerContextImpl context = new SQLListenerContextImpl(metadata, connection, entity);
        listeners.start(context);
        return context;
    }
957749
public void startAuthorizationProcess(final Context context, ResponseListener listener) {
        authorizationQueue.add(listener);

        //start the authorization process only if this is the first time we ask for authorization
        if (authorizationQueue.size() == 1) {
            try {
                if (preferences.clientId.get() == null) {
                    logger.info("starting registration process");
                    invokeInstanceRegistrationRequest(context);
                } else {
                    logger.info("starting authorization process");
                    invokeAuthorizationRequest(context);
                }
            } catch (Throwable t) {
                handleAuthorizationFailure(t);
            }
        }

        else{
            logger.info("authorization process already running, adding response listener to the queue");
            logger.debug(String.format("authorization process currently handling %d requests", authorizationQueue.size()));
        }
    }
1176963
@PostConstruct
    public void onInit() {
    	isExecutorAvailable = isExecutorOnClasspath();
		if (identityProvider.isUnsatisfied()) {
			setIdentityProvider(new EJBContextIdentityProvider(context));
		} else {
			setIdentityProvider(identityProvider.get());
		}
		setManagerFactory(new RuntimeManagerFactoryImpl());
		super.onInit();
	}
3657
private void init(SSLContextImpl ctx) {
        if (debug != null && Debug.isOn("ssl")) {
            System.out.println("Using SSLEngineImpl.");
        }

        sslContext = ctx;
        sess = SSLSessionImpl.nullSession;
        handshakeSession = null;

        /*
         * State is cs_START until we initialize the handshaker.
         *
         * Apps using SSLEngine are probably going to be server.
         * Somewhat arbitrary choice.
         */
        roleIsServer = true;
        connectionState = cs_START;
        receivedCCS = false;

        /*
         * default read and write side cipher and MAC support
         *
         * Note:  compression support would go here too
         */
        readCipher = CipherBox.NULL;
        readMAC = MAC.NULL;
        writeCipher = CipherBox.NULL;
        writeMAC = MAC.NULL;

        // default security parameters for secure renegotiation
        secureRenegotiation = false;
        clientVerifyData = new byte[0];
        serverVerifyData = new byte[0];

        enabledCipherSuites =
                sslContext.getDefaultCipherSuiteList(roleIsServer);
        enabledProtocols =
                sslContext.getDefaultProtocolList(roleIsServer);

        wrapLock = new Object();
        unwrapLock = new Object();
        writeLock = new Object();

        /*
         * Save the Access Control Context.  This will be used later
         * for a couple of things, including providing a context to
         * run tasks in, and for determining which credentials
         * to use for Subject based (JAAS) decisions
         */
        acc = AccessController.getContext();

        /*
         * All outbound application data goes through this OutputRecord,
         * other data goes through their respective records created
         * elsewhere.  All inbound data goes through this one
         * input record.
         */
        outputRecord =
            new EngineOutputRecord(Record.ct_application_data, this);
        inputRecord = new EngineInputRecord(this);
        inputRecord.enableFormatChecks();

        writer = new EngineWriter();
    }