| | |
| | | * 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; |
| | |
| | | |
| | | 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 |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isOpen() |
| | | { |
| | | return !sslEngine.isOutboundDone() || !sslEngine.isInboundDone(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int read(final ByteBuffer unwrappedData) throws IOException |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int write(final ByteBuffer unwrappedData) throws IOException |
| | | { |
| | |
| | | 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. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private void doHandshake(final boolean isReading) throws IOException |
| | | { |
| | | // This lock is probably unnecessary since tasks can be run in parallel, |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** Attempt to read and unwrap the next SSL packet. */ |
| | | private int doRecvAndUnwrap() throws IOException |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** Attempt to wrap and send the next SSL packet. */ |
| | | private int doWrapAndSend(final ByteBuffer unwrappedData) |
| | | throws IOException |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | recvUnwrappedBuffer.flip(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteChannel getChannel() |
| | | { |
| | | return pimpl; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Certificate[] getClientCertificateChain() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return "TLS"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int getSSF() |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isSecure() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | } |