org.opensaml.xmlsec.signature.support.SignatureValidator Java Examples
The following examples show how to use
org.opensaml.xmlsec.signature.support.SignatureValidator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsumerServlet.java From OpenSAML-ref-project-demo-v3 with Apache License 2.0 | 6 votes |
private void verifyAssertionSignature(Assertion assertion) { if (!assertion.isSigned()) { throw new RuntimeException("The SAML Assertion was not signed"); } try { SAMLSignatureProfileValidator profileValidator = new SAMLSignatureProfileValidator(); profileValidator.validate(assertion.getSignature()); SignatureValidator.validate(assertion.getSignature(), IDPCredentials.getCredential()); logger.info("SAML Assertion signature verified"); } catch (SignatureException e) { e.printStackTrace(); } }
Example #2
Source File: ValidatorUtils.java From saml-client with MIT License | 6 votes |
/** * Validate boolean. * * @param signature the signature * @param credentials the credentials * @return the boolean */ private static boolean validate(Signature signature, List<Credential> credentials) { if (signature == null) { return false; } // It's fine if any of the credentials match the signature return credentials .stream() .anyMatch( credential -> { try { SignatureValidator.validate(signature, credential); return true; } catch (SignatureException ex) { return false; } }); }
Example #3
Source File: SamlMessageUtil.java From armeria with Apache License 2.0 | 6 votes |
static void validateSignature(Credential validationCredential, SignableSAMLObject signableObj) { requireNonNull(validationCredential, "validationCredential"); requireNonNull(signableObj, "signableObj"); // Skip signature validation if the object is not signed. if (!signableObj.isSigned()) { return; } final Signature signature = signableObj.getSignature(); if (signature == null) { throw new InvalidSamlRequestException("failed to validate a signature because no signature exists"); } try { signatureProfileValidator.validate(signature); SignatureValidator.validate(signature, validationCredential); } catch (SignatureException e) { throw new InvalidSamlRequestException("failed to validate a signature", e); } }
Example #4
Source File: AuthenticationHandlerSAML2.java From sling-whiteboard with Apache License 2.0 | 5 votes |
private void verifyAssertionSignature(final Assertion assertion) { if (!assertion.isSigned()) { logger.error("Halting"); throw new RuntimeException("The SAML Assertion was not signed!"); } try { SAMLSignatureProfileValidator profileValidator = new SAMLSignatureProfileValidator(); profileValidator.validate(assertion.getSignature()); // use IDP Cert to verify signature SignatureValidator.validate(assertion.getSignature(), this.getIdpVerificationCert()); logger.info("SAML Assertion signature verified"); } catch (SignatureException e) { throw new RuntimeException("SAML Assertion signature problem", e); } }