public void verifyPostBindingSignature(Document document, PublicKey publicKey)
     throws VerificationException {
   SAML2Signature saml2Signature = new SAML2Signature();
   try {
     if (!saml2Signature.validate(document, publicKey)) {
       throw new VerificationException("Invalid signature on document");
     }
   } catch (ProcessingException e) {
     throw new VerificationException("Error validating signature", e);
   }
 }
Пример #2
0
  public void signDocument(Document samlDocument) throws ProcessingException {
    String signatureMethod = signatureAlgorithm.getXmlSignatureMethod();
    String signatureDigestMethod = signatureAlgorithm.getXmlSignatureDigestMethod();
    SAML2Signature samlSignature = new SAML2Signature();

    if (signatureMethod != null) {
      samlSignature.setSignatureMethod(signatureMethod);
    }

    if (signatureDigestMethod != null) {
      samlSignature.setDigestMethod(signatureDigestMethod);
    }

    Node nextSibling = samlSignature.getNextSiblingOfIssuer(samlDocument);

    samlSignature.setNextSibling(nextSibling);

    if (signingCertificate != null) {
      samlSignature.setX509Certificate(signingCertificate);
    }

    samlSignature.signSAMLDocument(
        samlDocument, signingKeyName, signingKeyPair, canonicalizationMethodType);
  }