mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
20.42.2016 61b9eb1be03fc03a9f4bb0013a08ff44a1059503
opendj-server-legacy/src/main/java/org/opends/server/extensions/TLSByteChannel.java
@@ -12,12 +12,10 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2008-2009 Sun Microsystems, Inc.
 * Portions Copyright 2012-2015 ForgeRock AS.
 * Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.extensions;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
@@ -36,20 +34,12 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
/**
 * A class that provides a TLS byte channel implementation.
 */
/** A class that provides a TLS byte channel implementation. */
public final class TLSByteChannel implements ConnectionSecurityProvider
{
  /**
   * Private implementation.
   */
  /** Private implementation. */
  private final class ByteChannelImpl implements ByteChannel
  {
    /** {@inheritDoc} */
    @Override
    public void close() throws IOException
    {
@@ -98,18 +88,12 @@
      }
    }
    /** {@inheritDoc} */
    @Override
    public boolean isOpen()
    {
      return !sslEngine.isOutboundDone() || !sslEngine.isInboundDone();
    }
    /** {@inheritDoc} */
    @Override
    public int read(final ByteBuffer unwrappedData) throws IOException
    {
@@ -147,9 +131,6 @@
      }
    }
    /** {@inheritDoc} */
    @Override
    public int write(final ByteBuffer unwrappedData) throws IOException
    {
@@ -176,8 +157,6 @@
      return bytesWritten;
    }
    /**
     * It seems that the SSL engine does not remember if an error has already
     * occurred so we must cache it here and rethrow. See OPENDJ-652.
@@ -190,8 +169,6 @@
      }
    }
    private void doHandshake(final boolean isReading) throws IOException
    {
      // This lock is probably unnecessary since tasks can be run in parallel,
@@ -234,8 +211,6 @@
      }
    }
    /** Attempt to read and unwrap the next SSL packet. */
    private int doRecvAndUnwrap() throws IOException
    {
@@ -323,8 +298,6 @@
      }
    }
    /** Attempt to wrap and send the next SSL packet. */
    private int doWrapAndSend(final ByteBuffer unwrappedData)
        throws IOException
@@ -382,17 +355,12 @@
      }
    }
    private boolean isHandshaking(final HandshakeStatus status)
    {
      return status != HandshakeStatus.NOT_HANDSHAKING;
    }
  }
  /**
   * Map of cipher phrases to effective key size (bits). Taken from the
   * following RFCs: 5289, 4346, 3268,4132 and 4162 and the IANA Transport Layer
@@ -445,8 +413,6 @@
  private final Object readLock = new Object();
  private final Object writeLock = new Object();
  /**
   * Creates an TLS byte channel instance using the specified LDAP connection
   * configuration, client connection, SSL context and socket channel
@@ -476,18 +442,12 @@
    recvUnwrappedBuffer.flip();
  }
  /** {@inheritDoc} */
  @Override
  public ByteChannel getChannel()
  {
    return pimpl;
  }
  /** {@inheritDoc} */
  @Override
  public Certificate[] getClientCertificateChain()
  {
@@ -502,18 +462,12 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public String getName()
  {
    return "TLS";
  }
  /** {@inheritDoc} */
  @Override
  public int getSSF()
  {
@@ -546,13 +500,9 @@
    return null;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isSecure()
  {
    return true;
  }
}