Java 8 SSLContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SSLContext class.

This code example shows how to use the following methods:getServerSocketFactory
     *  
     * @see org.productivity.java.syslog4j.server.impl.net.tcp.TCPNetSyslogServer#getServerSocketFactory() 
     */ 
    @Override 
    protected ServerSocketFactory getServerSocketFactory() throws IOException {
        return sslContext.getServerSocketFactory();
    } 
 
    /** 
     * Loads a JKS keystore with given path and password. 
     *  
     * @param keystoreFile path to keystore file 
     * @param keystorePwd keystore password 
     * @return 
     * @throws KeyStoreException 
     * @throws NoSuchAlgorithmException 
     * @throws CertificateException 
     * @throws IOException 
     */ 
    private static KeyStore loadKeyStore(final String keystoreFile, final char[] keystorePwd) throws KeyStoreException,
7
CodeRank
This code example shows how to use the following methods:getSocketFactory
    @Override 
    public Socket createSocket(String host, int port) throws IOException {
        this.initSSLContext();
        InetAddress address = InetAddress.getByName(host);
 
        SSLSocketFactory socketFactory = this.sslContext.getSocketFactory();
        SSLSocket socket = (SSLSocket) socketFactory.createSocket(address, port);
        if (this.jsseSecurityDomain.getProtocols() != null)
            socket.setEnabledProtocols(this.jsseSecurityDomain.getProtocols());
        if (this.jsseSecurityDomain.getCipherSuites() != null)
            socket.setEnabledCipherSuites(this.jsseSecurityDomain.getCipherSuites());
        socket.setNeedClientAuth(this.jsseSecurityDomain.isClientAuth());
        return socket;
    } 
 
    @Override 
    public Socket createSocket(String host, int port, int timeout) throws IOException, TIMEOUT {
        this.initSSLContext();
        InetAddress address = InetAddress.getByName(host);
 
7
CodeRank
This code example shows how to use the following methods:getServerSocketFactory
This code example shows how to use the following methods:createSSLEngine
This code example shows how to use the following methods:getSocketFactory, init
        TrustManager[] trustmanagers = null;
        if (truststore != null) {
            trustmanagers = createTrustManagers(truststore);
        } 
        sslcontext = SSLContext.getInstance(algorithm);
        sslcontext.init(keymanagers, trustmanagers, random);
        socketfactory = sslcontext.getSocketFactory();
        this.nameResolver = nameResolver;
    } 
 
    public SSLSocketFactory( 
            final KeyStore keystore,
            final String keystorePassword,
            final KeyStore truststore)
            throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException 
    { 
        this(TLS, keystore, keystorePassword, truststore, null, null);
    } 
 
    public SSLSocketFactory(final KeyStore keystore, final String keystorePassword)
6
CodeRank
This code example shows how to use the following methods:getSocketFactory
 
    /** 
     * @see ProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int) 
     */ 
    public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort) throws IOException, UnknownHostException {
        Socket socket = mSslContext.getSocketFactory().createSocket(host, port, clientHost, clientPort);
        verifyPeerIdentity(host, port, socket);
        return socket;
    } 
 
     
    /** 
     * Attempts to get a new socket connection to the given host within the 
     * given time limit. 
     *  
     * @param host the host name/IP 
     * @param port the port on the host 
     * @param clientHost the local host name/IP to bind the socket to 
     * @param clientPort the port on the local machine 
     * @param params {@link HttpConnectionParams Http connection parameters} 
6
CodeRank
This code example shows how to use the following methods:getClientSessionContext
        return true; 
    } 
 
    @Override 
    protected void configureSSLContext(SSLContext context) throws GeneralSecurityException {
        LOG.trace("Configuring client-side SSLContext parameters on SSLContext [{}]...", context);
        if (this.getSessionTimeout() != null) {
            LOG.info("Configuring client-side SSLContext session timeout on SSLContext [{}] to [{}].", context, this.getSessionTimeout());
            this.configureSessionContext(context.getClientSessionContext(), this.getSessionTimeout());
        } 
        LOG.trace("Configured client-side SSLContext parameters on SSLContext [{}].", context);
    } 
 
    /** 
     * {@inheritDoc} 
     * <p/> 
     * This implementation returns the empty list as the enabled cipher suites 
     * and protocols are not client and server side specific in an 
     * {@code SSLEngine}. Consequently, overriding them here would be a bit odd 
     * as the client side specific configuration shouldn't really override a 
6
CodeRank
This code example shows how to use the following methods:getSocketFactory
        } 
    } 
 
    @Override 
    public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
        return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
    } 
 
    @Override 
    public Socket createSocket() throws IOException {
        return sslContext.getSocketFactory().createSocket();
    } 
 
    @Override 
    public String[] getDefaultCipherSuites() {
        return sslContext.getSocketFactory().getDefaultCipherSuites();
    } 
 
    @Override 
    public String[] getSupportedCipherSuites() {
6
CodeRank
This code example shows how to use the following methods:createSSLEngine
	{ 
		// Create a default pipeline implementation. 
		ChannelPipeline pipeline = pipeline();
 
		SSLContext sslContext = getSSLContext();
		SSLEngine sslEngine = sslContext.createSSLEngine();
		sslEngine.setUseClientMode(false);
		SslHandler sslHandler = new SslHandler(sslEngine);
 
		pipeline.addLast("ssl", sslHandler);
 
		pipeline.addLast("broker-encoder", new BrokerEncoderRouter());
		pipeline.addLast("broker-decoder", new BrokerDecoderRouter(GcsInfo.getMessageMaxSize()));
 
		if (GcsInfo.useAccessControl()) 
		{ 
			pipeline.addLast("broker-auth-filter", new AuthorizationFilter());
		} 
 
		pipeline.addLast("broker-handler", BrokerProtocolHandler.getInstance());
5
CodeRank
This code example shows how to use the following methods:getProtocol, getProvider, init

Related Java 8 SSLContext Questions & Answers:

See Code Examples for Java 8 SSLContext Methods: