| | |
| | | import org.opends.server.types.SSLClientAuthPolicy; |
| | | import org.opends.server.util.SelectableCertificateKeyManager; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | public class TLSConnectionSecurityProvider |
| | | extends ConnectionSecurityProvider |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.extensions.TLSConnectionSecurityProvider"; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(clientConnection)); |
| | | |
| | | this.clientConnection = clientConnection; |
| | | this.socketChannel = socketChannel; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializeConnectionSecurityProvider", |
| | | e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_TLS_SECURITY_PROVIDER_CANNOT_INITIALIZE; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | |
| | | public void initializeConnectionSecurityProvider(ConfigEntry configEntry) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "initializeConnectionSecurityProvider", |
| | | String.valueOf(configEntry)); |
| | | |
| | | // Initialize default values for the connection-specific variables. |
| | | clientConnection = null; |
| | |
| | | */ |
| | | public void finalizeConnectionSecurityProvider() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "finalizeConnectionSecurityProvider"); |
| | | |
| | | // No implementation is required. |
| | | } |
| | |
| | | */ |
| | | public String getSecurityMechanismName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSecurityMechanismName"); |
| | | |
| | | return SSL_CONTEXT_INSTANCE_NAME; |
| | | } |
| | |
| | | */ |
| | | public boolean isSecure() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isSecure"); |
| | | |
| | | // This should be considered secure. |
| | | return true; |
| | |
| | | SocketChannel socketChannel) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "newInstance", |
| | | String.valueOf(clientConnection), |
| | | String.valueOf(socketChannel)); |
| | | |
| | | return new TLSConnectionSecurityProvider(clientConnection, socketChannel, |
| | | this); |
| | |
| | | */ |
| | | public void disconnect(boolean connectionValid) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "disconnect"); |
| | | |
| | | if (connectionValid) |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "disconnect", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public int getClearBufferSize() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getClearBufferSize"); |
| | | |
| | | return clearBufferSize; |
| | | } |
| | |
| | | */ |
| | | public int getEncodedBufferSize() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getEncodedBufferSize"); |
| | | |
| | | return sslBufferSize; |
| | | } |
| | |
| | | */ |
| | | public boolean readData() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "readData"); |
| | | |
| | | |
| | | while (true) |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | assert debugException(CLASS_NAME, "readData", ioe); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ioe); |
| | | } |
| | | |
| | | // An error occurred while trying to communicate with the client. |
| | | // Disconnect and return. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "readData", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // An unexpected error occurred while trying to process the data read. |
| | | // Disconnect and return. |
| | |
| | | */ |
| | | public boolean writeData(ByteBuffer clearData) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "writeData", "java.nio.ByteBuffer"); |
| | | |
| | | int originalPosition = clearData.position(); |
| | | int originalLimit = clearData.limit(); |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | assert debugException(CLASS_NAME, "writeData", ioe); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ioe); |
| | | } |
| | | |
| | | // An error occurred while trying to communicate with the client. |
| | | // Disconnect and return. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "writeData", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // An unexpected error occurred while trying to process the data read. |
| | | // Disconnect and return. |
| | |
| | | */ |
| | | public String[] getEnabledProtocols() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getEnabledProtocols"); |
| | | |
| | | return enabledProtocols; |
| | | } |
| | |
| | | */ |
| | | public void setEnabledProtocols(String[] enabledProtocols) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setEnabledProtocols", |
| | | String.valueOf(enabledProtocols)); |
| | | |
| | | this.enabledProtocols = enabledProtocols; |
| | | } |
| | |
| | | */ |
| | | public String[] getEnabledCipherSuites() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getEnabledCipherSuites"); |
| | | |
| | | return enabledCipherSuites; |
| | | } |
| | |
| | | */ |
| | | public void setEnabledCipherSuites(String[] enabledCipherSuites) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setEnabledCipherSuites", |
| | | String.valueOf(enabledCipherSuites)); |
| | | |
| | | this.enabledCipherSuites = enabledCipherSuites; |
| | | } |
| | |
| | | */ |
| | | public SSLClientAuthPolicy getSSLClientAuthPolicy() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSSLClientAuthPolicy"); |
| | | |
| | | return sslClientAuthPolicy; |
| | | } |
| | |
| | | */ |
| | | public void setSSLClientAuthPolicy(SSLClientAuthPolicy sslClientAuthPolicy) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setSSLClientAuthPolicy", |
| | | String.valueOf(sslClientAuthPolicy)); |
| | | |
| | | this.sslClientAuthPolicy = sslClientAuthPolicy; |
| | | } |
| | |
| | | */ |
| | | public SSLSession getSSLSession() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSSLSession"); |
| | | |
| | | return sslEngine.getSession(); |
| | | } |
| | |
| | | */ |
| | | public Certificate[] getClientCertificateChain() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getClientCertificateChain"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getClientCertificateChain", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return null; |
| | | } |