Sun Adapter for LDAP API

com.stc.connector.ldapadapter.utils.cryptography.impl
Class CryptorImpl

java.lang.Object
  extended by com.stc.connector.ldapadapter.utils.cryptography.impl.CryptorImpl
All Implemented Interfaces:
Cryptor

public final class CryptorImpl
extends java.lang.Object
implements Cryptor

Provides a Cryptor implementation. The getInstance(Map aProperties) factory method returnes a new instance of this implementation each time. So it does not provide a singlton and does not pool any instances.

Use the CIPHER_KEY_ALIAS_PROPERTY_KEY, CIPHER_KEY_PASSWORD_PROPERTY_KEY, CIPHER_TRANSFORMATION_PROPERTY_KEY keys and the KEYSTORE_URL_PROPERTY_KEY, KEYSTORE_TYPE_PROPERTY_KEY, KEYSTORE_PASSWORD_PROPERTY_KEY keys defined in the KeyStoreUtil interface to set the desired values in the property map when acquiring an instance.

Version:
$Revision: 1.2 $, $Date: 2008/04/23 11:03:15 $
Author:
See Also:
Cryptor

Field Summary
 
Fields inherited from interface com.stc.connector.ldapadapter.utils.cryptography.api.Cryptor
CIPHER_KEY_ALIAS_PROPERTY_KEY, CIPHER_KEY_PASSWORD_PROPERTY_KEY, CIPHER_TRANSFORMATION_PROPERTY_KEY
 
Method Summary
 byte[] decodeBase64(byte[] aData)
          Decodes the Base64 encoded aData.
 byte[] decodeBase64AndDecrypt(byte[] aData)
          Decrypts the Base64 encoded aData and then decrypts using the same Cipher that was used to encrypt it.
 byte[] decrypt(byte[] aData)
          Decrypts the aData using a Cipher.
 byte[] encodeBase64(byte[] aData)
          Encodes the aData to Base64 encoded form.
 byte[] encrypt(byte[] aData)
          Encrypts the aData using a Cipher.
 byte[] encryptAndEncodeBase64(byte[] aData)
          Encrypts the aData using a Cipher and returns the results in Base64 encoded form.
static Cryptor getInstance(java.util.Map aProperties)
          This factory method returns a new instance of a Cryptor initializing it using the specified properties.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Cryptor getInstance(java.util.Map aProperties)

This factory method returns a new instance of a Cryptor initializing it using the specified properties.

Use the CIPHER_KEY_ALIAS_PROPERTY_KEY, CIPHER_KEY_PASSWORD_PROPERTY_KEY, CIPHER_TRANSFORMATION_PROPERTY_KEY keys and the KEYSTORE_URL_PROPERTY_KEY, KEYSTORE_TYPE_PROPERTY_KEY, KEYSTORE_PASSWORD_PROPERTY_KEY keys defined in the KeyStoreUtil interface to set the desired values in the property map when acquiring an instance.

Parameters:
aProperties - The map view of the properties to use in getting the instance.
Returns:
A new Cryptor instance based on the specified properties.

encrypt

public byte[] encrypt(byte[] aData)
Description copied from interface: Cryptor
Encrypts the aData using a Cipher.

Specified by:
encrypt in interface Cryptor
Parameters:
aData - The data to be encrypted.
Returns:
byte[] The encrypted data.
See Also:
Cryptor.encrypt(byte[] aData).

decrypt

public byte[] decrypt(byte[] aData)
Description copied from interface: Cryptor
Decrypts the aData using a Cipher.

Specified by:
decrypt in interface Cryptor
Parameters:
aData - The encyrpted data.
Returns:
byte[] The decrypted data.
See Also:
Cryptor.decrypt(byte[] aData).

encodeBase64

public byte[] encodeBase64(byte[] aData)
Description copied from interface: Cryptor
Encodes the aData to Base64 encoded form.

Specified by:
encodeBase64 in interface Cryptor
Parameters:
aData - The data to be encoded in Base64.
Returns:
byte[] The encoded data.
See Also:
Cryptor.encodeBase64(byte[] aData).

decodeBase64

public byte[] decodeBase64(byte[] aData)
Description copied from interface: Cryptor
Decodes the Base64 encoded aData.

Specified by:
decodeBase64 in interface Cryptor
Parameters:
aData - The Base64 encoded data.
Returns:
byte[] The decoded data.
See Also:
Cryptor.decodeBase64(byte[] aData).

encryptAndEncodeBase64

public byte[] encryptAndEncodeBase64(byte[] aData)
Description copied from interface: Cryptor
Encrypts the aData using a Cipher and returns the results in Base64 encoded form. It uses methods encrypt and base64Encode in its implementation.

Specified by:
encryptAndEncodeBase64 in interface Cryptor
Parameters:
aData - The data to be encrypted.
Returns:
byte[] The encrypted data.
See Also:
Cryptor.encryptAndEncodeBase64(byte[] aData).

decodeBase64AndDecrypt

public byte[] decodeBase64AndDecrypt(byte[] aData)
Description copied from interface: Cryptor
Decrypts the Base64 encoded aData and then decrypts using the same Cipher that was used to encrypt it. This method will decrypt only the data that was encrypted using the encryptAndBase64Encode method of this interface. It uses methods base64Decode and decrypt in its implementation.

Specified by:
decodeBase64AndDecrypt in interface Cryptor
Parameters:
aData - The encyrpted data in Base64 encoded form.
Returns:
byte[] The decrypted data.
See Also:
Cryptor.decodeBase64AndDecrypt(byte[] aData).

main

public static void main(java.lang.String[] args)

Sun Adapter for LDAP API