Package org.opends.server.util
Class SslUtils
- java.lang.Object
-
- org.opends.server.util.SslUtils
-
public final class SslUtils extends Object
Utility class for common SSL related setup.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Options
createOptionsForSslContext(Dn trustManagerProviderDn, Dn keyManagerProviderDn, String friendlyName, SortedSet<String> sslCertNicknames, SortedSet<String> sslCipherSuites, SortedSet<String> sslProtocols, ServerContext serverContext, ConnectionSecurity connectionSecurity)
Create SSL communicationsOptions
for an SSL context.static SSLContext
createSslContext(Collection<Dn> trustManagerProviderDns, Dn keyManagerProviderDn, String friendlyName, SortedSet<String> sslCertNicknames, ServerContext serverContext)
Creates an SSL context.static SslOptions
createSslOptions(Collection<Dn> trustManagerProviderDns, Dn keyManagerProviderDn, String friendlyName, SortedSet<String> sslCertNicknames, SortedSet<String> sslCipherSuites, SortedSet<String> sslProtocols, ServerContext serverContext)
CreatesSslOptions
for the provided parameters.static KeyManager[]
getKeyManagers(Dn keyManagerProviderDn, String friendlyName, Set<String> sslCertNicknames, ServerContext serverContext)
Returns an array ofKeyManager
s for use by theSSLContext
while setting up communication.static TrustManager[]
getTrustManagers(Collection<Dn> trustManagerProviderDns, ServerContext serverContext)
Returns an array ofTrustManager
s for use by theSSLContext
while setting up communication.static Collection<LocalizableMessage>
verifySslCiphersAndProtocols(Collection<String> cipherSuites, Collection<String> protocols, LocalizableMessageDescriptor.Arg1<Object> cipherError, LocalizableMessageDescriptor.Arg1<Object> protocolError)
Verifies all the specified SSL cipher suites and protocols are available in the current JVM.
-
-
-
Method Detail
-
createOptionsForSslContext
public static Options createOptionsForSslContext(Dn trustManagerProviderDn, Dn keyManagerProviderDn, String friendlyName, SortedSet<String> sslCertNicknames, SortedSet<String> sslCipherSuites, SortedSet<String> sslProtocols, ServerContext serverContext, ConnectionSecurity connectionSecurity)
Create SSL communicationsOptions
for an SSL context.If specific certificate nicknames are specified, only key managers managing those certificates will be returned in
Options
.- Parameters:
trustManagerProviderDn
- TheDN
of the configuration entry providingTrustManager
s.keyManagerProviderDn
- TheDN
of the configuration entry providingKeyManager
s.friendlyName
- A user readable name to be used in messages.sslCertNicknames
- The certificate nicknames to select the key managers to return.sslCipherSuites
- Sorted set of strings representing names of the SSL cipher suites which should be used.sslProtocols
- Sorted set of strings representing names of the SSL protocols which should be used.serverContext
- Theserver context
from which the key manager provider will be retrieve.connectionSecurity
- Represents the security level of the communications.- Returns:
options
associated to the provided SSL context.
-
createSslOptions
public static SslOptions createSslOptions(Collection<Dn> trustManagerProviderDns, Dn keyManagerProviderDn, String friendlyName, SortedSet<String> sslCertNicknames, SortedSet<String> sslCipherSuites, SortedSet<String> sslProtocols, ServerContext serverContext) throws KeyManagementException, LdapException
CreatesSslOptions
for the provided parameters.If specific certificate nicknames are specified, only key managers managing those certificates will be returned in
SslOptions
.- Parameters:
trustManagerProviderDns
- TheDN
s of the configuration entries providingTrustManager
s.keyManagerProviderDn
- TheDN
of the configuration entry providingKeyManager
s.friendlyName
- A user readable name to be used in messages.sslCertNicknames
- The certificate nicknames to select the key managers to return.sslCipherSuites
- Sorted set of strings representing names of the SSL cipher suites which should be used.sslProtocols
- Sorted set of strings representing names of the SSL protocols which should be used.serverContext
- Theserver context
from which the key manager provider will be retrieve.- Returns:
SSL options
associated to the provided arguments.- Throws:
KeyManagementException
- if an error occurred initializing the ssl contextLdapException
- If a problem occurs while attempting to obtain the key/trust managers from the provider.
-
createSslContext
public static SSLContext createSslContext(Collection<Dn> trustManagerProviderDns, Dn keyManagerProviderDn, String friendlyName, SortedSet<String> sslCertNicknames, ServerContext serverContext) throws LdapException, KeyManagementException
Creates an SSL context.If specific certificate nicknames are specified, only key managers managing those certificates will be used.
- Parameters:
trustManagerProviderDns
- TheDN
s of the configuration entries providingTrustManager
s.keyManagerProviderDn
- TheDN
of the configuration entry providingKeyManager
s.friendlyName
- A user readable name to be used in messages.sslCertNicknames
- The certificate nicknames to select the key managers to return.serverContext
- Theserver context
from which the key manager provider will be retrieve.- Returns:
- A new SSL context
- Throws:
LdapException
- If a problem occurs while attempting to obtain the key managers from the provider.KeyManagementException
- if the SSL context could not be initialized.
-
getKeyManagers
public static KeyManager[] getKeyManagers(Dn keyManagerProviderDn, String friendlyName, Set<String> sslCertNicknames, ServerContext serverContext) throws LdapException
Returns an array ofKeyManager
s for use by theSSLContext
while setting up communication.If the keyManagerProviderDn is
null
or if a key manager provider cannot be retrieved from the serverContext, then this method returnsnull
which means that an empty key manager should be used in communications.- Parameters:
keyManagerProviderDn
-DN
of the configuration element which represents a key manager provider. Ifnull
, the method will useSslOptions.USE_EMPTY_KEY_MANAGER
.friendlyName
- A user readable name to be used in messages.sslCertNicknames
- A set of string representing the aliases of the certificates which will be selected and returned by the method. This parameter can be used to filter out some key managers return by the provider.serverContext
- The server context to retrieve the key managers.- Returns:
- The computed
KeyManager
s or {code null} if no key manager can be retrieved. - Throws:
LdapException
- If a problem occurs while attempting to obtain the key managers from the provider.
-
getTrustManagers
public static TrustManager[] getTrustManagers(Collection<Dn> trustManagerProviderDns, ServerContext serverContext) throws LdapException
Returns an array ofTrustManager
s for use by theSSLContext
while setting up communication.- Parameters:
trustManagerProviderDns
-DN
s of the configuration element which represents trust manager providers.serverContext
- The server context to retrieve the trust managers.- Returns:
- The computed
TrustManager
s ornull
if no trust manager can be retrieved. - Throws:
LdapException
- If a problem occurs while attempting to obtain the trust managers from the provider.
-
verifySslCiphersAndProtocols
public static Collection<LocalizableMessage> verifySslCiphersAndProtocols(Collection<String> cipherSuites, Collection<String> protocols, LocalizableMessageDescriptor.Arg1<Object> cipherError, LocalizableMessageDescriptor.Arg1<Object> protocolError)
Verifies all the specified SSL cipher suites and protocols are available in the current JVM.- Parameters:
cipherSuites
- the list of required SSL cipher suitesprotocols
- the list of required SSL protocolcipherError
- the error to return for unknown cipher suitesprotocolError
- the error to return for unknown protocols- Returns:
- the list of errors to report when one of the cipher suites or protocols are not available
-
-