use of org.openecard.addons.cg.ex.AuthServerException in project open-ecard by ecsec.
the class ChipGateway method validateSignature.
private void validateSignature(HelloResponseType helloResp) throws AuthServerException, InvalidRedirectUrlException {
try {
byte[] challenge = helloReq.getChallenge();
byte[] signature = helloResp.getSignature();
// prevent null value
signature = signature == null ? new byte[0] : signature;
SignatureVerifier sigVerif = new SignatureVerifier(challenge);
sigVerif.validate(signature);
} catch (IOException ex) {
String msg = "Failed to load ChipGateway truststore from bundled truststore file.";
LOG.error(msg, ex);
throw new RuntimeException(msg, ex);
} catch (KeyStoreException ex) {
String msg = "ChipGateway truststore is inoperable.";
LOG.error(msg, ex);
throw new RuntimeException(msg, ex);
} catch (NoSuchAlgorithmException ex) {
String msg = "Invalid algorithm used during signature verification.";
LOG.error(msg, ex);
throw new RuntimeException(msg, ex);
} catch (CertificateException ex) {
String msg = "Invalid certificate used in signature.";
LOG.warn(msg, ex);
throw new RuntimeException(msg, ex);
} catch (SignatureInvalid ex) {
throw new AuthServerException(token.finalizeErrorAddress(ResultMinor.COMMUNICATION_ERROR), SIGNATURE_INVALID, ex);
}
}
Aggregations