net.sf.borg.common
Class EncryptionHelper

java.lang.Object
  extended by net.sf.borg.common.EncryptionHelper

public class EncryptionHelper
extends Object

class containing encryption and decryption methods for borg


Constructor Summary
EncryptionHelper(String keyStoreLocation, String keyStorePassword)
          constructor - loads a KeyStore from a file
 
Method Summary
static void createStore(String location, String password)
          create a new JCEKS Key Store
 String decrypt(String cipherText, String keyAlias)
          decrypt a String using a key from the key store
 String encrypt(String clearText, String keyAlias)
          encrypt a String using a key from the key store
 String exportKey(String keyAlias, String keyStorePassword)
          Export the borg key in text form
static void generateKey(String location, String password, String name)
          generate a new encryption key in the key store.
static void importKey(String location, String encodedKey, String keyAlias, String password)
          Import a provided key into a KeyStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptionHelper

public EncryptionHelper(String keyStoreLocation,
                        String keyStorePassword)
                 throws Exception
constructor - loads a KeyStore from a file

Parameters:
keyStoreLocation - - key store location
keyStorePassword - - key store password
Throws:
Exception
Method Detail

createStore

public static void createStore(String location,
                               String password)
                        throws Exception
create a new JCEKS Key Store

Parameters:
location - - location (file) for the key store
password - - key store password
Throws:
Exception

generateKey

public static void generateKey(String location,
                               String password,
                               String name)
                        throws Exception
generate a new encryption key in the key store. the key store password will be used as the key password.

Parameters:
location - - key store location
password - - key store password
name - - key alias
Throws:
Exception

encrypt

public String encrypt(String clearText,
                      String keyAlias)
               throws Exception
encrypt a String using a key from the key store

Parameters:
clearText - - the string to encrypt
keyAlias - - the encryption key alias
Returns:
the encrypted string
Throws:
Exception

decrypt

public String decrypt(String cipherText,
                      String keyAlias)
               throws Exception
decrypt a String using a key from the key store

Parameters:
cipherText - - the string to decrypt
keyAlias - - the decryption key alias
Returns:
the encrypted string
Throws:
Exception

exportKey

public String exportKey(String keyAlias,
                        String keyStorePassword)
                 throws Exception
Export the borg key in text form

Parameters:
keyAlias - the key alias
keyStorePassword - the keystore password
Returns:
the exproted key as a string
Throws:
Exception

importKey

public static void importKey(String location,
                             String encodedKey,
                             String keyAlias,
                             String password)
                      throws Exception
Import a provided key into a KeyStore

Parameters:
location - - the keystore location
encodedKey - - the encoded key to import
keyAlias - - the key alias
password - - the key store password
Throws:
Exception


Generated September 24 2010 by mbb using Apache Ant version 1.7.1 compiled on June 27 2008 and Java version 1.6.0_20 from Sun Microsystems Inc. on Linux i386 2.6.24-28-generic