Code example for SSLEngine

Methods: getSessionsetUseClientMode

0
 
  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);