use of xades4j.properties.CommitmentTypeProperty in project xades4j by luisgoncalves.
the class DefaultProductionBindingsModule method configure.
@Override
protected void configure() {
// Defaults for configurable components.
bind(SignaturePropertiesProvider.class).to(DefaultSignaturePropertiesProvider.class);
bind(DataObjectPropertiesProvider.class).toInstance(new DataObjectPropertiesProvider() {
@Override
public void provideProperties(DataObjectDesc dataObj) {
// By default no properties are specified for a data object.
}
});
bind(AlgorithmsProviderEx.class).to(DefaultAlgorithmsProviderEx.class);
// Will wrap the AlgorithmsProviderEx in use
bind(AlgorithmsProvider.class).to(AlgorithmsProvider_ExToDeprecated_Adapter.class);
bind(BasicSignatureOptionsProvider.class).to(DefaultBasicSignatureOptionsProvider.class);
bind(MessageDigestEngineProvider.class).to(DefaultMessageDigestProvider.class);
bind(TimeStampTokenProvider.class).to(HttpTimeStampTokenProvider.class);
// Backwards compatibility
bind(TSAHttpData.class).toInstance(new TSAHttpData("http://tss.accv.es:8318/tsa"));
// PropertiesDataObjectsGenerator is not configurable but the individual
// generators may have dependencies.
bind(PropertiesDataObjectsGenerator.class).to(PropertiesDataObjectsGeneratorImpl.class);
bind(PropertyDataGeneratorsMapper.class).to(PropertyDataGeneratorsMapperImpl.class);
// Ensure empty set when no bindings are defined
Multibinder.newSetBinder(binder(), CustomPropertiesDataObjsStructureVerifier.class);
// PropertyDataGeneratorsMapperImpl relies on the injector to get
// the individual generators, so they need to be bound.
// - SignedSignatureProperties
bind(new TypeLiteral<PropertyDataObjectGenerator<SigningTimeProperty>>() {
}).to(DataGenSigningTime.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignerRoleProperty>>() {
}).to(DataGenSignerRole.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SigningCertificateProperty>>() {
}).to(DataGenSigningCertificate.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignatureProductionPlaceProperty>>() {
}).to(DataGenSigProdPlace.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignaturePolicyIdentifierProperty>>() {
}).to(DataGenSigPolicy.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignaturePolicyImpliedProperty>>() {
}).to(DataGenSigPolicyImplied.class);
// - SignedDataObjectProperties
bind(new TypeLiteral<PropertyDataObjectGenerator<DataObjectFormatProperty>>() {
}).to(DataGenDataObjFormat.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CommitmentTypeProperty>>() {
}).to(DataGenCommitmentType.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<AllDataObjsCommitmentTypeProperty>>() {
}).to(DataGenCommitmentTypeAllDataObjs.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<IndividualDataObjsTimeStampProperty>>() {
}).to(DataGenIndivDataObjsTimeStamp.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<AllDataObjsTimeStampProperty>>() {
}).to(DataGenAllDataObjsTimeStamp.class);
// - UnsignedSignatureProperties
bind(new TypeLiteral<PropertyDataObjectGenerator<CounterSignatureProperty>>() {
}).to(DataGenCounterSig.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SignatureTimeStampProperty>>() {
}).to(DataGenSigTimeStamp.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CompleteCertificateRefsProperty>>() {
}).to(DataGenCompleteCertRefs.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CompleteRevocationRefsProperty>>() {
}).to(DataGenCompleteRevocRefs.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<SigAndRefsTimeStampProperty>>() {
}).to(DataGenSigAndRefsTimeStamp.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<CertificateValuesProperty>>() {
}).to(DataGenCertificateValues.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<RevocationValuesProperty>>() {
}).to(DataGenRevocationValues.class);
bind(new TypeLiteral<PropertyDataObjectGenerator<ArchiveTimeStampProperty>>() {
}).to(DataGenArchiveTimeStamp.class);
}
use of xades4j.properties.CommitmentTypeProperty in project xades4j by luisgoncalves.
the class CommitmentTypeVerifier method verify.
@Override
public QualifyingProperty verify(CommitmentTypeData propData, QualifyingPropertyVerificationContext ctx) throws CommitmentTypeVerificationException {
String uri = propData.getUri(), desc = propData.getDescription();
Collection<String> objsReferences = propData.getObjReferences();
CommitmentTypePropertyBase property;
if (objsReferences != null) {
// "Check that all the ObjectReference elements actually reference
// ds:Reference elements from the signature."
SignedObjectsData signedObjsData = ctx.getSignedObjectsData();
CommitmentTypeProperty commitmentTypeProperty = new CommitmentTypeProperty(uri, desc);
for (String objRef : objsReferences) {
RawDataObjectDesc dataObj = signedObjsData.findSignedDataObject(objRef);
if (null == dataObj)
throw new CommitmentTypeVerificationException(objRef);
// Associate the property to the data object.
dataObj.withCommitmentType(commitmentTypeProperty);
}
property = commitmentTypeProperty;
} else {
property = new AllDataObjsCommitmentTypeProperty(uri, desc);
}
if (propData.getQualifiers() != null) {
for (Object q : propData.getQualifiers()) {
if (q instanceof String) {
property.withQualifier((String) q);
} else if (q instanceof Element) {
property.withQualifier((Element) q);
}
}
}
return property;
}
use of xades4j.properties.CommitmentTypeProperty in project xades4j by luisgoncalves.
the class SignerBESTest method testSignBES.
@Test
public void testSignBES() throws Exception {
System.out.println("signBES");
Document doc1 = getTestDocument();
Document doc2 = getDocument("content.xml");
Node objectContent = doc1.importNode(doc2.getDocumentElement(), true);
Element elemToSign = doc1.getDocumentElement();
SignerBES signer = (SignerBES) new XadesBesSigningProfile(keyingProviderMy).newSigner();
IndividualDataObjsTimeStampProperty dataObjsTimeStamp = new IndividualDataObjsTimeStampProperty();
AllDataObjsCommitmentTypeProperty globalCommitment = AllDataObjsCommitmentTypeProperty.proofOfApproval();
CommitmentTypeProperty commitment = (CommitmentTypeProperty) CommitmentTypeProperty.proofOfCreation().withQualifier("MyQualifier");
DataObjectDesc obj1 = new DataObjectReference('#' + elemToSign.getAttribute("Id")).withTransform(new EnvelopedSignatureTransform()).withDataObjectFormat(new DataObjectFormatProperty("text/xml", "MyEncoding").withDescription("Isto é uma descrição do elemento raiz").withDocumentationUri("http://doc1.txt").withDocumentationUri("http://doc2.txt").withIdentifier("http://elem.root")).withCommitmentType(commitment).withDataObjectTimeStamp(dataObjsTimeStamp);
DataObjectDesc obj2 = new EnvelopedXmlObject(objectContent, "text/xml", null).withDataObjectFormat(new DataObjectFormatProperty("text/xml", "MyEncoding").withDescription("Isto é uma descrição do elemento dentro do object").withDocumentationUri("http://doc3.txt").withDocumentationUri("http://doc4.txt").withIdentifier("http://elem.in.object")).withCommitmentType(commitment).withDataObjectTimeStamp(dataObjsTimeStamp);
SignedDataObjects dataObjs = new SignedDataObjects(obj1, obj2).withCommitmentType(globalCommitment).withDataObjectsTimeStamp();
signer.sign(dataObjs, elemToSign);
outputDocument(doc1, "document.signed.bes.xml");
}
Aggregations