}
}
private static void checkSignature(Header _header,
byte[] sessionbuff) {
KeyStoreHelper helper = new KeyStoreHelper();
boolean signed = _header.hasSignature();
if ( helper.isSigned() != signed ) {
throw new RuntimeDroolsException( "This environment is configured to work with " +
(helper.isSigned() ? "signed" : "unsigned") +
" serialized objects, but the given object is " +
(signed ? "signed" : "unsigned") + ". Deserialization aborted." );
}
if ( signed ) {
if ( helper.getPubKeyStore() == null ) {
throw new RuntimeDroolsException( "The session was serialized with a signature. Please configure a public keystore with the public key to check the signature. Deserialization aborted." );
}
try {
if ( !helper.checkDataWithPublicKey( _header.getSignature().getKeyAlias(),
sessionbuff,
_header.getSignature().getSignature().toByteArray() ) ) {
throw new RuntimeDroolsException(
"Signature does not match serialized package. This is a security violation. Deserialisation aborted." );
}