Package com.betfair.cougar.netutil

Examples of com.betfair.cougar.netutil.SslContextFactory


    protected void configureProtocol(BaseIoServiceConfig config, boolean isServer) throws IOException {
        try {
            ByteBuffer.setUseDirectBuffers(isUseDirectBuffersInMina());

            SslContextFactory factory = new SslContextFactory();
            if (isServer) {
                if (supportsTls) {
                    KeyStoreManagement keystoreMgmt = getKeystoreCertificateChains();
                    if (keystoreMgmt == null) {
                        throw new IllegalStateException("This configuration ostensibly supports TLS, yet doesn't provide valid keystore configuration");
                    }
                    factory.setKeyManagerFactoryKeyStore(keystoreMgmt.getKeyStore());
                    factory.setKeyManagerFactoryKeyStorePassword(keystorePassword);
                    if (wantClientAuth) {
                        KeyStoreManagement truststoreMgmt = getTruststoreCertificateChains();
                        if (truststoreMgmt == null) {
                            throw new IllegalStateException("This configuration ostensibly supports client auth, yet doesn't provide valid truststore configuration");
                        }
                        factory.setTrustManagerFactoryKeyStore(truststoreMgmt.getKeyStore());
                    }
                }
            }
            else {
                if (supportsTls) {
                    KeyStoreManagement truststoreMgmt = getTruststoreCertificateChains();
                    if (truststoreMgmt == null) {
                        throw new IllegalStateException("This configuration ostensibly supports TLS, yet doesn't provide valid truststore configuration");
                    }
                    factory.setTrustManagerFactoryKeyStore(truststoreMgmt.getKeyStore());
                    if (wantClientAuth) {
                        KeyStoreManagement keystoreMgmt = getKeystoreCertificateChains();
                        if (keystoreMgmt == null) {
                            throw new IllegalStateException("This configuration ostensibly supports client auth, yet doesn't provide valid keystore configuration");
                        }
                        factory.setKeyManagerFactoryKeyStore(keystoreMgmt.getKeyStore());
                        factory.setKeyManagerFactoryKeyStorePassword(keystorePassword);
                    }
                }
            }
            SSLFilter sslFilter = null;
            if (supportsTls) {
                sslFilter = new SSLFilter(factory.newInstance());
                sslFilter.setWantClientAuth(wantClientAuth);
                sslFilter.setNeedClientAuth(needClientAuth);
                sslFilter.setUseClientMode(!isServer);
                String[] cipherSuites = allowedCipherSuites == null || "".equals(allowedCipherSuites.trim()) ? null : allowedCipherSuites.split(",");
                if (cipherSuites != null) {
View Full Code Here

TOP

Related Classes of com.betfair.cougar.netutil.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.