Search in sources :

Example 1 with DoubleItPortTypeImpl

use of org.apache.coheigea.cxf.ocsp.common.DoubleItPortTypeImpl in project testcases by coheigea.

the class ClientAuthServer method run.

protected void run() {
    Bus busLocal = BusFactory.getDefaultBus(true);
    setBus(busLocal);
    String address = "https://localhost:" + TLSOCSPClientAuthTest.PORT + "/doubleit/services/doubleittlsocspclientauth";
    try {
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
        keyStore.load(ClassLoaderUtils.getResourceAsStream("servicestore.jks", this.getClass()), "sspass".toCharArray());
        PKIXBuilderParameters param = new PKIXBuilderParameters(keyStore, new X509CertSelector());
        param.setRevocationEnabled(true);
        tmf.init(new CertPathTrustManagerParameters(param));
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmf.init(keyStore, "skpass".toCharArray());
        ClientAuthentication clientAuthentication = new ClientAuthentication();
        clientAuthentication.setRequired(true);
        clientAuthentication.setWant(true);
        TLSServerParameters tlsParams = new TLSServerParameters();
        tlsParams.setTrustManagers(tmf.getTrustManagers());
        tlsParams.setKeyManagers(kmf.getKeyManagers());
        tlsParams.setClientAuthentication(clientAuthentication);
        Map<String, TLSServerParameters> map = new HashMap<>();
        map.put("tlsId", tlsParams);
        JettyHTTPServerEngineFactory factory = busLocal.getExtension(JettyHTTPServerEngineFactory.class);
        factory.setTlsServerParametersMap(map);
        factory.createJettyHTTPServerEngine("localhost", Integer.parseInt(TLSOCSPClientAuthTest.PORT), "https", "tlsId");
        factory.initComplete();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    Endpoint.publish(address, new DoubleItPortTypeImpl());
}
Also used : Bus(org.apache.cxf.Bus) HashMap(java.util.HashMap) DoubleItPortTypeImpl(org.apache.coheigea.cxf.ocsp.common.DoubleItPortTypeImpl) PKIXBuilderParameters(java.security.cert.PKIXBuilderParameters) CertPathTrustManagerParameters(javax.net.ssl.CertPathTrustManagerParameters) X509CertSelector(java.security.cert.X509CertSelector) KeyStore(java.security.KeyStore) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) ClientAuthentication(org.apache.cxf.configuration.security.ClientAuthentication)

Aggregations

KeyStore (java.security.KeyStore)1 PKIXBuilderParameters (java.security.cert.PKIXBuilderParameters)1 X509CertSelector (java.security.cert.X509CertSelector)1 HashMap (java.util.HashMap)1 CertPathTrustManagerParameters (javax.net.ssl.CertPathTrustManagerParameters)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)1 DoubleItPortTypeImpl (org.apache.coheigea.cxf.ocsp.common.DoubleItPortTypeImpl)1 Bus (org.apache.cxf.Bus)1 TLSServerParameters (org.apache.cxf.configuration.jsse.TLSServerParameters)1 ClientAuthentication (org.apache.cxf.configuration.security.ClientAuthentication)1 JettyHTTPServerEngineFactory (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory)1