net.sourceforge.jcetaglib.jsp20
Class ELFunctions

java.lang.Object
  extended bynet.sourceforge.jcetaglib.jsp20.ELFunctions

public class ELFunctions
extends java.lang.Object

JSP 2.0 EL (Expression Language) based JCE functions

Version:
$Id: ELFunctions.java,v 1.1 2004/04/14 09:48:29 hamgert Exp $
Author:
Gert Van Ham, hamgert@users.sourceforge.net, http://jcetaglib.sourceforge.net

Constructor Summary
ELFunctions()
           
 
Method Summary
static java.lang.String decrypt(java.lang.String ciphertext, java.lang.String keyfile, java.lang.String passphrase, java.lang.String algorithm, java.lang.String mode, java.lang.String padding)
          Decrypts a ciphered BASE64 string with a symmetric key
static java.lang.String digest(java.lang.String text, java.lang.String algorithm)
          Creates a digest from a string
static java.lang.String encrypt(java.lang.String text, java.lang.String keyfile, java.lang.String passphrase, java.lang.String algorithm, java.lang.String mode, java.lang.String padding)
          Encrypts a string with a symmetric key and returns the ciphered text in BASE64 format.
static java.lang.String formdigest(java.lang.String text, java.lang.String digest, java.lang.String keyfile, java.lang.String passphrase, java.lang.String algorithm)
          Creates a form digest from a parameter string
static java.lang.String mac(java.lang.String text, java.lang.String keyfile, java.lang.String passphrase, java.lang.String algorithm, java.lang.String macname)
          Create a MAC from a string
static java.lang.String pbedecrypt(java.lang.String ciphertext, java.lang.String passphrase, java.lang.String algorithm)
          Decrypts a ciphered BASE64 string with PBE
static java.lang.String pbeencrypt(java.lang.String text, java.lang.String passphrase, java.lang.String algorithm)
          Encrypts a string with PBE and returns the ciphered text in BASE64 format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ELFunctions

public ELFunctions()
Method Detail

digest

public static java.lang.String digest(java.lang.String text,
                                      java.lang.String algorithm)
                               throws CryptoException
Creates a digest from a string

Parameters:
text - creates the digest from this text
algorithm - the digest algorithm. 'SHA-1' if null
Returns:
the generated digest string in BASE64
Throws:
CryptoException - for all encryption errors

formdigest

public static java.lang.String formdigest(java.lang.String text,
                                          java.lang.String digest,
                                          java.lang.String keyfile,
                                          java.lang.String passphrase,
                                          java.lang.String algorithm)
                                   throws CryptoException,
                                          java.io.IOException
Creates a form digest from a parameter string

Parameters:
text - create the form digest from this parameter string
digest - the digest algorithm. 'SHA-1' if null
keyfile - the symmetric key file
passphrase - the symmetric key file passphrase
algorithm - the symmetric key algorithm
Returns:
form digest in BASE64 format
Throws:
CryptoException - for all encryption errors
java.io.IOException - I/O errors

pbeencrypt

public static java.lang.String pbeencrypt(java.lang.String text,
                                          java.lang.String passphrase,
                                          java.lang.String algorithm)
                                   throws CryptoException
Encrypts a string with PBE and returns the ciphered text in BASE64 format.

Parameters:
text - the plain text
passphrase - the password or passphrase
algorithm - the PBE algorithm. "PBEWithSHAAndIDEA-CBC" if null
Returns:
the cipherstring in BASE64 format
Throws:
CryptoException - for all encryption errors

pbedecrypt

public static java.lang.String pbedecrypt(java.lang.String ciphertext,
                                          java.lang.String passphrase,
                                          java.lang.String algorithm)
                                   throws CryptoException
Decrypts a ciphered BASE64 string with PBE

Parameters:
ciphertext - the text to decipher
passphrase - password or passphrase
algorithm - the PBE algorithm. "PBEWithSHAAndIDEA-CBC" if null
Returns:
the plain text
Throws:
CryptoException - for all encryption errors

encrypt

public static java.lang.String encrypt(java.lang.String text,
                                       java.lang.String keyfile,
                                       java.lang.String passphrase,
                                       java.lang.String algorithm,
                                       java.lang.String mode,
                                       java.lang.String padding)
                                throws CryptoException,
                                       KeystoreException
Encrypts a string with a symmetric key and returns the ciphered text in BASE64 format.

Parameters:
text - the string to encrypt
keyfile - the symmetric key file
passphrase - symmetric key file passphrase
algorithm - symmetric key file algorithm. AES if null
mode - encryption mode. CBC if null
padding - encryption padding. PKCS7Padding if null
Returns:
the encrypted text in BASE64 format
Throws:
CryptoException - encryption errors
KeystoreException - keystore errors

decrypt

public static java.lang.String decrypt(java.lang.String ciphertext,
                                       java.lang.String keyfile,
                                       java.lang.String passphrase,
                                       java.lang.String algorithm,
                                       java.lang.String mode,
                                       java.lang.String padding)
                                throws CryptoException,
                                       KeystoreException
Decrypts a ciphered BASE64 string with a symmetric key

Parameters:
ciphertext - the ciphered BASE64 string
keyfile - the symmetric key file
passphrase - symmetric key file passphrase
algorithm - symmetric key file algorithm. AES if null
mode - encryption mode. CBC if null
padding - encryption padding. PKCS7Padding if null
Returns:
the plaintext
Throws:
CryptoException - encryption errors
KeystoreException - keystore errors

mac

public static java.lang.String mac(java.lang.String text,
                                   java.lang.String keyfile,
                                   java.lang.String passphrase,
                                   java.lang.String algorithm,
                                   java.lang.String macname)
                            throws CryptoException
Create a MAC from a string

Parameters:
text - the text string
keyfile - the symmetric key file location
passphrase - the symmetric key file passphrase
algorithm - the symmetric key file algorithm
macname - MAC algorithm. "HMac-SHA512" if null
Returns:
MAC code
Throws:
CryptoException - MAC errors