本文整理汇总了Java中javax.xml.crypto.dsig.XMLObject类的典型用法代码示例。如果您正苦于以下问题:Java XMLObject类的具体用法?Java XMLObject怎么用?Java XMLObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLObject类属于javax.xml.crypto.dsig包,在下文中一共展示了XMLObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getReferencedSameDocumentObjects
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
protected List<XMLObject> getReferencedSameDocumentObjects(List<Reference> relevantReferences, List<XMLObject> relevantObjects) {
List<XMLObject> referencedObjects = new ArrayList<XMLObject>(1);
for (Reference ref : relevantReferences) {
String refUri = getSameDocumentReferenceUri(ref);
if (refUri == null) {
continue;
}
XMLObject referencedOb = getReferencedObject(relevantObjects, refUri);
if (referencedOb != null) {
referencedObjects.add(referencedOb);
continue;
}
// content could also be indirectly referenced via manifest
addManifestReferencedObjects(relevantObjects, referencedObjects, refUri);
}
return referencedObjects;
}
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:DefaultXmlSignature2Message.java
示例2: addManifestReferencedObjects
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void addManifestReferencedObjects(List<XMLObject> allObjects, List<XMLObject> referencedObjects, String manifestId) {
Manifest manifest = getReferencedManifest(allObjects, manifestId);
if (manifest == null) {
return;
}
for (Reference manifestRef : (List<Reference>) manifest.getReferences()) {
String manifestRefUri = getSameDocumentReferenceUri(manifestRef);
if (manifestRefUri == null) {
continue;
}
XMLObject manifestReferencedOb = getReferencedObject(allObjects, manifestRefUri);
if (manifestReferencedOb != null) {
referencedObjects.add(manifestReferencedOb);
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:DefaultXmlSignature2Message.java
示例3: getObjects
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
protected List<? extends XMLObject> getObjects(XmlSignatureProperties.Input input, XmlSignatureProperties.Output properties)
throws Exception { //NOPMD
if (SignatureType.enveloped == input.getSignatureType() || SignatureType.detached == input.getSignatureType()) {
if (properties == null || properties.getObjects() == null) {
return Collections.emptyList();
}
return properties.getObjects();
}
// enveloping signature --> add additional object
final String objectId = getConfiguration().getContentObjectId();
LOG.debug("Object Content Id {}", objectId);
XMLObject obj = createXMLObject(input.getSignatureFactory(), input.getMessageBodyNode(), objectId);
if (properties == null || properties.getObjects() == null || properties.getObjects().isEmpty()) {
return Collections.singletonList(obj);
}
List<XMLObject> result = new ArrayList<XMLObject>(properties.getObjects().size() + 1);
result.add(obj);
result.addAll(properties.getObjects());
return result;
}
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:XmlSignerProcessor.java
示例4: get
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
@Override
public Output get(Input input) throws Exception {
Transform transform = input.getSignatureFactory().newTransform(CanonicalizationMethod.INCLUSIVE, (TransformParameterSpec) null);
Reference ref = input.getSignatureFactory().newReference("#propertiesObject",
input.getSignatureFactory().newDigestMethod(input.getContentDigestAlgorithm(), null), Collections.singletonList(transform),
null, null);
String doc2 = "<ts:timestamp xmlns:ts=\"http:/timestamp\">" + System.currentTimeMillis() + "</ts:timestamp>";
InputStream is = new ByteArrayInputStream(doc2.getBytes("UTF-8"));
Document doc = XmlSignatureHelper.newDocumentBuilder(Boolean.TRUE).parse(is);
DOMStructure structure = new DOMStructure(doc.getDocumentElement());
SignatureProperty prop = input.getSignatureFactory().newSignatureProperty(Collections.singletonList(structure),
input.getSignatureId(), "property");
SignatureProperties properties = input.getSignatureFactory().newSignatureProperties(Collections.singletonList(prop), "properties");
XMLObject propertiesObject = input.getSignatureFactory().newXMLObject(Collections.singletonList(properties), "propertiesObject",
null, null);
XmlSignatureProperties.Output result = new Output();
result.setReferences(Collections.singletonList(ref));
result.setObjects(Collections.singletonList(propertiesObject));
return result;
}
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:TimestampProperty.java
示例5: test_create_signature_enveloping
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
private void test_create_signature_enveloping(
SignatureMethod sm, DigestMethod dm, KeyInfo ki, Key signingKey, KeySelector ks
) throws Exception {
// create reference
Reference ref = fac.newReference("#DSig.Object_1", dm, null,
XMLObject.TYPE, null);
// create SignedInfo
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
Document doc = db.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
webElem.appendChild(text);
XMLObject obj = fac.newXMLObject(Collections.singletonList
(new DOMStructure(webElem)), "DSig.Object_1", "text/xml", null);
// create XMLSignature
XMLSignature sig = fac.newXMLSignature
(si, ki, Collections.singletonList(obj), null, null);
DOMSignContext dsc = new DOMSignContext(signingKey, doc);
dsc.setDefaultNamespacePrefix("dsig");
sig.sign(dsc);
TestUtils.validateSecurityOrEncryptionElement(doc.getDocumentElement());
// XMLUtils.outputDOM(doc.getDocumentElement(), System.out);
DOMValidateContext dvc = new DOMValidateContext
(ks, doc.getDocumentElement());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:40,代码来源:HMACSignatureAlgorithmTest.java
示例6: getNodeForMessageBodyInEnvelopingCase
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
protected Node getNodeForMessageBodyInEnvelopingCase(Input input) throws Exception { //NOPMD
Node node;
List<Reference> relevantReferences = getReferencesForMessageMapping(input);
List<XMLObject> relevantObjects = getObjectsForMessageMapping(input);
DOMStructure domStruc = getDomStructureForMessageBody(relevantReferences, relevantObjects);
node = domStruc.getNode();
return node;
}
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:DefaultXmlSignature2Message.java
示例7: getDomStructureForMessageBody
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
/**
* Returns the DOM structure which is transformed to a byte array and set to
* the camel message body.
*
* @param relevantReferences
* input from method
* {@link #getReferencesForMessageMapping(ReferencesAndObjects)}
* @param relevantObjects
* input from method
* {@link #getObjectsForMessageMapping(ReferencesAndObjects)}
* @return dom structure
* @throws Exception
* if an error occurs
*/
protected DOMStructure getDomStructureForMessageBody(List<Reference> relevantReferences, List<XMLObject> relevantObjects)
throws Exception { //NOPMD
List<XMLObject> referencedObjects = getReferencedSameDocumentObjects(relevantReferences, relevantObjects);
if (referencedObjects.isEmpty()) {
throw new XmlSignatureException(
String.format("Unsupported XML signature document: Content object not found in the enveloping XML signature."));
}
if (referencedObjects.size() > 1) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < referencedObjects.size(); i++) {
XMLObject xmlOb = referencedObjects.get(i);
sb.append(xmlOb.getId());
if (i < referencedObjects.size() - 1) {
sb.append(", ");
}
}
throw new XmlSignatureException(String.format(
"Unsupported XML signature document: More than one content objects found. Object IDs: %s", sb.toString()));
}
@SuppressWarnings("unchecked")
List<XMLStructure> structures = referencedObjects.get(0).getContent();
if (structures.size() == 0) {
throw new XmlSignatureException(
"Unsupported XML signature: XML signature is not enveloping; content not found in XML signature: structure list is empty.");
}
if (structures.size() > 1) {
throw new XmlSignatureException("Unsupported XML signature: more than one structure elements in referenced content object.");
}
XMLStructure structure = structures.get(0);
// only dom currently supported
DOMStructure domStruc = (DOMStructure) structure;
return domStruc;
}
开发者ID:HydAu,项目名称:Camel,代码行数:52,代码来源:DefaultXmlSignature2Message.java
示例8: getReferencedManifest
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
protected Manifest getReferencedManifest(List<XMLObject> objects, String id) {
for (XMLObject xo : objects) {
@SuppressWarnings("unchecked")
List<XMLStructure> content = xo.getContent();
for (XMLStructure xs : content) {
if (xs instanceof Manifest) {
Manifest man = (Manifest) xs;
if (id.equals(man.getId())) {
return man;
}
}
}
}
return null;
}
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:DefaultXmlSignature2Message.java
示例9: getReferencedObject
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
protected XMLObject getReferencedObject(List<XMLObject> objects, String id) {
for (XMLObject ob : objects) {
if (id.equals(ob.getId())) {
return ob;
}
}
return null;
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:DefaultXmlSignature2Message.java
示例10: preSign
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId,
List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
DigestMethod digestMethod = signatureFactory.newDigestMethod(this.digestAlgo.getXmlAlgoId(), null);
List<Transform> transforms = new LinkedList<Transform>();
Map<String, String> xpathNamespaceMap = new HashMap<String, String>();
xpathNamespaceMap.put("ds", "http://www.w3.org/2000/09/xmldsig#");
// XPath v1 - slow...
// Transform envelopedTransform = signatureFactory.newTransform(
// CanonicalizationMethod.XPATH, new XPathFilterParameterSpec(
// "not(ancestor-or-self::ds:Signature)",
// xpathNamespaceMap));
// XPath v2 - fast...
List<XPathType> types = new ArrayList<XPathType>(1);
types.add(new XPathType("/descendant::*[name()='ds:Signature']", XPathType.Filter.SUBTRACT, xpathNamespaceMap));
Transform envelopedTransform = signatureFactory.newTransform(CanonicalizationMethod.XPATH2,
new XPathFilter2ParameterSpec(types));
transforms.add(envelopedTransform);
Transform exclusiveTransform = signatureFactory.newTransform(CanonicalizationMethod.EXCLUSIVE,
(TransformParameterSpec) null);
transforms.add(exclusiveTransform);
Reference reference = signatureFactory.newReference("", digestMethod, transforms, null, this.dsReferenceId);
references.add(reference);
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:32,代码来源:CoSignatureFacet.java
示例11: preSign
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId,
List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
DigestMethod digestMethod = signatureFactory.newDigestMethod(this.digestAlgo.getXmlAlgoId(), null);
List<Transform> transforms = new LinkedList<Transform>();
Transform envelopedTransform = signatureFactory.newTransform(CanonicalizationMethod.ENVELOPED,
(TransformParameterSpec) null);
transforms.add(envelopedTransform);
Transform exclusiveTransform = signatureFactory.newTransform(CanonicalizationMethod.EXCLUSIVE,
(TransformParameterSpec) null);
transforms.add(exclusiveTransform);
Reference reference = signatureFactory.newReference("", digestMethod, transforms, null, null);
references.add(reference);
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:18,代码来源:EnvelopedSignatureFacet.java
示例12: preSign
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId,
List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
LOG.debug("pre sign");
Element dateElement = document.createElementNS("", "dc:date");
dateElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:dc", "http://purl.org/dc/elements/1.1/");
DateTime dateTime = new DateTime(DateTimeZone.UTC);
DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
String now = fmt.print(dateTime);
now = now.substring(0, now.indexOf("Z"));
LOG.debug("now: " + now);
dateElement.setTextContent(now);
String signaturePropertyId = "sign-prop-" + UUID.randomUUID().toString();
List<XMLStructure> signaturePropertyContent = new LinkedList<XMLStructure>();
signaturePropertyContent.add(new DOMStructure(dateElement));
SignatureProperty signatureProperty = signatureFactory.newSignatureProperty(signaturePropertyContent,
"#" + signatureId, signaturePropertyId);
List<XMLStructure> objectContent = new LinkedList<XMLStructure>();
List<SignatureProperty> signaturePropertiesContent = new LinkedList<SignatureProperty>();
signaturePropertiesContent.add(signatureProperty);
SignatureProperties signatureProperties = signatureFactory.newSignatureProperties(signaturePropertiesContent,
null);
objectContent.add(signatureProperties);
objects.add(signatureFactory.newXMLObject(objectContent, null, null, null));
DigestMethod digestMethod = signatureFactory.newDigestMethod(this.digestAlgo.getXmlAlgoId(), null);
Reference reference = signatureFactory.newReference("#" + signaturePropertyId, digestMethod);
references.add(reference);
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:34,代码来源:OpenOfficeSignatureFacet.java
示例13: preSign
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId,
List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
LOG.debug("pre sign");
addManifestObject(signatureFactory, document, signatureId, references, objects);
addSignatureInfo(signatureFactory, document, signatureId, references, objects);
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:9,代码来源:OOXMLSignatureFacet.java
示例14: addManifestObject
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
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);
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:18,代码来源:OOXMLSignatureFacet.java
示例15: addSignatureInfo
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
private void addSignatureInfo(XMLSignatureFactory signatureFactory, Document document, String signatureId,
List<Reference> references, List<XMLObject> objects)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
List<XMLStructure> objectContent = new LinkedList<XMLStructure>();
Element signatureInfoElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureInfoV1");
signatureInfoElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", OFFICE_DIGSIG_NS);
Element manifestHashAlgorithmElement = document.createElementNS(OFFICE_DIGSIG_NS, "ManifestHashAlgorithm");
manifestHashAlgorithmElement.setTextContent("http://www.w3.org/2000/09/xmldsig#sha1");
signatureInfoElement.appendChild(manifestHashAlgorithmElement);
List<XMLStructure> signatureInfoContent = new LinkedList<XMLStructure>();
signatureInfoContent.add(new DOMStructure(signatureInfoElement));
SignatureProperty signatureInfoSignatureProperty = signatureFactory.newSignatureProperty(signatureInfoContent,
"#" + signatureId, "idOfficeV1Details");
List<SignatureProperty> signaturePropertyContent = new LinkedList<SignatureProperty>();
signaturePropertyContent.add(signatureInfoSignatureProperty);
SignatureProperties signatureProperties = signatureFactory.newSignatureProperties(signaturePropertyContent,
null);
objectContent.add(signatureProperties);
String objectId = "idOfficeObject";
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);
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:32,代码来源:OOXMLSignatureFacet.java
示例16: findObject
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private XMLObject findObject(XMLSignature xmlSignature, String objectId) {
List<XMLObject> objects = xmlSignature.getObjects();
for (XMLObject object : objects) {
if (objectId.equals(object.getId())) {
LOG.debug("Found \"" + objectId + "\" ds:object");
return object;
}
}
return null;
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:13,代码来源:OOXMLSignatureVerifier.java
示例17: preSign
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId,
List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
DigestMethod digestMethod = signatureFactory.newDigestMethod(DigestMethod.SHA1, null);
for (String uri : this.uris) {
Reference reference = signatureFactory.newReference(uri, digestMethod);
references.add(reference);
}
}
开发者ID:e-Contract,项目名称:eid-applet,代码行数:10,代码来源:SignatureTestFacet.java
示例18: get
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
@Override
public Output get(Input input) throws Exception { //NOPMD
XmlSignatureProperties.Output result = new Output();
if (!isAddSignedSignatureProperties() && !isAddSignedDataObjectPropeties()) {
LOG.debug("XAdES signature properties are empty. Therefore no XAdES element will be added to the signature.");
return result;
}
String signedPropertiesId = "_" + UUID.randomUUID().toString();
List<Transform> transforms = Collections.emptyList();
Reference ref = input.getSignatureFactory().newReference("#" + signedPropertiesId,
input.getSignatureFactory().newDigestMethod(input.getContentDigestAlgorithm(), null), transforms,
"http://uri.etsi.org/01903#SignedProperties", null);
Node parent = input.getParent();
Document doc;
if (Node.DOCUMENT_NODE == parent.getNodeType()) {
doc = (Document) parent; // enveloping
} else {
doc = parent.getOwnerDocument(); // enveloped
}
Element qualifyingProperties = createElement("QualifyingProperties", doc, input);
setIdAttributeFromHeader(XmlSignatureConstants.HEADER_XADES_QUALIFYING_PROPERTIES_ID, qualifyingProperties, input);
String signatureId = input.getSignatureId();
if (signatureId == null || signatureId.isEmpty()) {
LOG.debug("No signature Id configured. Therefore a value is generated.");
// generate one
signatureId = "_" + UUID.randomUUID().toString();
// and set to output
result.setSignatureId(signatureId);
}
setAttribute(qualifyingProperties, "Target", "#" + signatureId);
Element signedProperties = createElement("SignedProperties", doc, input);
qualifyingProperties.appendChild(signedProperties);
setAttribute(signedProperties, "Id", signedPropertiesId);
signedProperties.setIdAttribute("Id", true);
addSignedSignatureProperties(doc, signedProperties, input);
String contentReferenceId = addSignedDataObjectProperties(doc, signedProperties, input);
result.setContentReferenceId(contentReferenceId);
DOMStructure structure = new DOMStructure(qualifyingProperties);
XMLObject propertiesObject = input.getSignatureFactory().newXMLObject(Collections.singletonList(structure), null, null, null);
result.setReferences(Collections.singletonList(ref));
result.setObjects(Collections.singletonList(propertiesObject));
return result;
}
开发者ID:HydAu,项目名称:Camel,代码行数:51,代码来源:XAdESSignatureProperties.java
示例19: getObjects
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
/** XML objects list. */
List<? extends XMLObject> getObjects();
开发者ID:HydAu,项目名称:Camel,代码行数:3,代码来源:XmlSignatureChecker.java
示例20: getObjects
import javax.xml.crypto.dsig.XMLObject; //导入依赖的package包/类
public List<? extends XMLObject> getObjects() {
return objects;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:XmlSignatureProperties.java
注:本文中的javax.xml.crypto.dsig.XMLObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论