Search in sources :

Example 16 with TLSServerParameters

use of org.apache.cxf.configuration.jsse.TLSServerParameters in project cxf by apache.

the class JettyHTTPDestination method retrieveEngine.

/**
 * Post-configure retreival of server engine.
 */
protected void retrieveEngine() throws GeneralSecurityException, IOException {
    if (serverEngineFactory == null) {
        return;
    }
    engine = serverEngineFactory.retrieveJettyHTTPServerEngine(nurl.getPort());
    if (engine == null) {
        engine = serverEngineFactory.createJettyHTTPServerEngine(nurl.getHost(), nurl.getPort(), nurl.getProtocol());
    }
    assert engine != null;
    TLSServerParameters serverParameters = engine.getTlsServerParameters();
    if (serverParameters != null && serverParameters.getCertConstraints() != null) {
        CertificateConstraintsType constraints = serverParameters.getCertConstraints();
        if (constraints != null) {
            certConstraints = CertConstraintsJaxBUtils.createCertConstraints(constraints);
        }
    }
    // Spring configuration has configured the port for https.
    if (!nurl.getProtocol().equals(engine.getProtocol())) {
        throw new IllegalStateException("Port " + engine.getPort() + " is configured with wrong protocol \"" + engine.getProtocol() + "\" for \"" + nurl + "\"");
    }
}
Also used : CertificateConstraintsType(org.apache.cxf.configuration.security.CertificateConstraintsType) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters)

Example 17 with TLSServerParameters

use of org.apache.cxf.configuration.jsse.TLSServerParameters in project cxf by apache.

the class JettyHTTPServerEngineFactory method createJettyHTTPServerEngine.

/**
 * This call creates a new JettyHTTPServerEngine initialized for "http"
 * or "https" on the given port. The determination of "http" or "https"
 * will depend on configuration of the engine's bean name.
 *
 * If an JettyHTTPEngine already exists, or the port
 * is already in use, a BindIOException will be thrown. If the
 * engine is being Spring configured for TLS a GeneralSecurityException
 * may be thrown.
 *
 * @param host if not null, server will listen on this host/address, otherwise
 *        server will listen on all local addresses.
 * @param port listen port for server
 * @param protocol "http" or "https"
 * @param id The key to reference into the tlsParametersMap. Can be null.
 * @return
 * @throws GeneralSecurityException
 * @throws IOException
 */
public synchronized JettyHTTPServerEngine createJettyHTTPServerEngine(String host, int port, String protocol, String id) throws GeneralSecurityException, IOException {
    LOG.fine("Creating Jetty HTTP Server Engine for port " + port + ".");
    TLSServerParameters tlsParameters = null;
    if (id != null && tlsParametersMap != null && tlsParametersMap.containsKey(id)) {
        tlsParameters = tlsParametersMap.get(id);
    }
    JettyHTTPServerEngine ref = getOrCreate(this, host, port, tlsParameters);
    // checking the protocol
    if (!protocol.equals(ref.getProtocol())) {
        throw new IOException("Protocol mismatch for port " + port + ": " + "engine's protocol is " + ref.getProtocol() + ", the url protocol is " + protocol);
    }
    if (!(ref.isSetThreadingParameters() || null == fallbackThreadingParameters)) {
        if (LOG.isLoggable(Level.INFO)) {
            final int min = fallbackThreadingParameters.getMinThreads();
            final int max = fallbackThreadingParameters.getMaxThreads();
            final String threadNamePrefix = fallbackThreadingParameters.getThreadNamePrefix();
            LOG.log(Level.INFO, "FALLBACK_THREADING_PARAMETERS_MSG", new Object[] { port, min, max, threadNamePrefix });
        }
        ref.setThreadingParameters(fallbackThreadingParameters);
    }
    return ref;
}
Also used : IOException(java.io.IOException) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters)

Aggregations

TLSServerParameters (org.apache.cxf.configuration.jsse.TLSServerParameters)17 IOException (java.io.IOException)6 TreeMap (java.util.TreeMap)6 JAXBException (javax.xml.bind.JAXBException)6 TLSServerParametersConfig (org.apache.cxf.configuration.jsse.TLSServerParametersConfig)6 ArrayList (java.util.ArrayList)5 GeneralSecurityException (java.security.GeneralSecurityException)4 ConfigurationException (org.osgi.service.cm.ConfigurationException)4 StringReader (java.io.StringReader)3 JAXBElement (javax.xml.bind.JAXBElement)3 ClientAuthentication (org.apache.cxf.configuration.security.ClientAuthentication)3 Test (org.junit.Test)3 Element (org.w3c.dom.Element)3 URL (java.net.URL)2 HashMap (java.util.HashMap)2 StringTokenizer (java.util.StringTokenizer)2 Bus (org.apache.cxf.Bus)2 KeyManagersType (org.apache.cxf.configuration.security.KeyManagersType)2 SecureRandomParameters (org.apache.cxf.configuration.security.SecureRandomParameters)2 TrustManagersType (org.apache.cxf.configuration.security.TrustManagersType)2