public static Reference newReference( String uri , List<Transform> transforms , String type , String id , byte digestValue[] , SignatureConfig signatureConfig) throws XMLSignatureException { // the references appear in the package signature or the package object // so we can use the default digest algorithm String digestMethodUri = signatureConfig.getDigestMethodUri(); XMLSignatureFactory sigFac = signatureConfig.getSignatureFactory(); DigestMethod digestMethod; try { digestMethod = sigFac.newDigestMethod(digestMethodUri, null); } catch (GeneralSecurityException e) { throw new XMLSignatureException("unknown digest method uri: "+digestMethodUri, e); } Reference reference; if (digestValue == null) { reference = sigFac.newReference(uri, digestMethod, transforms, type, id); } else { reference = sigFac.newReference(uri, digestMethod, transforms, type, id, digestValue); } return reference; } }
XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM"); Reference ref = fac.newReference("", fac.newDigestMethod(DigestMethod.SHA1, null), Collections.singletonList(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)), null, null); SignedInfo si = fac.newSignedInfo(fac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec) null), fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null), Collections.singletonList(ref));
public DigestMethod getDigestMethod() throws GeneralSecurityException { if(digestMethod == null) { digestMethod = getXMLSignatureFactory().newDigestMethod(DigestMethod.SHA1, null); } return digestMethod; }
protected DigestMethod getDigestMethod() throws GeneralSecurityException { if (this.digestMethod == null) { this.digestMethod = getXMLSignatureFactory().newDigestMethod(DigestMethod.SHA1, null); } return this.digestMethod; }
@Nonnull @OverrideOnDemand protected DigestMethod createDigestMethod (@Nonnull final XMLSignatureFactory aSignatureFactory) throws Exception { return aSignatureFactory.newDigestMethod (DigestMethod.SHA1, (DigestMethodParameterSpec) null); }
private static Reference generateCustomReference(XMLSignatureFactory fac, String uri, String type, String id) throws GeneralSecurityException { DigestMethod dsDigestMethod = fac.newDigestMethod(DigestMethod.SHA1, null); return fac.newReference(uri, dsDigestMethod, null, type, id); }
private static Reference generateCustomReference(XMLSignatureFactory fac, String uri, String type, String id) throws GeneralSecurityException { DigestMethod dsDigestMethod = fac.newDigestMethod(DigestMethod.SHA1, null); return fac.newReference(uri, dsDigestMethod, null, type, id); }
public void setDigestMethod(String method) throws GeneralSecurityException { this.digestMethod = getXMLSignatureFactory().newDigestMethod(method, null); }
private Reference initReference(XMLSignatureFactory fac) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { List transformers = new ArrayList(); transformers.add(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)); String dm = map.getProperty(SIGNATURE_OPTION_DIGEST_METHOD); if (dm == null) { dm = DigestMethod.SHA1; } Reference ref = fac.newReference("", fac.newDigestMethod(dm, null), transformers, null, null); return ref; }
protected List<Reference> createReference(Document doc, XmlSignatureConfig config) throws Exception { Transform envelopedTransform = xmlSignatureFactory.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null); DigestMethod sha1DigMethod = xmlSignatureFactory.newDigestMethod(DigestMethod.SHA1, null); Reference ref = xmlSignatureFactory.newReference("", sha1DigMethod, Collections.singletonList(envelopedTransform), null, null); return Collections.singletonList(ref); }
private static Reference initReference(XMLSignatureFactory fac) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { List transformers = new ArrayList(); transformers.add(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)); Reference ref = fac.newReference("", fac.newDigestMethod(DigestMethod.SHA1, null), transformers, null, null); return ref; }
@Nonnull @OverrideOnDemand protected DigestMethod createDigestMethod () throws Exception { return m_aSignatureFactory.newDigestMethod (getDigestMethod (), (DigestMethodParameterSpec) null); }
private void addManifestObject(XMLSignatureFactory signatureFactory, Document document, String signatureId, List<Reference> references, List<XMLObject> objects) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { Manifest manifest = constructManifest(signatureFactory, document); String objectId = "idPackageObject"; // really has to be this value. List<XMLStructure> objectContent = new LinkedList<XMLStructure>(); objectContent.add(manifest); addSignatureTime(signatureFactory, document, signatureId, objectContent); objects.add(signatureFactory.newXMLObject(objectContent, objectId, null, null)); DigestMethod digestMethod = signatureFactory.newDigestMethod(this.digestAlgo.getXmlAlgoId(), null); Reference reference = signatureFactory.newReference("#" + objectId, digestMethod, null, "http://www.w3.org/2000/09/xmldsig#Object", null); references.add(reference); }
private static Reference generateContentReference(XMLSignatureFactory fac, XmlSignatureAppearance sap, String referenceId) throws GeneralSecurityException { DigestMethod digestMethodSHA1 = fac.newDigestMethod(DigestMethod.SHA1, null); List<Transform> transforms = new ArrayList<Transform>(); transforms.add(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)); // Create the Reference XpathConstructor xpathConstructor = sap.getXpathConstructor(); if (xpathConstructor != null && xpathConstructor.getXpathExpression().length() > 0) { XPathFilter2ParameterSpec xpath2Spec = new XPathFilter2ParameterSpec(Collections.singletonList(new XPathType(xpathConstructor.getXpathExpression(), XPathType.Filter.INTERSECT))); transforms.add(fac.newTransform(Transform.XPATH2, xpath2Spec)); } return fac.newReference("", digestMethodSHA1, transforms, null, referenceId); }
private static Reference generateContentReference(XMLSignatureFactory fac, XmlSignatureAppearance sap, String referenceId) throws GeneralSecurityException { DigestMethod digestMethodSHA1 = fac.newDigestMethod(DigestMethod.SHA1, null); List<Transform> transforms = new ArrayList<Transform>(); transforms.add(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)); // Create the Reference XpathConstructor xpathConstructor = sap.getXpathConstructor(); if (xpathConstructor != null && xpathConstructor.getXpathExpression().length() > 0) { XPathFilter2ParameterSpec xpath2Spec = new XPathFilter2ParameterSpec(Collections.singletonList(new XPathType(xpathConstructor.getXpathExpression(), XPathType.Filter.INTERSECT))); transforms.add(fac.newTransform(Transform.XPATH2, xpath2Spec)); } return fac.newReference("", digestMethodSHA1, transforms, null, referenceId); }
public Element sign(X509Certificate cert, PrivateKey privKey, boolean alwaysIncludeCert) throws SAMLException { //Check if the signature is already calculated if ( signedAssertion != null) { return signedAssertion; } //Calculate the enveloped signature try { XMLSignatureFactory fac = WSSPolicyConsumerImpl.getInstance().getSignatureFactory(); return sign(fac.newDigestMethod(DigestMethod.SHA1,null),SignatureMethod.RSA_SHA1, cert,privKey, alwaysIncludeCert); } catch (Exception ex) { // log here throw new SAMLException(ex); } }
public Element sign(X509Certificate cert, PrivateKey privKey) throws SAMLException { //Check if the signature is already calculated if ( signedAssertion != null) { return signedAssertion; } //Calculate the enveloped signature try { XMLSignatureFactory fac = WSSPolicyConsumerImpl.getInstance().getSignatureFactory(); return sign(fac.newDigestMethod(DigestMethod.SHA1,null),SignatureMethod.RSA_SHA1, cert,privKey); } catch (Exception ex) { // log here throw new SAMLException(ex); } }
public Element sign(X509Certificate cert, PrivateKey privKey) throws SAMLException { //Check if the signature is already calculated if ( signedAssertion != null) { return signedAssertion; } //Calculate the enveloped signature try { XMLSignatureFactory fac = WSSPolicyConsumerImpl.getInstance ().getSignatureFactory (); return sign (fac.newDigestMethod (DigestMethod.SHA1,null),SignatureMethod.RSA_SHA1, cert,privKey); } catch (Exception ex) { // log here throw new SAMLException (ex); } }
public RequestSigner ( final Configuration configuration ) throws Exception { this.fac = XMLSignatureFactory.getInstance ( "DOM" ); this.md = this.fac.newDigestMethod ( configuration.getDigestMethod (), null ); this.kif = this.fac.getKeyInfoFactory (); this.t = this.fac.newTransform ( Transform.ENVELOPED, (TransformParameterSpec)null ); this.ref = this.fac.newReference ( "", this.md, Collections.singletonList ( this.t ), null, null ); this.cm = this.fac.newCanonicalizationMethod ( CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec)null ); }
public RequestSigner ( final Configuration configuration ) throws Exception { this.fac = XMLSignatureFactory.getInstance ( "DOM" ); this.md = this.fac.newDigestMethod ( configuration.getDigestMethod (), null ); this.kif = this.fac.getKeyInfoFactory (); this.t = this.fac.newTransform ( Transform.ENVELOPED, (TransformParameterSpec)null ); this.ref = this.fac.newReference ( "", this.md, Collections.singletonList ( this.t ), null, null ); this.cm = this.fac.newCanonicalizationMethod ( CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec)null ); }