|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opends.server.crypto.CryptoManagerImpl
public class CryptoManagerImpl
This class implements the Directory Server cryptographic framework,
which is described in the
CrytpoManager design document. CryptoManager implements
inter-OpenDS-instance authentication and authorization using the
ADS-based truststore, and secret key distribution. The interface also
provides methods for hashing, encryption, and other kinds of
cryptographic operations.
Note that it also contains methods for compressing and uncompressing data: while these are not strictly cryptographic operations, there are a lot of similarities and it is conceivable at some point that accelerated compression may be available just as it is for cryptographic operations.
Other components of CryptoManager:
CryptoManagerSync,
GetSymmetricKeyExtendedOperation| Constructor Summary | |
|---|---|
CryptoManagerImpl(CryptoManagerCfg cfg)
Creates a new instance of this crypto manager object from a given configuration, plus some static member initialization. |
|
| Method Summary | |
|---|---|
ConfigChangeResult |
applyConfigurationChange(CryptoManagerCfg cfg)
Applies the configuration changes to this change listener. |
int |
compress(byte[] src,
byte[] dst)
Attempts to compress the data in the provided source array into the given destination array. |
byte[] |
decrypt(byte[] data)
Decrypts the data in the provided byte array using cipher specified by the key identifier prologue to the data. |
byte[] |
digest(byte[] data)
Retrieves a byte array containing a message digest based on the provided data, using the preferred digest algorithm. |
byte[] |
digest(java.io.InputStream inputStream)
Retrieves a byte array containing a message digest based on the data read from the provided input stream, using the preferred digest algorithm. |
byte[] |
digest(java.lang.String digestAlgorithm,
byte[] data)
Retrieves a byte array containing a message digest based on the provided data, using the requested digest algorithm. |
byte[] |
digest(java.lang.String digestAlgorithm,
java.io.InputStream inputStream)
Retrieves a byte array containing a message digest based on the data read from the provided input stream, using the requested digest algorithm. |
byte[] |
encrypt(byte[] data)
Encrypts the data in the provided byte array using the preferred cipher transformation. |
byte[] |
encrypt(java.lang.String cipherTransformation,
int keyLengthBits,
byte[] data)
Encrypts the data in the provided byte array using the requested cipher algorithm. |
javax.crypto.CipherInputStream |
getCipherInputStream(java.io.InputStream inputStream)
Returns a CipherInputStream instantiated with a cipher corresponding to the key identifier prologue to the data. |
javax.crypto.CipherOutputStream |
getCipherOutputStream(java.io.OutputStream outputStream)
Writes encrypted data to the provided output stream using the preferred cipher transformation. |
javax.crypto.CipherOutputStream |
getCipherOutputStream(java.lang.String cipherTransformation,
int keyLengthBits,
java.io.OutputStream outputStream)
Writes encrypted data to the provided output stream using the requested cipher transformation. |
static java.lang.String |
getInstanceKeyID(byte[] instanceKeyCertificate)
Return the identifier of an instance's instance key. |
javax.crypto.Mac |
getMacEngine(java.lang.String keyEntryID)
For the specified key entry identifier, instantiate a MAC engine. |
java.lang.String |
getMacEngineKeyEntryID()
For the current preferred MAC algorithm and key length, return the identifier of the corresponding key entry. |
java.lang.String |
getMacEngineKeyEntryID(java.lang.String macAlgorithm,
int keyLengthBits)
For the specified MAC algorithm and key length, return the identifier of the corresponding key entry. |
java.security.MessageDigest |
getMessageDigest(java.lang.String digestAlgorithm)
Retrieves a MessageDigest object that may be used to
generate digests using the specified algorithm. |
java.security.MessageDigest |
getPreferredMessageDigest()
Retrieves a MessageDigest object that may be used to
generate digests using the preferred digest algorithm. |
java.lang.String |
getPreferredMessageDigestAlgorithm()
Retrieves the name of the preferred message digest algorithm. |
java.lang.String |
getSslCertNickname()
Get the name of the local certificate to use for SSL. |
java.util.SortedSet<java.lang.String> |
getSslCipherSuites()
Get the set of enabled SSL cipher suites. |
javax.net.ssl.SSLContext |
getSslContext(java.lang.String sslCertNickname)
Create an SSL context that may be used for communication to another ADS component. |
java.util.SortedSet<java.lang.String> |
getSslProtocols()
Get the set of enabled SSL protocols. |
boolean |
isConfigurationChangeAcceptable(CryptoManagerCfg cfg,
java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener. |
boolean |
isSslEncryption()
Determine whether SSL encryption is enabled. |
int |
uncompress(byte[] src,
byte[] dst)
Attempts to uncompress the data in the provided source array into the given destination array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CryptoManagerImpl(CryptoManagerCfg cfg)
throws ConfigException,
InitializationException
cfg - The configuration of this crypto manager.
ConfigException - If a problem occurs while creating this
CryptoManager that is a result of a problem in the configuration.
InitializationException - If a problem
occurs while creating this CryptoManager that is not the result of a
problem in the configuration.| Method Detail |
|---|
public boolean isConfigurationChangeAcceptable(CryptoManagerCfg cfg,
java.util.List<Message> unacceptableReasons)
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<CryptoManagerCfg>cfg - The new configuration containing the changes.unacceptableReasons - A list that can be used to hold messages about why the
provided configuration is not acceptable.
true if the proposed change is
acceptable, or false if it is not.public ConfigChangeResult applyConfigurationChange(CryptoManagerCfg cfg)
applyConfigurationChange in interface ConfigurationChangeListener<CryptoManagerCfg>cfg - The new configuration containing the changes.
public static java.lang.String getInstanceKeyID(byte[] instanceKeyCertificate)
throws CryptoManagerException
instanceKeyCertificate - The instance key for which to
return an identifier.
CryptoManagerException - If there is a problem computing
the identifier from the instance key.
TODO: Make package-private if ADSContextHelper can get keyID from ADS
TODO: suffix: Issue https://opends.dev.java.net/issues/show_bug.cgi?id=2442getInstanceKeyID()public java.lang.String getPreferredMessageDigestAlgorithm()
getPreferredMessageDigestAlgorithm in interface CryptoManager
public java.security.MessageDigest getPreferredMessageDigest()
throws java.security.NoSuchAlgorithmException
MessageDigest object that may be used to
generate digests using the preferred digest algorithm.
getPreferredMessageDigest in interface CryptoManagerMessageDigest object that may be used to
generate digests using the preferred digest algorithm.
java.security.NoSuchAlgorithmException - If the requested
algorithm is not supported or is unavailable.
public java.security.MessageDigest getMessageDigest(java.lang.String digestAlgorithm)
throws java.security.NoSuchAlgorithmException
MessageDigest object that may be used to
generate digests using the specified algorithm.
getMessageDigest in interface CryptoManagerdigestAlgorithm - The algorithm to use to generate the
message digest.
MessageDigest object that may be used to
generate digests using the specified algorithm.
java.security.NoSuchAlgorithmException - If the requested
algorithm is not supported or is unavailable.
public byte[] digest(byte[] data)
throws java.security.NoSuchAlgorithmException
digest in interface CryptoManagerdata - The data to be digested.
java.security.NoSuchAlgorithmException - If the requested
algorithm is not supported or is unavailable.
public byte[] digest(java.lang.String digestAlgorithm,
byte[] data)
throws java.security.NoSuchAlgorithmException
digest in interface CryptoManagerdigestAlgorithm - The algorithm to use to generate the
message digest.data - The data to be digested.
java.security.NoSuchAlgorithmException - If the requested
algorithm is not supported or is unavailable.
public byte[] digest(java.io.InputStream inputStream)
throws java.io.IOException,
java.security.NoSuchAlgorithmException
digest in interface CryptoManagerinputStream - The input stream from which the data is to
be read.
java.io.IOException - If a problem occurs while reading
data from the provided stream.
java.security.NoSuchAlgorithmException - If the requested
algorithm is not supported or is unavailable.
public byte[] digest(java.lang.String digestAlgorithm,
java.io.InputStream inputStream)
throws java.io.IOException,
java.security.NoSuchAlgorithmException
digest in interface CryptoManagerdigestAlgorithm - The algorithm to use to generate the
message digest.inputStream - The input stream from which the data is
to be read.
java.io.IOException - If a problem occurs while reading
data from the provided stream.
java.security.NoSuchAlgorithmException - If the requested
algorithm is not supported or is unavailable.
public java.lang.String getMacEngineKeyEntryID()
throws CryptoManagerException
getMacEngineKeyEntryID in interface CryptoManagerCryptoManagerException - In case one or more of the key
parameters is invalid, or there is a problem instantiating the
key entry in case it does not already exist.
public java.lang.String getMacEngineKeyEntryID(java.lang.String macAlgorithm,
int keyLengthBits)
throws CryptoManagerException
getMacEngineKeyEntryID in interface CryptoManagermacAlgorithm - The algorithm to use for the MAC engine.keyLengthBits - The key length in bits to use with the
specified algorithm.
CryptoManagerException - In case one or more of the key
parameters is invalid, or there is a problem instantiating the
key entry in case it does not already exist.
public javax.crypto.Mac getMacEngine(java.lang.String keyEntryID)
throws CryptoManagerException
getMacEngine in interface CryptoManagerkeyEntryID - The identifier of the key entry containing the
desired MAC algorithm name and key length.
CryptoManagerException - In case the key entry identifier
is invalid or there is a problem instantiating the MAC engine
from the parameters in the referenced key entry.
public byte[] encrypt(byte[] data)
throws java.security.GeneralSecurityException,
CryptoManagerException
encrypt in interface CryptoManagerdata - The plain-text data to be encrypted.
java.security.GeneralSecurityException - If a problem
occurs while encrypting the data.
CryptoManagerException - If a problem occurs managing the
encryption key or producing the cipher.
public byte[] encrypt(java.lang.String cipherTransformation,
int keyLengthBits,
byte[] data)
throws java.security.GeneralSecurityException,
CryptoManagerException
encrypt in interface CryptoManagercipherTransformation - The algorithm/mode/padding to use
for the cipher.keyLengthBits - The length in bits of the encryption key
this method is to use. Note the specified key length and
transformation must be compatible.data - The plain-text data to be encrypted.
java.security.GeneralSecurityException - If a problem
occurs while encrypting the data.
CryptoManagerException - If a problem occurs managing the
encryption key or producing the cipher.
public javax.crypto.CipherOutputStream getCipherOutputStream(java.io.OutputStream outputStream)
throws CryptoManagerException
getCipherOutputStream in interface CryptoManageroutputStream - The output stream to be wrapped by the
returned cipher output stream.
CryptoManagerException - If a problem occurs managing the
encryption key or producing the cipher.
public javax.crypto.CipherOutputStream getCipherOutputStream(java.lang.String cipherTransformation,
int keyLengthBits,
java.io.OutputStream outputStream)
throws CryptoManagerException
getCipherOutputStream in interface CryptoManagercipherTransformation - The algorithm/mode/padding to use
for the cipher.keyLengthBits - The length in bits of the encryption key
this method will generate. Note the specified key length
must be compatible with the transformation.outputStream - The output stream to be wrapped by the
returned cipher output stream.
CryptoManagerException - If a problem occurs managing the
encryption key or producing the cipher.
public byte[] decrypt(byte[] data)
throws java.security.GeneralSecurityException,
CryptoManagerException
decrypt in interface CryptoManagerdata - The cipher-text data to be decrypted.
java.security.GeneralSecurityException - If a problem
occurs while encrypting the data.
CryptoManagerException - If a problem occurs reading the
key identifier or initialization vector from the data
prologue, or using these values to initialize a Cipher.
public javax.crypto.CipherInputStream getCipherInputStream(java.io.InputStream inputStream)
throws CryptoManagerException
getCipherInputStream in interface CryptoManagerinputStream - The input stream be wrapped with the
CipherInputStream.
CryptoManagerException - If there is a problem reading the
key ID or initialization vector from the input stream,
or using these values to inititalize a Cipher.
public int compress(byte[] src,
byte[] dst)
compress in interface CryptoManagersrc - The array containing the raw data to compress.dst - The array into which the compressed data should be
written.
public int uncompress(byte[] src,
byte[] dst)
throws java.util.zip.DataFormatException
uncompress in interface CryptoManagersrc - The array containing the compressed data.dst - The array into which the uncompressed data should be
written.
java.util.zip.DataFormatException - If a problem occurs
while attempting to uncompress the data.
public javax.net.ssl.SSLContext getSslContext(java.lang.String sslCertNickname)
throws ConfigException
getSslContext in interface CryptoManagersslCertNickname - The name of the local certificate to use,
or null if none is specified.
ConfigException - If the context
could not be created.public java.lang.String getSslCertNickname()
getSslCertNickname in interface CryptoManagerpublic boolean isSslEncryption()
isSslEncryption in interface CryptoManagerpublic java.util.SortedSet<java.lang.String> getSslProtocols()
getSslProtocols in interface CryptoManagerpublic java.util.SortedSet<java.lang.String> getSslCipherSuites()
getSslCipherSuites in interface CryptoManager
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||