Class KeyStoreHelper


  • public class KeyStoreHelper
    extends java.lang.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 =

    • Method Detail

      • reInit

        public static void reInit()
      • signDataWithPrivateKey

        public byte[] signDataWithPrivateKey​(byte[] data)
                                      throws java.security.UnrecoverableKeyException,
                                             java.security.KeyStoreException,
                                             java.security.NoSuchAlgorithmException,
                                             java.security.InvalidKeyException,
                                             java.security.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:
        java.security.UnrecoverableKeyException
        java.security.KeyStoreException
        java.security.NoSuchAlgorithmException
        java.security.InvalidKeyException
        java.security.SignatureException
      • checkDataWithPublicKey

        public boolean checkDataWithPublicKey​(java.lang.String publicKeyAlias,
                                              byte[] data,
                                              byte[] signature)
                                       throws java.security.KeyStoreException,
                                              java.security.NoSuchAlgorithmException,
                                              java.security.InvalidKeyException,
                                              java.security.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:
        java.security.KeyStoreException
        java.security.NoSuchAlgorithmException
        java.security.InvalidKeyException
        java.security.SignatureException
      • getPasswordKey

        public java.lang.String getPasswordKey​(java.lang.String pwdKeyAlias,
                                               char[] pwdKeyPassword)
      • isSigned

        public boolean isSigned()
      • getPvtKeyStoreURL

        public java.net.URL getPvtKeyStoreURL()
      • getPvtKeyStorePwd

        public char[] getPvtKeyStorePwd()
      • getPvtKeyAlias

        public java.lang.String getPvtKeyAlias()
      • getPvtKeyPassword

        public char[] getPvtKeyPassword()
      • getPubKeyStoreURL

        public java.net.URL getPubKeyStoreURL()
      • getPubKeyStorePwd

        public char[] getPubKeyStorePwd()
      • getPvtKeyStore

        public java.security.KeyStore getPvtKeyStore()
      • getPubKeyStore

        public java.security.KeyStore getPubKeyStore()