com.jaspersoft.jasperserver.api.metadata.common.service.impl
Class Cipherer

java.lang.Object
  extended by com.jaspersoft.jasperserver.api.metadata.common.service.impl.Cipherer

public class Cipherer
extends java.lang.Object

This class provides the utilities of a cryptographic cipher for encryption and decryption.


Constructor Summary
Cipherer()
           
 
Method Summary
 byte[] decode(byte[] content)
          Decodes the given content
 java.lang.String decode(java.lang.String content)
          Dehexifies and decodes the given content * @param content string to be decoded
 java.lang.String decode(java.lang.String content, java.lang.Object booleanValue)
          Decodes the given content if the booleanValue is "true" (case insensitive).
static byte[] dehexify(java.lang.String data)
          Convert a hex string response to a byte array
 byte[] encode(byte[] content)
          Encodes the given content
 java.lang.String encode(java.lang.String content)
          Encodes and hexifies the given content
static java.lang.String hexify(byte[] data)
          Convert a byte array response to a hex string
 void init()
          Initializes the encoder and decoder.
 void init(java.lang.String inCipherTransformation, java.lang.String inKeyAlgorithm, java.lang.String inKeyBytes, boolean isPlainText)
          Initializes the encoder and decoder with the given parameters
static void main(java.lang.String[] args)
          Utility API for password encryption/decryption.
 void setCipherTransformation(java.lang.String cipherTransformation)
           
 void setKeyAlgorithm(java.lang.String keyAlgorithm)
           
 void setKeyBytes(java.lang.String inKeyBytes, boolean isPlainText)
           
static void test(java.lang.String[] args)
          For testing purposes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cipherer

public Cipherer()
Method Detail

init

public void init(java.lang.String inCipherTransformation,
                 java.lang.String inKeyAlgorithm,
                 java.lang.String inKeyBytes,
                 boolean isPlainText)
Initializes the encoder and decoder with the given parameters

Parameters:
cipherTransformation -
keyAlgorithm -
keyBytes -
isPlainText -

init

public void init()
Initializes the encoder and decoder. Note: The vaues of CIPHER_TRANSFORMATION, KEY_BYTES, KEY_ALGORITHM should be set before calling this method, otherwise it will use the default values.


encode

public java.lang.String encode(java.lang.String content)
Encodes and hexifies the given content


encode

public byte[] encode(byte[] content)
Encodes the given content


decode

public java.lang.String decode(java.lang.String content)
Dehexifies and decodes the given content * @param content string to be decoded

Returns:
the decoded content.

decode

public byte[] decode(byte[] content)
Decodes the given content


decode

public java.lang.String decode(java.lang.String content,
                               java.lang.Object booleanValue)
Decodes the given content if the booleanValue is "true" (case insensitive). (Utility Function)

Parameters:
content - string to be decoded
booleanValue - specifies whether content needs to be decoded
Returns:
the decoded content if the booleanValue is "true" (case insensitive). Otherwise it just returns content.

hexify

public static java.lang.String hexify(byte[] data)
Convert a byte array response to a hex string


dehexify

public static byte[] dehexify(java.lang.String data)
Convert a hex string response to a byte array


setKeyBytes

public void setKeyBytes(java.lang.String inKeyBytes,
                        boolean isPlainText)
Parameters:
key_bytes - The KEY_BYTES to set.
isPlainText - Whether key_bytes is plain text or a represantation of byte sequence

setCipherTransformation

public void setCipherTransformation(java.lang.String cipherTransformation)
Parameters:
cipherTransformation - The cipherTransformation to set.

setKeyAlgorithm

public void setKeyAlgorithm(java.lang.String keyAlgorithm)
Parameters:
keyAlgorithm - The keyAlgorithm to set.

test

public static void test(java.lang.String[] args)
For testing purposes

Parameters:
args -

main

public static void main(java.lang.String[] args)
Utility API for password encryption/decryption. Options: -d Dehexifies and Decrypts the given password. -e Encrypts and Hexifys the given password.

Parameters:
args -


Copyright © 2007. All Rights Reserved.