Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class EncryptionUtil

java.lang.Object
  extended by com.jivesoftware.util.EncryptionUtil

public class EncryptionUtil
extends java.lang.Object

A utility for encrypting strings using different algorithms. All strings are in hex format. The default algorithm for this class is Blowfish.


Constructor Summary
EncryptionUtil(java.lang.String key)
          Creates a EncryptionUtil class that uses the algorithm specified by the jive proeprty jive.crypto.algorithm, if the property is not specified then "Blowfish/ECB/PKCS5Padding" will be used.
EncryptionUtil(java.lang.String key, java.lang.String algorithm)
          Creates an encryption utility using the specified algorithm
 
Method Summary
 java.lang.String decryptString(java.lang.String cipherText)
          Decrypt the string using the cipher that this class was initialized with.
 java.lang.String encryptString(java.lang.String plainText)
          Encrypts the string using the cipher that this class was initialized with.
static java.lang.String generateSecretKey()
          Generates a new secret key using the Blowfish algorithm unless there is another specified by the jive property jive.crypto.algorithm.
static java.lang.String generateSecretKey(java.lang.String algorithm)
          Generates a new secret key using the specified algorithm.
static java.lang.String storeNewKeyInProperty(java.lang.String jiveProperty)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptionUtil

public EncryptionUtil(java.lang.String key)
               throws java.security.NoSuchAlgorithmException,
                      java.security.InvalidKeyException,
                      javax.crypto.NoSuchPaddingException
Creates a EncryptionUtil class that uses the algorithm specified by the jive proeprty jive.crypto.algorithm, if the property is not specified then "Blowfish/ECB/PKCS5Padding" will be used.

Parameters:
key - Secret key used for encryption/decryption
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
javax.crypto.NoSuchPaddingException

EncryptionUtil

public EncryptionUtil(java.lang.String key,
                      java.lang.String algorithm)
               throws java.security.InvalidKeyException,
                      java.security.NoSuchAlgorithmException,
                      javax.crypto.NoSuchPaddingException
Creates an encryption utility using the specified algorithm

Parameters:
key - Secret key used for encryption/decryption
algorithm - The name of the algorithm (ie "Blowfish" or "DES").
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException
Method Detail

encryptString

public java.lang.String encryptString(java.lang.String plainText)
                               throws javax.crypto.BadPaddingException,
                                      javax.crypto.IllegalBlockSizeException
Encrypts the string using the cipher that this class was initialized with.

Parameters:
plainText - The string to encrypt.
Returns:
The encrypted string in hex format.
Throws:
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException

decryptString

public java.lang.String decryptString(java.lang.String cipherText)
                               throws javax.crypto.IllegalBlockSizeException
Decrypt the string using the cipher that this class was initialized with.

Parameters:
cipherText - String in hex format.
Returns:
Decrypted string.
Throws:
javax.crypto.IllegalBlockSizeException

generateSecretKey

public static java.lang.String generateSecretKey()
Generates a new secret key using the Blowfish algorithm unless there is another specified by the jive property jive.crypto.algorithm.

Returns:
The new secret key.

generateSecretKey

public static java.lang.String generateSecretKey(java.lang.String algorithm)
                                          throws java.security.NoSuchAlgorithmException
Generates a new secret key using the specified algorithm.

Parameters:
algorithm - The encryption algorithm.
Returns:
The new secret key.
Throws:
java.security.NoSuchAlgorithmException - Thrown if the algorithm doesn't exist.

storeNewKeyInProperty

public static java.lang.String storeNewKeyInProperty(java.lang.String jiveProperty)

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.