Search in sources :

Example 1 with AuthServerException

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);
    }
}
Also used : CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) KeyStoreException(java.security.KeyStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) AuthServerException(org.openecard.addons.cg.ex.AuthServerException)

Aggregations

IOException (java.io.IOException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 AuthServerException (org.openecard.addons.cg.ex.AuthServerException)1