lumis.portal.crypto
Class MessageDigestCipher

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

public class MessageDigestCipher
extends AbstractCipher

Uses a MessageDigest algorithm to encrypt data.

In this cipher's configuration, the value of algorithm element is used to specify the MessageDigest algorithm; and the provider element may optionally be used to specify the MessageDigest provider.

Since:
5.5.0
See Also:
MessageDigest

Constructor Summary
MessageDigestCipher()
           
 
Method Summary
protected  MessageDigest createMessageDigest()
          Returns a new MessageDigest instance based on this cipher's getAlgorithm() and getProvider().
 byte[] decrypt(byte[] value)
          Decrypts an array of bytes.
 byte[] encrypt(byte[] value)
          Encrypts an array of bytes.
protected  String getAlgorithm()
          Returns the message digest algorithm to be used.
protected  String getProvider()
          Returns the message digest provider to be used.
protected  boolean getUseURLSafeBase64Variant()
          Indicates if a URL safe Base64 variant is to be used when encoding bytes to String.
 void init(Node configuration)
          This method is called only once and before any other method are called.
protected  void setAlgorithm(String algorithm)
          Sets the message digest algorithm to be used.
protected  void setProvider(String provider)
          Sets the message digest provider to be used.
 
Methods inherited from class lumis.portal.crypto.AbstractCipher
decrypt, encrypt, getStringCharset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageDigestCipher

public MessageDigestCipher()
Method Detail

getUseURLSafeBase64Variant

protected boolean getUseURLSafeBase64Variant()
Description copied from class: AbstractCipher
Indicates if a URL safe Base64 variant is to be used when encoding bytes to String.

The default value is true. This method may be overridden to change it.

Overrides:
getUseURLSafeBase64Variant in class AbstractCipher
Returns:
true if a URL safe variant is to be used, false if the standard Base64 is to be used.

getAlgorithm

protected String getAlgorithm()
Returns the message digest algorithm to be used.

Returns:
the algorithm.
Since:
5.5.0

setAlgorithm

protected void setAlgorithm(String algorithm)
Sets the message digest algorithm to be used.

Parameters:
algorithm - the algorithm.
Since:
5.5.0

getProvider

protected String getProvider()
Returns the message digest provider to be used.

Returns:
the provider, or null if the default provider search is to be used.
Since:
5.5.0

setProvider

protected void setProvider(String provider)
Sets the message digest provider to be used.

Parameters:
provider - the provider, or null if the default provider search is to be used.
Since:
5.5.0

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

createMessageDigest

protected MessageDigest createMessageDigest()
Returns a new MessageDigest instance based on this cipher's getAlgorithm() and getProvider().

Returns:
the message digest.
Since:
5.5.0
See Also:
MessageDigest.getInstance(String, String)

encrypt

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

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

decrypt

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

Parameters:
value - the encrypted value.
Returns:
the value decrypted.


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.