org.drools.core.util
Class KeyStoreHelper

java.lang.Object
  extended by org.drools.core.util.KeyStoreHelper

public class KeyStoreHelper
extends Object

A helper class to deal with the key store and signing process during Serialisation This class will read and use the following system properties: drools.serialization.sign = drools.serialization.private.keyStoreURL = drools.serialization.private.keyStorePwd = drools.serialization.private.keyAlias = drools.serialization.private.keyPwd = drools.serialization.public.keyStoreURL = drools.serialization.public.keyStorePwd =


Field Summary
static String PROP_PUB_KS_PWD
           
static String PROP_PUB_KS_URL
           
static String PROP_PVT_ALIAS
           
static String PROP_PVT_KS_PWD
           
static String PROP_PVT_KS_URL
           
static String PROP_PVT_PWD
           
static String PROP_SIGN
           
 
Constructor Summary
KeyStoreHelper()
          Creates a KeyStoreHelper and initialises the KeyStore, by loading its entries.
 
Method Summary
 boolean checkDataWithPublicKey(String publicKeyAlias, byte[] data, byte[] signature)
          Checks the given byte[] data against the signature, using the public key with which this helper was initialised and the algorithm MD5 with RSA.
 KeyStore getPubKeyStore()
           
 char[] getPubKeyStorePwd()
           
 URL getPubKeyStoreURL()
           
 String getPvtKeyAlias()
           
 char[] getPvtKeyPassword()
           
 KeyStore getPvtKeyStore()
           
 char[] getPvtKeyStorePwd()
           
 URL getPvtKeyStoreURL()
           
 boolean isSigned()
           
 byte[] signDataWithPrivateKey(byte[] data)
          Generates the signature for the given byte[] using MD5 with RSA algorithm and the private key with which this helper was initialised.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_SIGN

public static final String PROP_SIGN
See Also:
Constant Field Values

PROP_PVT_KS_URL

public static final String PROP_PVT_KS_URL
See Also:
Constant Field Values

PROP_PVT_KS_PWD

public static final String PROP_PVT_KS_PWD
See Also:
Constant Field Values

PROP_PVT_ALIAS

public static final String PROP_PVT_ALIAS
See Also:
Constant Field Values

PROP_PVT_PWD

public static final String PROP_PVT_PWD
See Also:
Constant Field Values

PROP_PUB_KS_URL

public static final String PROP_PUB_KS_URL
See Also:
Constant Field Values

PROP_PUB_KS_PWD

public static final String PROP_PUB_KS_PWD
See Also:
Constant Field Values
Constructor Detail

KeyStoreHelper

public KeyStoreHelper()
Creates a KeyStoreHelper and initialises the KeyStore, by loading its entries.

Throws:
RuntimeDroolsException - in case any error happens when initialising and loading the keystore.
Method Detail

signDataWithPrivateKey

public byte[] signDataWithPrivateKey(byte[] data)
                              throws UnrecoverableKeyException,
                                     KeyStoreException,
                                     NoSuchAlgorithmException,
                                     InvalidKeyException,
                                     SignatureException
Generates the signature for the given byte[] using MD5 with RSA algorithm and the private key with which this helper was initialised.

Parameters:
data - the byte[] of data to be signed
Returns:
the signature, encrypted with the private key
Throws:
UnrecoverableKeyException
KeyStoreException
NoSuchAlgorithmException
InvalidKeyException
SignatureException

checkDataWithPublicKey

public boolean checkDataWithPublicKey(String publicKeyAlias,
                                      byte[] data,
                                      byte[] signature)
                               throws KeyStoreException,
                                      NoSuchAlgorithmException,
                                      InvalidKeyException,
                                      SignatureException
Checks the given byte[] data against the signature, using the public key with which this helper was initialised and the algorithm MD5 with RSA.

Parameters:
data - the original data that was signed
signature - the provided signature
Returns:
true in case the signature matches, false otherwise.
Throws:
KeyStoreException
NoSuchAlgorithmException
InvalidKeyException
SignatureException

isSigned

public boolean isSigned()

getPvtKeyStoreURL

public URL getPvtKeyStoreURL()

getPvtKeyStorePwd

public char[] getPvtKeyStorePwd()

getPvtKeyAlias

public String getPvtKeyAlias()

getPvtKeyPassword

public char[] getPvtKeyPassword()

getPubKeyStoreURL

public URL getPubKeyStoreURL()

getPubKeyStorePwd

public char[] getPubKeyStorePwd()

getPvtKeyStore

public KeyStore getPvtKeyStore()

getPubKeyStore

public KeyStore getPubKeyStore()


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.