private void signAssertion(Assertion assertion, Credential credential) throws SecurityException, MarshallingException, SignatureException { SignatureBuilder signatureBuilder = (SignatureBuilder) builderFactory .getBuilder(Signature.DEFAULT_ELEMENT_NAME); Signature signature = signatureBuilder.buildObject(); signature.setSigningCredential(credential); SecurityHelper.prepareSignatureParams(signature, credential, null, null); assertion.setSignature(signature); Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(assertion); marshaller.marshall(assertion); Signer.signObject(signature); }
@Override public void marshellAndSign() throws IdentityProviderException { try { MarshallerFactory marshallerFactory = Configuration.getMarshallerFactory(); Marshaller marshaller = marshallerFactory.getMarshaller(assertion); signedAssertion = marshaller.marshall(assertion); Signer.signObjects(signatureList); } catch (MarshallingException e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } catch (Exception e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } }
/** * Signs a single XMLObject. * * @param signature the signature to computer the signature on * @throws SignatureException thrown if there is an error computing the signature */ public static void signObject(Signature signature) throws SignatureException { Logger log = getLogger(); try { XMLSignature xmlSignature = ((SignatureImpl) signature).getXMLSignature(); if (xmlSignature == null) { log.error("Unable to compute signature, Signature XMLObject does not have the XMLSignature " + "created during marshalling."); throw new SignatureException("XMLObject does not have an XMLSignature instance, unable to compute signature"); } log.debug("Computing signature over XMLSignature object"); xmlSignature.sign(SecurityHelper.extractSigningKey(signature.getSigningCredential())); } catch (XMLSecurityException e) { log.error("An error occured computing the digital signature", e); throw new SignatureException("Signature computation error", e); } }
@Override public void marshellAndSign() throws IdentityProviderException { try { MarshallerFactory marshallerFactory = Configuration.getMarshallerFactory(); Marshaller marshaller = marshallerFactory.getMarshaller(assertion); signedAssertion = marshaller.marshall(assertion); Signer.signObjects(signatureList); } catch (MarshallingException e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } catch (Exception e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } }
/** * Signs a single XMLObject. * * @param signature the signature to computer the signature on * @throws SignatureException thrown if there is an error computing the signature */ public static void signObject(Signature signature) throws SignatureException { Logger log = getLogger(); try { XMLSignature xmlSignature = ((SignatureImpl) signature).getXMLSignature(); if (xmlSignature == null) { log.error("Unable to compute signature, Signature XMLObject does not have the XMLSignature " + "created during marshalling."); throw new SignatureException("XMLObject does not have an XMLSignature instance, unable to compute signature"); } log.debug("Computing signature over XMLSignature object"); xmlSignature.sign(SecurityHelper.extractSigningKey(signature.getSigningCredential())); } catch (XMLSecurityException e) { log.error("An error occured computing the digital signature", e); throw new SignatureException("Signature computation error", e); } }
@Override public void marshellAndSign() throws IdentityProviderException { try { MarshallerFactory marshallerFactory = Configuration.getMarshallerFactory(); Marshaller marshaller = marshallerFactory.getMarshaller(assertion); signedAssertion = marshaller.marshall(assertion); Signer.signObjects(signatureList); } catch (MarshallingException e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } catch (Exception e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } }
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(assertion); marshaller.marshall(assertion); Signer.signObject(signature); return assertion;
@Override public void marshellAndSign() throws IdentityProviderException { try { MarshallerFactory marshallerFactory = Configuration.getMarshallerFactory(); Marshaller marshaller = marshallerFactory.getMarshaller(assertion); signedAssertion = marshaller.marshall(assertion); Signer.signObjects(signatureList); } catch (MarshallingException e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } catch (Exception e) { log.debug(e); throw new IdentityProviderException("errorMarshellingOrSigning", e); } }
/** * Signs the given XMLObject in the order provided. * * @param xmlObjects an orderded list of XMLObject to be signed * @throws SignatureException thrown if there is an error computing the signature */ public static void signObjects(List<Signature> xmlObjects) throws SignatureException { for (Signature xmlObject : xmlObjects) { signObject(xmlObject); } }
/** * Sign the SAML AuthnRequest message * * @param logoutRequest * @param signatureAlgorithm * @param cred * @return * @throws SSOAgentException */ public static LogoutRequest setSignature(LogoutRequest logoutRequest, String signatureAlgorithm, X509Credential cred) throws SSOAgentException { try { Signature signature = setSignatureRaw(signatureAlgorithm,cred); logoutRequest.setSignature(signature); List<Signature> signatureList = new ArrayList<Signature>(); signatureList.add(signature); // Marshall and Sign MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory(); Marshaller marshaller = marshallerFactory.getMarshaller(logoutRequest); marshaller.marshall(logoutRequest); org.apache.xml.security.Init.init(); Signer.signObjects(signatureList); return logoutRequest; } catch (Exception e) { throw new SSOAgentException("Error while signing the Logout Request message", e); } }
/** * Signs the given XMLObject in the order provided. * * @param xmlObjects an orderded list of XMLObject to be signed * @throws SignatureException thrown if there is an error computing the signature */ public static void signObjects(List<Signature> xmlObjects) throws SignatureException { for (Signature xmlObject : xmlObjects) { signObject(xmlObject); } }
/** * Add signature to any singable XML object. * @param xmlObject Singable xml object. * @param signatureAlgorithm Signature algorithm to be used. * @param cred X509 Credentials. * @param <T> Singable XML object with signature. * @return Singable XML object with signature. * @throws SSOAgentException If error occurred. */ public static <T extends SignableXMLObject> T setSignatureValue(T xmlObject, String signatureAlgorithm, X509Credential cred) throws SSOAgentException { try { Signature signature = setSignatureRaw(signatureAlgorithm, cred); xmlObject.setSignature(signature); List<Signature> signatureList = new ArrayList<>(); signatureList.add(signature); // Marshall and Sign MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory(); Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject); marshaller.marshall(xmlObject); org.apache.xml.security.Init.init(); Signer.signObjects(signatureList); return xmlObject; } catch (Exception e) { throw new SSOAgentException("Error while signing the SAML Request message", e); } }
private static void signObject(Signature signature) throws WSSecurityException { if (signature != null) { try { Signer.signObject(signature); } catch (SignatureException ex) { throw new WSSecurityException("Error signing a SAML assertion", ex); } } }
/** * Sign the SAML AuthnRequest message * * @param authnRequest * @param signatureAlgorithm * @param cred * @return * @throws org.wso2.carbon.identity.sso.agent.SSOAgentException */ public static AuthnRequest setSignature(AuthnRequest authnRequest, String signatureAlgorithm, X509Credential cred) throws SSOAgentException { doBootstrap(); try { Signature signature = setSignatureRaw(signatureAlgorithm,cred); authnRequest.setSignature(signature); List<Signature> signatureList = new ArrayList<Signature>(); signatureList.add(signature); // Marshall and Sign MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory(); Marshaller marshaller = marshallerFactory.getMarshaller(authnRequest); marshaller.marshall(authnRequest); org.apache.xml.security.Init.init(); Signer.signObjects(signatureList); return authnRequest; } catch (Exception e) { throw new SSOAgentException("Error while signing the SAML Request message", e); } }
private static void signObject(Signature signature) throws WSSecurityException { if (signature != null) { try { Signer.signObject(signature); } catch (SignatureException ex) { throw new WSSecurityException("Error signing a SAML assertion", ex); } } }
Signer.signObjects(signatureList); return logoutReq;
Signer.signObject(saml2.getSignature()); } catch (SignatureException ex) { throw new Exception("Error signing a SAML assertion", ex);
Signer.signObjects(signatureList); return logoutReq;
Signer.signObject(signature); } catch (SignatureException e) { log.debug("Error signing SAML Assertion. An error occurred while signing SAML Assertion with alias "
Signer.signObjects(signatureList); return authnRequest;