Java 8 SSLEngine - 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 SSLEngine class.

This code example shows how to use the following methods: setEnabledCipherSuites, setEnabledProtocols, setUseClientMode
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setUseClientMode
            { 
                TrustingX509Manager.getInstance() 
            }, null ); 
 
            SSLEngine engine = context.createSSLEngine();
            engine.setUseClientMode( true );
 
            ch.pipeline().addLast( "ssl", new SslHandler( engine ) );
        } 
        ch.pipeline().addLast( "http", new HttpClientCodec() );
        ch.pipeline().addLast( "handler", new HttpHandler( callback ) );
    } 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getSession, setUseClientMode
 
        // set the property before initialization SSLEngine. 
        System.setProperty("jsse.SSLEngine.acceptLargeFragments", "true");
 
        SSLEngine cliEngine = context.createSSLEngine();
        cliEngine.setUseClientMode(true);
 
        SSLEngine srvEngine = context.createSSLEngine();
        srvEngine.setUseClientMode(false);
 
        SSLSession cliSession = cliEngine.getSession();
        SSLSession srvSession = srvEngine.getSession();
 
        // check packet buffer sizes. 
        if (cliSession.getPacketBufferSize() < 33049 ||
            srvSession.getPacketBufferSize() < 33049) {
                throw new Exception("Don't accept large SSL/TLS fragments");
        } 
 
        // check application data buffer sizes. 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setUseClientMode
		// 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());
		return pipeline;
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getSession, setUseClientMode
 
  public SecureSocketWrapper(SocketWrapper wrapper) throws NoSuchAlgorithmException {
    this.channel = wrapper.getSocket();
    SSLContext context = SSLContext.getDefault();
    sslEngine = context.createSSLEngine();
    sslEngine.setUseClientMode(true);
    in = ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize());
    unwrappedIn = ByteBuffer.allocate(sslEngine.getSession().getApplicationBufferSize());
    out = ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize());
    empty = ByteBuffer.allocate(0);
  } 
 
  @Override 
  public SelectionKey register(Selector sel, int ops) throws ClosedChannelException {
    return channel.register(sel, ops);
  } 
 
  @Override 
  public boolean connect(SocketAddress remote) throws IOException {
    return channel.connect(remote);
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getSession, setEnabledCipherSuites, setNeedClientAuth, setUseClientMode
	 */ 
	public SSLEngineHelper(String host, int port, NIOJICPConnection connection) throws ICPException {
		SSLContext context = SSLHelper.createContext();
		// get a SSLEngine, use host and port for optimization 
		ssle = context.createSSLEngine(host, port);
		ssle.setUseClientMode(false);
		ssle.setNeedClientAuth(SSLHelper.needAuth());
		if (!SSLHelper.needAuth()) { 
			// if we don't do authentication we restrict our ssl connection to use specific cipher suites 
			ssle.setEnabledCipherSuites(SSLHelper.getSupportedKeys());
		} 
 
		SSLSession session = ssle.getSession();
		// TODO prevent buffer overflow, why *2? 
		unwrapData = ByteBuffer.allocateDirect(session.getApplicationBufferSize() + 1500);
		wrapData = ByteBuffer.allocateDirect(session.getPacketBufferSize());
		sendData = ByteBuffer.allocateDirect(wrapData.capacity());;
		this.connection = connection;
	} 
	/** 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setUseClientMode
    public com.facebook.presto.jdbc.internal.jetty.io.Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOExceptionString host = (String)context.get(SSL_PEER_HOST_CONTEXT_KEY);
        int port = (Integer)context.get(SSL_PEER_PORT_CONTEXT_KEY);
        SSLEngine engine = sslContextFactory.newSSLEngine(host, port);
        engine.setUseClientMode(true);
        context.put(SSL_ENGINE_CONTEXT_KEY, engine);
 
        SslConnection sslConnection = newSslConnection(byteBufferPool, executor, endPoint, engine);
        sslConnection.setRenegotiationAllowed(sslContextFactory.isRenegotiationAllowed());
        endPoint.setConnection(sslConnection);
        EndPoint appEndPoint = sslConnection.getDecryptedEndPoint();
        appEndPoint.setConnection(connectionFactory.newConnection(appEndPoint, context));
 
        return sslConnection;
    } 
 
    protected SslConnection newSslConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
    { 
        return new SslConnection(byteBufferPool, executor, endPoint, engine);
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getSSLParameters, getHandshakeSession
    } 
 
    @Override 
    public String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine)
    { 
        String alias = chooseServerAlias(keyType,issuers,engine.getSSLParameters().getSNIMatchers(),engine.getHandshakeSession());
        if (alias==NO_MATCHERS)
            alias=_delegate.chooseEngineServerAlias(keyType,issuers,engine);
        if (LOG.isDebugEnabled())
            LOG.debug("Chose alias {}/{} on {}",alias,keyType,engine);
        return alias;
    } 
 
    @Override 
    public X509Certificate[] getCertificateChain(String alias)
    { 
        return _delegate.getCertificateChain(alias);
    } 
 
    @Override 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: beginHandshake, getSession, setNeedClientAuth, setWantClientAuth
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: beginHandshake, getSession, setNeedClientAuth, setWantClientAuth
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 SSLEngine Methods: