Java Code Examples for org.apache.xml.security.transforms.Transforms#addTransform()
The following examples show how to use
org.apache.xml.security.transforms.Transforms#addTransform() .
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: XadesHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public void before() throws TechnicalConnectorException, XMLSecurityException { if (!ArrayUtils.isEmpty(this.specs)) { ObjectContainer container = new ObjectContainer(this.sig.getDocument()); this.sig.appendObject(container); QualifyingPropertiesBuilder qualProperties = new QualifyingPropertiesBuilder(); String xadesSignedId = IdGeneratorFactory.getIdGenerator("uuid").generateId(); XadesSpecification[] arr$ = this.specs; int len$ = arr$.length; for(int i$ = 0; i$ < len$; ++i$) { XadesSpecification spec = arr$[i$]; spec.addOptionalBeforeSignatureParts(qualProperties.getSignedProps(), this.sig, this.signatureCredential, xadesSignedId, this.options); } Document xadesQualPropertiesDocument = qualProperties.buildBeforeSigningAsDocument(); this.xadesQualProperties = (Element)this.sig.getDocument().importNode(xadesQualPropertiesDocument.getDocumentElement(), true); container.appendChild(this.xadesQualProperties); this.sig.addResourceResolver(new DocumentResolver(xadesQualPropertiesDocument)); Transforms xadesTransform = new Transforms(this.sig.getDocument()); xadesTransform.addTransform("http://www.w3.org/2001/10/xml-exc-c14n#"); this.sig.addDocument(ref(qualProperties.getSignedProps().getId()), xadesTransform, (String)SignatureUtils.getOption("digestURI", this.options, "http://www.w3.org/2001/04/xmlenc#sha256"), (String)null, "http://uri.etsi.org/01903#SignedProperties"); } }
Example 2
Source File: XadesHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public void before() throws TechnicalConnectorException, XMLSecurityException { if (!ArrayUtils.isEmpty(this.specs)) { ObjectContainer container = new ObjectContainer(this.sig.getDocument()); this.sig.appendObject(container); QualifyingPropertiesBuilder qualProperties = new QualifyingPropertiesBuilder(); String xadesSignedId = IdGeneratorFactory.getIdGenerator("uuid").generateId(); XadesSpecification[] arr$ = this.specs; int len$ = arr$.length; for(int i$ = 0; i$ < len$; ++i$) { XadesSpecification spec = arr$[i$]; spec.addOptionalBeforeSignatureParts(qualProperties.getSignedProps(), this.sig, this.signatureCredential, xadesSignedId, this.options); } Document xadesQualPropertiesDocument = qualProperties.buildBeforeSigningAsDocument(); this.xadesQualProperties = (Element)this.sig.getDocument().importNode(xadesQualPropertiesDocument.getDocumentElement(), true); container.appendChild(this.xadesQualProperties); this.sig.addResourceResolver(new DocumentResolver(xadesQualPropertiesDocument)); Transforms xadesTransform = new Transforms(this.sig.getDocument()); xadesTransform.addTransform("http://www.w3.org/2001/10/xml-exc-c14n#"); this.sig.addDocument(ref(qualProperties.getSignedProps().getId()), xadesTransform, (String)SignatureUtils.getOption("digestURI", this.options, "http://www.w3.org/2001/04/xmlenc#sha256"), (String)null, "http://uri.etsi.org/01903#SignedProperties"); } }
Example 3
Source File: XadesHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public void before() throws TechnicalConnectorException, XMLSecurityException { if (!ArrayUtils.isEmpty(this.specs)) { ObjectContainer container = new ObjectContainer(this.sig.getDocument()); this.sig.appendObject(container); QualifyingPropertiesBuilder qualProperties = new QualifyingPropertiesBuilder(); String xadesSignedId = IdGeneratorFactory.getIdGenerator("uuid").generateId(); XadesSpecification[] arr$ = this.specs; int len$ = arr$.length; for(int i$ = 0; i$ < len$; ++i$) { XadesSpecification spec = arr$[i$]; spec.addOptionalBeforeSignatureParts(qualProperties.getSignedProps(), this.sig, this.signatureCredential, xadesSignedId, this.options); } Document xadesQualPropertiesDocument = qualProperties.buildBeforeSigningAsDocument(); this.xadesQualProperties = (Element)this.sig.getDocument().importNode(xadesQualPropertiesDocument.getDocumentElement(), true); container.appendChild(this.xadesQualProperties); this.sig.addResourceResolver(new DocumentResolver(xadesQualPropertiesDocument)); Transforms xadesTransform = new Transforms(this.sig.getDocument()); xadesTransform.addTransform("http://www.w3.org/2001/10/xml-exc-c14n#"); this.sig.addDocument(ref(qualProperties.getSignedProps().getId()), xadesTransform, (String)SignatureUtils.getOption("digestURI", this.options, "http://www.w3.org/2001/04/xmlenc#sha256"), (String)null, "http://uri.etsi.org/01903#SignedProperties"); } }
Example 4
Source File: XadesHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public void before() throws TechnicalConnectorException, XMLSecurityException { if (!ArrayUtils.isEmpty(this.specs)) { ObjectContainer container = new ObjectContainer(this.sig.getDocument()); this.sig.appendObject(container); QualifyingPropertiesBuilder qualProperties = new QualifyingPropertiesBuilder(); String xadesSignedId = IdGeneratorFactory.getIdGenerator("uuid").generateId(); XadesSpecification[] arr$ = this.specs; int len$ = arr$.length; for(int i$ = 0; i$ < len$; ++i$) { XadesSpecification spec = arr$[i$]; spec.addOptionalBeforeSignatureParts(qualProperties.getSignedProps(), this.sig, this.signatureCredential, xadesSignedId, this.options); } Document xadesQualPropertiesDocument = qualProperties.buildBeforeSigningAsDocument(); this.xadesQualProperties = (Element)this.sig.getDocument().importNode(xadesQualPropertiesDocument.getDocumentElement(), true); container.appendChild(this.xadesQualProperties); this.sig.addResourceResolver(new DocumentResolver(xadesQualPropertiesDocument)); Transforms xadesTransform = new Transforms(this.sig.getDocument()); xadesTransform.addTransform("http://www.w3.org/2001/10/xml-exc-c14n#"); this.sig.addDocument(ref(qualProperties.getSignedProps().getId()), xadesTransform, (String)SignatureUtils.getOption("digestURI", this.options, "http://www.w3.org/2001/04/xmlenc#sha256"), (String)null, "http://uri.etsi.org/01903#SignedProperties"); } }
Example 5
Source File: XadesHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public void before() throws TechnicalConnectorException, XMLSecurityException { if (!ArrayUtils.isEmpty(this.specs)) { ObjectContainer container = new ObjectContainer(this.sig.getDocument()); this.sig.appendObject(container); QualifyingPropertiesBuilder qualProperties = new QualifyingPropertiesBuilder(); String xadesSignedId = IdGeneratorFactory.getIdGenerator("uuid").generateId(); XadesSpecification[] arr$ = this.specs; int len$ = arr$.length; for(int i$ = 0; i$ < len$; ++i$) { XadesSpecification spec = arr$[i$]; spec.addOptionalBeforeSignatureParts(qualProperties.getSignedProps(), this.sig, this.signatureCredential, xadesSignedId, this.options); } Document xadesQualPropertiesDocument = qualProperties.buildBeforeSigningAsDocument(); this.xadesQualProperties = (Element)this.sig.getDocument().importNode(xadesQualPropertiesDocument.getDocumentElement(), true); container.appendChild(this.xadesQualProperties); this.sig.addResourceResolver(new DocumentResolver(xadesQualPropertiesDocument)); Transforms xadesTransform = new Transforms(this.sig.getDocument()); xadesTransform.addTransform("http://www.w3.org/2001/10/xml-exc-c14n#"); this.sig.addDocument(ref(qualProperties.getSignedProps().getId()), xadesTransform, (String)SignatureUtils.getOption("digestURI", this.options, "http://www.w3.org/2001/04/xmlenc#sha256"), (String)null, "http://uri.etsi.org/01903#SignedProperties"); } }
Example 6
Source File: XmlSigOutInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private XMLSignature prepareEnvelopingSignature(Document doc, String id, String referenceId, String sigAlgo, String digestAlgo) throws Exception { Element docEl = doc.getDocumentElement(); Document newDoc = DOMUtils.createDocument(); doc.removeChild(docEl); newDoc.adoptNode(docEl); Element object = newDoc.createElementNS(Constants.SignatureSpecNS, "ds:Object"); object.appendChild(docEl); docEl.setAttributeNS(null, "Id", id); docEl.setIdAttributeNS(null, "Id", true); XMLSignature sig = new XMLSignature(newDoc, "", sigAlgo); newDoc.appendChild(sig.getElement()); sig.getElement().appendChild(object); Transforms transforms = new Transforms(newDoc); transforms.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS); sig.addDocument(referenceId, transforms, digestAlgo); return sig; }
Example 7
Source File: XmlSigOutInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private XMLSignature prepareDetachedSignature(Document doc, String id, String referenceId, String sigAlgo, String digestAlgo) throws Exception { Element docEl = doc.getDocumentElement(); Document newDoc = DOMUtils.createDocument(); doc.removeChild(docEl); newDoc.adoptNode(docEl); docEl.setAttributeNS(null, "Id", id); docEl.setIdAttributeNS(null, "Id", true); Element root = newDoc.createElementNS(envelopeQName.getNamespaceURI(), envelopeQName.getPrefix() + ":" + envelopeQName.getLocalPart()); root.appendChild(docEl); newDoc.appendChild(root); XMLSignature sig = new XMLSignature(newDoc, "", sigAlgo); root.appendChild(sig.getElement()); Transforms transforms = new Transforms(newDoc); transforms.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS); sig.addDocument(referenceId, transforms, digestAlgo); return sig; }
Example 8
Source File: XmlSigOutInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private XMLSignature prepareEnvelopedSignature(Document doc, String id, String referenceURI, String sigAlgo, String digestAlgo) throws Exception { doc.getDocumentElement().setAttributeNS(null, "Id", id); doc.getDocumentElement().setIdAttributeNS(null, "Id", true); XMLSignature sig = new XMLSignature(doc, "", sigAlgo); doc.getDocumentElement().appendChild(sig.getElement()); Transforms transforms = new Transforms(doc); transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE); transforms.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS); sig.addDocument(referenceURI, transforms, digestAlgo); return sig; }
Example 9
Source File: XmlSignatureBuilder.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static Transforms transforms(List<String> tranformerList, Document doc) throws TransformationException { Transforms baseDocTransform = new Transforms(doc); Iterator i$ = tranformerList.iterator(); while(i$.hasNext()) { String transform = (String)i$.next(); baseDocTransform.addTransform(transform); } return baseDocTransform; }
Example 10
Source File: XmlSignatureBuilder.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static Transforms transforms(List<String> tranformerList, Document doc) throws TransformationException { Transforms baseDocTransform = new Transforms(doc); Iterator i$ = tranformerList.iterator(); while(i$.hasNext()) { String transform = (String)i$.next(); baseDocTransform.addTransform(transform); } return baseDocTransform; }
Example 11
Source File: XmlSignatureBuilder.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static Transforms transforms(List<String> tranformerList, Document doc) throws TransformationException { Transforms baseDocTransform = new Transforms(doc); Iterator i$ = tranformerList.iterator(); while(i$.hasNext()) { String transform = (String)i$.next(); baseDocTransform.addTransform(transform); } return baseDocTransform; }
Example 12
Source File: XmlSignatureBuilder.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static Transforms transforms(List<String> tranformerList, Document doc) throws TransformationException { Transforms baseDocTransform = new Transforms(doc); Iterator i$ = tranformerList.iterator(); while(i$.hasNext()) { String transform = (String)i$.next(); baseDocTransform.addTransform(transform); } return baseDocTransform; }
Example 13
Source File: XmlSignatureBuilder.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static Transforms transforms(List<String> tranformerList, Document doc) throws TransformationException { Transforms baseDocTransform = new Transforms(doc); Iterator i$ = tranformerList.iterator(); while(i$.hasNext()) { String transform = (String)i$.next(); baseDocTransform.addTransform(transform); } return baseDocTransform; }
Example 14
Source File: URIContentReference.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public void createReference(XMLSignature signature) { try { Transforms dsigTransforms = new Transforms(signature.getDocument()); for (String transform : transforms) { dsigTransforms.addTransform(transform); } signature.addDocument(referenceID, dsigTransforms, digestAlgorithm); } catch (Exception e) { log.error("Error while adding content reference", e); } }
Example 15
Source File: TransformUtils.java From xades4j with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates a Transforms element for a given set of algorithms * @param document the target XML document * @param algorithmsParametersMarshaller algorithm parameters marshaller * @param algorithms algorithms * @return the Transforms * @throws UnsupportedAlgorithmException if an algorithm is not supported */ public static Transforms createTransforms( Document document, AlgorithmsParametersMarshallingProvider algorithmsParametersMarshaller, Iterable<Algorithm> algorithms) throws UnsupportedAlgorithmException { Transforms transforms = new Transforms(document); for (Algorithm t : algorithms) { try { List<Node> params = algorithmsParametersMarshaller.marshalParameters(t, document); if (null == params) { transforms.addTransform(t.getUri()); } else { transforms.addTransform(t.getUri(), DOMHelper.nodeList(params)); } } catch (TransformationException ex) { throw new UnsupportedAlgorithmException( "Unsupported transform on XML Signature provider", t.getUri(), ex); } } return transforms; }