use of com.adaptris.security.exc.VerifyException in project interlok by adaptris.
the class StdSecurityService method verify.
/**
* @see SecurityService#verify(byte[], Alias, Alias)
*/
public Output verify(byte[] payload, Alias receiver, Alias sender) throws AdaptrisSecurityException {
StdOutput target = null;
PrivateKey pk = null;
CertificateHandler them = null;
if (alg == null) {
throw new VerifyException("Decrypt / Verify requires an " + "EncryptionAlgorithm object");
}
pk = getPrivateKey(receiver.getAlias(), receiver.getAliasPassword());
them = createCertificateHandler(getCertificate(sender.getAlias()));
target = decrypt(payload, pk);
if (!verify(target, them)) {
throw new VerifyException("Payload signature could not be verified");
}
return target;
}
use of com.adaptris.security.exc.VerifyException in project interlok by adaptris.
the class StdSecurityService method verify.
private boolean verify(StdOutput target, CertificateHandler ch) throws AdaptrisSecurityException {
boolean rc = false;
try {
if (target.getSignature() != null) {
Signature sig = getSignatureInstance(ch);
sig.initVerify(ch.getPublicKey());
sig.update(target.getDecryptedData(true));
rc = sig.verify(target.getSignature());
} else {
rc = true;
}
} catch (Exception e) {
throw new VerifyException("Exception during signature verfication", e);
}
return rc;
}
use of com.adaptris.security.exc.VerifyException in project interlok by adaptris.
the class StdOutput method split.
/**
* This splits our full data message into it's constituent parts.
* <p>
* This output defines the encrypted payload be a base64 payload containing,
* in order
* <ul>
* <li>InitialisationVector.length</li>
* <li>InitialisationVector</li>
* <li>SessionKey.length</li>
* <li>SessionKey</li>
* <li>Data.length</li>
* <li>Data</li>
* <li>Signature.length</li>
* <li>Signature</li>
* </ul>
* </p>
*
* @param fullMessage the data to be treated as an encrypted message
* @throws AdaptrisSecurityException if an error occurs
*/
void split(byte[] fullMessage) throws AdaptrisSecurityException {
try {
message = fullMessage;
this.split();
} catch (Exception e) {
throw new VerifyException("Cannot parse payload", e);
}
}
Aggregations