lumis.portal.crypto
Class SymmetricCipher

Package class diagram package SymmetricCipher
java.lang.Object
  extended by lumis.portal.crypto.AbstractCipher
      extended by lumis.portal.crypto.SymmetricCipher
All Implemented Interfaces:
ICipher, ICipherSpi

public class SymmetricCipher
extends AbstractCipher

Generic cipher implementation, based on symmetric ciphers available in the Java Cryptography Architecture (JCA). Also includes a Mac in the encrypted value for integrity check.

Configuration elements:

Since:
5.5.0
See Also:
javax.crypto

Constructor Summary
SymmetricCipher()
           
 
Method Summary
 byte[] decrypt(byte[] encryptedValue)
          Decrypts an array of bytes.
 byte[] encrypt(byte[] plainText)
          Encrypts an array of bytes.
protected  SecretKey generateKey(int bitLength, String algorithm, String provider)
          Generates a key.
protected  Cipher getCipher()
          Returns a new Cipher instance, according to current configurations.
protected  Mac getMac()
          Returns a new Mac instance, according to current configurations.
 void init(Node configuration)
          This method is called only once and before any other method are called.
 
Methods inherited from class lumis.portal.crypto.AbstractCipher
decrypt, encrypt, getStringCharset, getUseURLSafeBase64Variant
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymmetricCipher

public SymmetricCipher()
Method Detail

init

public void init(Node configuration)
          throws PortalException
Description copied from interface: ICipherSpi
This method is called only once and before any other method are called. This allows the cipher to initialize itself and read any custom configuration.

Throws:
PortalException

generateKey

protected SecretKey generateKey(int bitLength,
                                String algorithm,
                                String provider)
                         throws GeneralSecurityException
Generates a key.

Parameters:
bitLength - the length of the key, in bits.
algorithm - the algorithm the key will be used for.
provider - the provider of the algorithm.
Returns:
the key.
Throws:
GeneralSecurityException
Since:
5.5.0

getCipher

protected Cipher getCipher()
                    throws GeneralSecurityException
Returns a new Cipher instance, according to current configurations.

Returns:
the cipher.
Throws:
GeneralSecurityException
Since:
5.5.0
See Also:
Cipher.getInstance(String, String)

getMac

protected Mac getMac()
              throws GeneralSecurityException
Returns a new Mac instance, according to current configurations.

Returns:
the mac.
Throws:
GeneralSecurityException
Since:
5.5.0
See Also:
Mac.getInstance(String, String)

decrypt

public byte[] decrypt(byte[] encryptedValue)
               throws InvalidEncryptedValueException
Description copied from interface: ICipher
Decrypts an array of bytes.

Parameters:
encryptedValue - the encrypted value.
Returns:
the value decrypted.
Throws:
InvalidEncryptedValueException - if value is incompatible with this cipher (probably was not encrypted by it or is corrupted).

encrypt

public byte[] encrypt(byte[] plainText)
Description copied from interface: ICipher
Encrypts an array of bytes.

Parameters:
plainText - the original value.
Returns:
the encrypted value.


Lumisportal  5.5.0.091130 - Copyright © 2001-2007, Lumis. All Rights Reserved.