org.apache.fulcrum.pbe
Class PBEServiceImpl

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.fulcrum.pbe.PBEServiceImpl
All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, PBEService

public class PBEServiceImpl
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements PBEService, org.apache.avalon.framework.configuration.Configurable

Encapsulates an PBE (Password Based Encryption) functionality from the JCE (Java Crypto Extension).

Author:
Siegfried Goeschl

Constructor Summary
PBEServiceImpl()
          Constructor
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 char[] createPassword()
          Create a password based on the pre-defined seed.
 char[] createPassword(char[] seed)
          Create a password based on the supplied seed.
 void decrypt(Object source, Object target, char[] password)
          Copies from a source to a target object using decrpytion.
 String decryptString(String cipherText, char[] password)
          Decrypts an encrypted string into the plain text.
 void encrypt(Object source, Object target, char[] password)
          Copies from a source to a target object using encryption.
 String encryptString(String plainText, char[] password)
          Encrypts a string into a hex string.
 InputStream getInputStream(InputStream is, char[] password)
          Creates a decrypting input stream.
 OutputStream getOutputStream(OutputStream os, char[] password)
          Creates an encrypting output stream.
 InputStream getSmartInputStream(InputStream is, char[] password)
          Creates a smart decrypting input stream.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PBEServiceImpl

public PBEServiceImpl()
Constructor

Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
Configurable.configure(org.apache.avalon.framework.configuration.Configuration)

createPassword

public char[] createPassword()
                      throws Exception
Description copied from interface: PBEService
Create a password based on the pre-defined seed.

Specified by:
createPassword in interface PBEService
Returns:
the password
Throws:
Exception - the password creation failed
See Also:
PBEService.createPassword()

createPassword

public char[] createPassword(char[] seed)
                      throws Exception
Description copied from interface: PBEService
Create a password based on the supplied seed.

Specified by:
createPassword in interface PBEService
Parameters:
seed - the seed value for the password generation
Returns:
the password
Throws:
Exception - the password creation failed
See Also:
PBEService.createPassword(char[])

decryptString

public String decryptString(String cipherText,
                            char[] password)
                     throws GeneralSecurityException,
                            IOException
Description copied from interface: PBEService
Decrypts an encrypted string into the plain text. The encrypted string must be a hex string created by encryptString.

Specified by:
decryptString in interface PBEService
Parameters:
cipherText - the encrypted text to be decrypted
password - the password for decryption
Returns:
the decrypted string
Throws:
GeneralSecurityException - accessing the JCE failed
IOException - an IOException occured during processing
See Also:
PBEService.decryptString(java.lang.String, char[])

encryptString

public String encryptString(String plainText,
                            char[] password)
                     throws GeneralSecurityException,
                            IOException
Description copied from interface: PBEService
Encrypts a string into a hex string.

Specified by:
encryptString in interface PBEService
Parameters:
plainText - the plain text to be encrypted
password - the password for encryption
Returns:
the encrypted string
Throws:
GeneralSecurityException - accessing the JCE failed
IOException - an IOException occured during processing
See Also:
PBEService.encryptString(java.lang.String, char[])

getInputStream

public InputStream getInputStream(InputStream is,
                                  char[] password)
                           throws GeneralSecurityException,
                                  IOException
Description copied from interface: PBEService
Creates a decrypting input stream.

Specified by:
getInputStream in interface PBEService
Parameters:
is - the input stream to be wrapped
password - the password to be used
Returns:
an decrypting input stream
Throws:
GeneralSecurityException - accessing the JCE failed
IOException - an IOException occured during processing
See Also:
PBEService.getInputStream(java.io.InputStream, char[])

getSmartInputStream

public InputStream getSmartInputStream(InputStream is,
                                       char[] password)
                                throws GeneralSecurityException,
                                       IOException
Description copied from interface: PBEService
Creates a smart decrypting input stream.

Specified by:
getSmartInputStream in interface PBEService
Parameters:
is - the input stream to be wrapped
password - the password to be used
Returns:
an decrypting input stream
Throws:
GeneralSecurityException - accessing the JCE failed
IOException - an IOException occured during processing
See Also:
PBEService.getSmartInputStream(java.io.InputStream, char[])

getOutputStream

public OutputStream getOutputStream(OutputStream os,
                                    char[] password)
                             throws GeneralSecurityException,
                                    IOException
Description copied from interface: PBEService
Creates an encrypting output stream.

Specified by:
getOutputStream in interface PBEService
Parameters:
os - the output stream to be wrapped
password - the password to be used
Returns:
an decrypting input stream
Throws:
GeneralSecurityException - accessing the JCE failed
IOException - an IOException occured during processing
See Also:
PBEService.getOutputStream(java.io.OutputStream, char[])

decrypt

public void decrypt(Object source,
                    Object target,
                    char[] password)
             throws GeneralSecurityException,
                    IOException
Description copied from interface: PBEService
Copies from a source to a target object using decrpytion. For he souce object the following data types are supported For target object the following data types are supported

Specified by:
decrypt in interface PBEService
Parameters:
source - the source object
target - the target object
password - the password to use for decryption
Throws:
GeneralSecurityException - accessing the JCE failed
IOException - an IOException occured during processing
See Also:
PBEService.decrypt(java.lang.Object, java.lang.Object, char[])

encrypt

public void encrypt(Object source,
                    Object target,
                    char[] password)
             throws GeneralSecurityException,
                    IOException
Description copied from interface: PBEService
Copies from a source to a target object using encryption. For he souce object the following data types are supported For target object the following data types are supported

Specified by:
encrypt in interface PBEService
Parameters:
source - the source object
target - the target object
password - the password to use for encryption
Throws:
GeneralSecurityException - accessing the JCE failed
IOException - an IOException occured during processing
See Also:
PBEService.encrypt(java.lang.Object, java.lang.Object, char[])


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.