@SuppressWarnings("unchecked") static <T extends SAMLObject> T build(@Nullable final QName key) { return (T) builder(key).buildObject(); }
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 SamlException("failed to validate a signature because no signature exists"); } try { signatureProfileValidator.validate(signature); SignatureValidator.validate(signature, validationCredential); } catch (SignatureException e) { throw new SamlException("failed to validate a signature", e); } }
/** * Signs the specified {@link SignableSAMLObject} with the specified {@link Credential} and * {@code signatureAlgorithm}. */ static void sign(SignableSAMLObject signableObj, Credential signingCredential, String signatureAlgorithm) { requireNonNull(signableObj, "signableObj"); requireNonNull(signingCredential, "signingCredential"); requireNonNull(signatureAlgorithm, "signatureAlgorithm"); final Signature signature = signatureBuilder.buildObject(); signature.setSignatureAlgorithm(signatureAlgorithm); signature.setSigningCredential(signingCredential); signature.setCanonicalizationAlgorithm(ALGO_ID_C14N_EXCL_OMIT_COMMENTS); try { signature.setKeyInfo(keyInfoGenerator.generate(signingCredential)); } catch (SecurityException e) { throw new SamlException("failed to create a key info of signing credential", e); } signableObj.setSignature(signature); serialize(signableObj); try { Signer.signObject(signature); } catch (SignatureException e) { throw new SamlException("failed to sign a SAML object", e); } }
public Signature getSignature() throws WSSecurityException { if (samlObject instanceof SignableSAMLObject) { return ((SignableSAMLObject)samlObject).getSignature(); } return null; }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { StatusCode statusCode = (StatusCode) parentSAMLObject; if (childSAMLObject instanceof StatusCode) { statusCode.setStatusCode((StatusCode) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } }
/** {@inheritDoc} */ public Element marshall(XMLObject xmlObject, Document document) throws MarshallingException { if (xmlObject instanceof SignableSAMLObject) { SAMLObjectSupport.declareNonVisibleNamespaces((SignableSAMLObject) xmlObject); } return super.marshall(xmlObject, document); }
/** {@inheritDoc} */ public int getMinorVersion() { return version.getMinorVersion(); }
/** {@inheritDoc} */ public int getMajorVersion(){ return version.getMajorVersion(); }
private static Collection<NameIDFormat> buildNameIdFormatElements(Collection<String> nameIds) { final SAMLObjectBuilder<NameIDFormat> builder = builder(NameIDFormat.DEFAULT_ELEMENT_NAME); final Collection<NameIDFormat> formats = new ArrayList<>(); for (final String value : nameIds) { final NameIDFormat nameIdFormat = builder.buildObject(); nameIdFormat.setFormat(value); formats.add(nameIdFormat); } return formats; }
/** * Method isSigned returns the signed of this SamlAssertionWrapper object. * * @return the signed (type boolean) of this SamlAssertionWrapper object. */ public boolean isSigned() { if (samlObject instanceof SignableSAMLObject && (((SignableSAMLObject)samlObject).isSigned() || ((SignableSAMLObject)samlObject).getSignature() != null)) { return true; } return false; }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { StatusCode statusCode = (StatusCode) parentSAMLObject; if (childSAMLObject instanceof StatusCode) { statusCode.setStatusCode((StatusCode) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } } }
/** {@inheritDoc} */ public Element marshall(XMLObject xmlObject, Element parentElement) throws MarshallingException { if (xmlObject instanceof SignableSAMLObject) { SAMLObjectSupport.declareNonVisibleNamespaces((SignableSAMLObject) xmlObject); } return super.marshall(xmlObject, parentElement); }
public static Subject createSubject(NameID nameId) { Subject subject = subjectBuilder.buildObject(); subject.setNameID(nameId); return subject; }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException { SubjectConfirmation sc = (SubjectConfirmation) parentObject; if (childObject instanceof SubjectConfirmationData) { sc.setSubjectConfirmationData((SubjectConfirmationData) childObject); } else { super.processChildElement(parentObject, childObject); } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { ResponseAbstractType response = (ResponseAbstractType) parentSAMLObject; if (childSAMLObject instanceof Signature) { response.setSignature((Signature) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { SubjectStatement statement = (SubjectStatement) parentSAMLObject; if (childSAMLObject instanceof Subject) { statement.setSubject((Subject) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { SubjectQuery query = (SubjectQuery) parentSAMLObject; if (childSAMLObject instanceof Subject) { query.setSubject((Subject) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException { AuthnStatement authnStatement = (AuthnStatement) parentObject; if (childObject instanceof SubjectLocality) { authnStatement.setSubjectLocality((SubjectLocality) childObject); } else if (childObject instanceof AuthnContext) { authnStatement.setAuthnContext((AuthnContext) childObject); } else { super.processChildElement(parentObject, childObject); } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException { XACMLAuthzDecisionStatementType xacmlauthzdecisionstatement = (XACMLAuthzDecisionStatementType) parentObject; if (childObject instanceof RequestType) { xacmlauthzdecisionstatement.setRequest((RequestType) childObject); } else if (childObject instanceof ResponseType) { xacmlauthzdecisionstatement.setResponse((ResponseType) childObject); } else { super.processChildElement(parentObject, childObject); } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { Request request = (Request) parentSAMLObject; if (childSAMLObject instanceof Issuer) { request.setIssuer((Issuer) childSAMLObject); } else if (childSAMLObject instanceof IDPList) { request.setIDPList((IDPList) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } }