Package org.eclipse.jetty.util.ssl

Examples of org.eclipse.jetty.util.ssl.SslContextFactory


      final String password = commandLineArgs.get(CommandLineIntepreter.OPTION_KEYPASS);
      final String keystorePath = commandLineArgs.get(CommandLineIntepreter.OPTION_KEYSTORE);
      final int port = getSslPort(commandLineArgs);

      final SslContextFactory sslContextFactory = constructSslContextFactory(password, keystorePath);
      final SslSocketConnector sslConnector = new SslSocketConnector(sslContextFactory);
      sslConnector.setPort(port);
      sslConnector.setName(SSL_CONNECTOR_NAME);
      sslConnector.setHost(DEFAULT_HOST);
View Full Code Here


      return sslConnector;
   }

   private SslContextFactory constructSslContextFactory(final String password, final String keystorePath) {
      final SslContextFactory sslFactory = new SslContextFactory();

      sslFactory.setKeyStorePassword(password);
      sslFactory.setTrustStorePassword(password);
      sslFactory.setKeyManagerPassword(password);
      sslFactory.setKeyStorePath(keystorePath);

      return sslFactory;
   }
View Full Code Here

      sslConnectorTwoWay.setTruststoreType("PKCS12");
      sslConnectorTwoWay.setNeedClientAuth(true);

      //Secured connector for 1-way auth
      //SslSelectChannelConnector sslConnectorOneWay = new SslSelectChannelConnector();
      SslContextFactory contextFactory = new SslContextFactory(true);
      //sslConnectorOneWay.setPort(AGENT_ONE_WAY_AUTH);
      contextFactory.setKeyStorePath(keystore);
      // sslConnectorOneWay.setKeystore(keystore);
      contextFactory.setTrustStore(keystore);
      // sslConnectorOneWay.setTruststore(keystore);
      contextFactory.setKeyStorePassword(srvrCrtPass);
      // sslConnectorOneWay.setPassword(srvrCrtPass);

      contextFactory.setKeyManagerPassword(srvrCrtPass);

      // sslConnectorOneWay.setKeyPassword(srvrCrtPass);

      contextFactory.setTrustStorePassword(srvrCrtPass);
      //sslConnectorOneWay.setTrustPassword(srvrCrtPass);

      contextFactory.setKeyStoreType("PKCS12");
      //sslConnectorOneWay.setKeystoreType("PKCS12");
      contextFactory.setTrustStoreType("PKCS12");

      //sslConnectorOneWay.setTruststoreType("PKCS12");
      contextFactory.setNeedClientAuth(false);
      // sslConnectorOneWay.setWantClientAuth(false);
      // sslConnectorOneWay.setNeedClientAuth(false);
      SslSelectChannelConnector sslConnectorOneWay = new SslSelectChannelConnector(contextFactory);
      sslConnectorOneWay.setPort(AGENT_ONE_WAY_AUTH);
      sslConnectorOneWay.setAcceptors(2);
View Full Code Here

public class WssProducerTest extends WsProducerTestBase {
    protected static final String PW = "changeit";
   
    @Override
    protected Connector getConnector() throws Exception {
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setSslContext(defineSSLContextServerParameters().createSSLContext());
        return new SslSelectChannelConnector(sslContextFactory);
    }
View Full Code Here

    }

    protected SslConnector getSslSocketConnector() {
        SslSelectChannelConnector sslSocketConnector = null;
        if (sslContextParameters != null) {
            SslContextFactory sslContextFactory = new CometdComponentSslContextFactory();
            try {
                sslContextFactory.setSslContext(sslContextParameters.createSSLContext());
            } catch (Exception e) {
                throw new RuntimeCamelException("Error initiating SSLContext.", e);
            }
            sslSocketConnector = new SslSelectChannelConnector(sslContextFactory);
        } else {
View Full Code Here

    {
      final DruidHttpClientConfig config = getConfigProvider().get().get();

      final HttpClient httpClient;
      if (getSslContextBinding() != null) {
        final SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setSslContext(getSslContextBinding().getProvider().get());
        httpClient = new HttpClient(sslContextFactory);
      } else {
        httpClient = new HttpClient();
      }
View Full Code Here

        {
            connector = new SelectChannelConnector();
        }
        else if (_transport == Transport.WSS)
        {
            SslContextFactory factory = new SslContextFactory();
            factory.setSslContext(_sslContext);
            factory.setNeedClientAuth(true);
            connector = new SslSelectChannelConnector(factory);
        }
        else
        {
            throw new IllegalArgumentException("Unexpected transport on port " + _port.getName() + ":" + _transport);
View Full Code Here

        {
            connector = new SelectChannelConnector();
        }
        else if (_transport == Transport.WSS)
        {
            SslContextFactory factory = new SslContextFactory();
            factory.setSslContext(_sslContext);
            factory.setNeedClientAuth(true);
            connector = new SslSelectChannelConnector(factory);
        }
        else
        {
            throw new IllegalArgumentException("Unexpected transport on port " + _port.getName() + ":" + _transport);
View Full Code Here

            _threadPool = new QueuedThreadPool();
        }
        if(context != null)
        {
            WebSocketClientFactory factory = new WebSocketClientFactory(_threadPool);
            SslContextFactory sslContextFactory = factory.getSslContextFactory();


            sslContextFactory.setSslContext(context);

            factory.start();

            return factory;
        }
View Full Code Here

        }
    }

    static void configureSsl( SslConnectionFactory sslConnFactory, SecureJettyConfiguration config )
    {
        SslContextFactory ssl = sslConnFactory.getSslContextFactory();

        boolean needBouncyCastle = false;

        // KeyStore
        String keystoreType = config.keystoreType().get();
        String keystorePath = config.keystorePath().get();
        String keystorePassword = config.keystorePassword().get();
        ssl.setKeyStoreType( keystoreType );
        if( "PKCS12".equals( keystoreType ) )
        {
            ssl.setKeyStoreProvider( "BC" ); // WARN This one needs BouncyCastle on the classpath
            needBouncyCastle = true;
        }
        ssl.setKeyStorePath( keystorePath );
        ssl.setKeyStorePassword( keystorePassword );

        // Certificate alias
        String certAlias = config.certAlias().get();
        if( certAlias != null )
        {
            ssl.setCertAlias( certAlias );
        }

        // TrustStore
        String truststoreType = config.truststoreType().get();
        String truststorePath = config.truststorePath().get();
        String truststorePassword = config.truststorePassword().get();
        if( truststoreType != null && truststorePath != null )
        {
            ssl.setTrustStoreType( truststoreType );
            if( "PKCS12".equals( truststoreType ) )
            {
                ssl.setTrustStoreProvider( "BC" );
                needBouncyCastle = true;
            }
            ssl.setTrustStorePath( truststorePath );
            ssl.setTrustStorePassword( truststorePassword );
        }

        // Need / Want Client Auth
        Boolean want = config.wantClientAuth().get();
        if( want != null )
        {
            ssl.setWantClientAuth( want );
        }
        Boolean need = config.needClientAuth().get();
        if( need != null )
        {
            ssl.setNeedClientAuth( need );
        }

        // Algorithms
        String secureRandomAlgo = config.secureRandomAlgorithm().get();
        if( secureRandomAlgo != null )
        {
            ssl.setSecureRandomAlgorithm( secureRandomAlgo );
        }
        String cipherExcludesConfigString = config.excludeCipherSuites().get();
        if( cipherExcludesConfigString != null )
        {
            String[] cipherExcludes = cipherExcludesConfigString.split( COMA );
            if( cipherExcludes.length > 0 )
            {
                ssl.setExcludeCipherSuites( cipherExcludes );
            }
        }
        String cipherIncludesConfigString = config.includeCipherSuites().get();
        if( cipherIncludesConfigString != null )
        {
            String[] cipherIncludes = cipherIncludesConfigString.split( COMA );
            if( cipherIncludes.length > 0 )
            {
                ssl.setIncludeCipherSuites( cipherIncludes );
            }
        }

        // SSL Handling
        Boolean cacheSslSessions = config.cacheSslSessions().get();
        if( cacheSslSessions != null )
        {
            ssl.setSessionCachingEnabled( cacheSslSessions );
        }
        ssl.setRenegotiationAllowed( config.allowRenegotiation().get() );

        // Validation Flags
        Integer maxCertPathLength = config.maxCertPathLength().get();
        if( maxCertPathLength != null )
        {
            ssl.setMaxCertPathLength( maxCertPathLength );
        }
        ssl.setValidateCerts( config.validateServerCert().get() );
        ssl.setValidatePeerCerts( config.validatePeerCerts().get() );

        // Validation CRL
        String crlFilePath = config.crlFilePath().get();
        if( crlFilePath != null && crlFilePath.length() > 0 )
        {
            ssl.setCrlPath( crlFilePath );
        }
        ssl.setEnableCRLDP( config.enableCRLDP().get() );

        // Validation OCSP
        ssl.setEnableOCSP( config.enableOCSP().get() );
        String ocspURL = config.ocspResponderURL().get();
        if( ocspURL != null )
        {
            ssl.setOcspResponderURL( ocspURL );
        }

        // Load BouncyCastle ?
        if( needBouncyCastle )
        {
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.util.ssl.SslContextFactory

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.