Compoze Software, Inc.

portlets.compoze.groupware.util
Class Encryptor

java.lang.Object
  extended byportlets.compoze.groupware.util.Encryptor
All Implemented Interfaces:
java.io.Serializable

public class Encryptor
extends java.lang.Object
implements java.io.Serializable

This is a utility class for DES3 encryption and decryption.

See Also:
Serialized Form

Method Summary
 java.lang.String decrypt(java.lang.String sValue)
          Decrypts the given String
 java.lang.String encrypt(java.lang.String sValue)
          Encrypts the gives String.
 java.lang.String generateKeyString()
          Randomly generates a new key.
static Encryptor i()
          Gets an instance of the encryptor.
 void setKey(java.lang.String sKey)
          Sets the encryption key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

i

public static Encryptor i()
                   throws GroupwareException
Gets an instance of the encryptor.

Returns:
an instance of the Encryptor
Throws:
GroupwareException - error occured while retrieving encryption key

setKey

public void setKey(java.lang.String sKey)
            throws java.security.InvalidKeyException
Sets the encryption key.

Parameters:
sKey - the encryption key
Throws:
java.security.InvalidKeyException

encrypt

public java.lang.String encrypt(java.lang.String sValue)
                         throws java.security.spec.InvalidKeySpecException,
                                java.security.NoSuchAlgorithmException,
                                javax.crypto.NoSuchPaddingException,
                                java.security.InvalidKeyException,
                                java.security.InvalidAlgorithmParameterException,
                                java.lang.IllegalStateException,
                                javax.crypto.IllegalBlockSizeException,
                                javax.crypto.BadPaddingException
Encrypts the gives String.

Parameters:
sValue - the String to encrypt
Returns:
the encrypted String
Throws:
java.security.spec.InvalidKeySpecException - consolidate to one exception
java.security.NoSuchAlgorithmException - consolidate to one exception
javax.crypto.NoSuchPaddingException - consolidate to one exception
java.security.InvalidKeyException - consolidate to one exception
java.security.InvalidAlgorithmParameterException - consolidate to one exception
java.lang.IllegalStateException - consolidate to one exception
javax.crypto.IllegalBlockSizeException - consolidate to one exception
javax.crypto.BadPaddingException - consolidate to one exception

decrypt

public java.lang.String decrypt(java.lang.String sValue)
                         throws java.security.spec.InvalidKeySpecException,
                                java.security.NoSuchAlgorithmException,
                                javax.crypto.NoSuchPaddingException,
                                java.security.InvalidKeyException,
                                java.security.InvalidAlgorithmParameterException,
                                java.lang.IllegalStateException,
                                javax.crypto.IllegalBlockSizeException,
                                javax.crypto.BadPaddingException
Decrypts the given String

Parameters:
sValue - the String ot decrypt
Returns:
the decrypted String
Throws:
java.security.spec.InvalidKeySpecException - consolidate to one exception
java.security.NoSuchAlgorithmException - consolidate to one exception
javax.crypto.NoSuchPaddingException - consolidate to one exception
java.security.InvalidKeyException - consolidate to one exception
java.security.InvalidAlgorithmParameterException - consolidate to one exception
java.lang.IllegalStateException - consolidate to one exception
javax.crypto.IllegalBlockSizeException - consolidate to one exception
javax.crypto.BadPaddingException - consolidate to one exception

generateKeyString

public java.lang.String generateKeyString()
                                   throws java.security.NoSuchAlgorithmException
Randomly generates a new key.

Returns:
the Base64 encoded key
Throws:
java.security.NoSuchAlgorithmException - if key generation fails

Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.