xades4j.verification
Class XadesVerificationProfile

java.lang.Object
  extended by xades4j.verification.XadesVerificationProfile

public final class XadesVerificationProfile
extends Object

A profile for signature verification. This class is the entry point for verifying a signature. A profile is a configuration for the signature verification process.

The purpose of this class is to create a XadesVerifier that will actually verify signatures using the configured components.

The minimum configuration is a CertificateValidationProvider because the validation data (trust-achors, CRLs, etc) has to be properly selected. All the other components have default implementations that are used if no other actions are taken. However, all of them can be replaced through the corresponding methods, either by an instance or a class. When a class is used it may have dependencies on other components, which will be handled in order to create the XadesVerifier. The types may also depend on external components, as long as that dependency is registered with on of the addBinding methods. To that end, the constructors and/or setters should use the Inject annotation from Guice.

Custom QualifyingPropertyVerifiers can also be configured. The principles on their dependencies are the same. In addition, custom verifiers over the whole signature can be configured. Finally, verifiers for specific XML elements may be added. This can be usefull if one wants to handle an unsigned property that is not known by the library, as the default unmarshaller will create GenericDOMData instances for those properties if acceptUnknownProperties is set.

Repeated dependency bindings will not cause an immediate error. An exception will be thrown when an instance of XadesVerifier is requested.

Author:
Luís

Constructor Summary
XadesVerificationProfile(CertificateValidationProvider certificateValidationProvider)
           
XadesVerificationProfile(Class<? extends CertificateValidationProvider> certificateValidationProviderClass)
           
 
Method Summary
 XadesVerificationProfile acceptUnknownProperties(boolean accept)
          Indicates whether the resulting verifiers should accept unknown properties.
 XadesVerifier newVerifier()
          Creates a new XadesVerifier based on the current state of the profile.
<T> XadesVerificationProfile
withBinding(Class<T> from, Class<? extends T> to)
          Adds a type dependency mapping to the profile.
<T> XadesVerificationProfile
withBinding(Class<T> from, T to)
          Adds a instance dependency mapping to the profile.
 XadesVerificationProfile withCustomSignatureVerifier(CustomSignatureVerifier v)
           
 XadesVerificationProfile withDigestEngineProvider(Class<? extends MessageDigestEngineProvider> digestProviderClass)
           
 XadesVerificationProfile withDigestEngineProvider(MessageDigestEngineProvider digestProvider)
           
 XadesVerificationProfile withElementVerifier(QName elemName, Class<? extends QualifyingPropertyVerifier> vClass)
           
 XadesVerificationProfile withGlobalDataObjsStructureVerifier(CustomPropertiesDataObjsStructureVerifier v)
           
 XadesVerificationProfile withPolicyDocumentProvider(Class<? extends SignaturePolicyDocumentProvider> policyDocProviderClass)
          By default no policies are supported.
 XadesVerificationProfile withPolicyDocumentProvider(SignaturePolicyDocumentProvider policyDocProvider)
          By default no policies are supported.
 XadesVerificationProfile withPropertiesUnmarshaller(Class<? extends QualifyingPropertiesUnmarshaller> propsUnmarshallerClass)
           
 XadesVerificationProfile withPropertiesUnmarshaller(QualifyingPropertiesUnmarshaller propsUnmarshaller)
           
<TData extends PropertyDataObject>
XadesVerificationProfile
withQualifyingPropertyVerifier(Class<TData> propDataClass, Class<? extends QualifyingPropertyVerifier<TData>> verifierClass)
           
<TData extends PropertyDataObject>
XadesVerificationProfile
withQualifyingPropertyVerifier(Class<TData> propDataClass, QualifyingPropertyVerifier<TData> verifier)
           
 XadesVerificationProfile withTimeStampTokenVerifier(Class<? extends TimeStampVerificationProvider> tsTokenVerifProvClass)
           
 XadesVerificationProfile withTimeStampTokenVerifier(TimeStampVerificationProvider tsTokenVerifProv)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XadesVerificationProfile

public XadesVerificationProfile(CertificateValidationProvider certificateValidationProvider)

XadesVerificationProfile

public XadesVerificationProfile(Class<? extends CertificateValidationProvider> certificateValidationProviderClass)
Method Detail

withBinding

public <T> XadesVerificationProfile withBinding(Class<T> from,
                                                Class<? extends T> to)
Adds a type dependency mapping to the profile. This is tipically done from an interface to a type that implements that interface. When a dependency to from is found, the to class is used. The to class may in turn have its own dependencies.

The other withNNNNNN methods are convenient shortcuts for this one.

Parameters:
from - the dependency
to - the type that resolves the dependency
Returns:
this profile

withBinding

public <T> XadesVerificationProfile withBinding(Class<T> from,
                                                T to)
Adds a instance dependency mapping to the profile. When a dependency to from is found, the to instance is used. The other withNNNNNN methods are convenient shortcuts for this one.

Parameters:
from - the dependency
to - the instance that resolves the dependency
Returns:
this profile

newVerifier

public final XadesVerifier newVerifier()
                                throws XadesProfileResolutionException
Creates a new XadesVerifier based on the current state of the profile. If any changes are made after this call, the previously returned verifier will not be afected. Other verifiers can be created, accumulating the profile changes.

Returns:
a XadesVerifier accordingly to this profile.
Throws:
XadesProfileResolutionException - if the dependencies of the signer (direct and indirect) cannot be resolved

withDigestEngineProvider

public XadesVerificationProfile withDigestEngineProvider(MessageDigestEngineProvider digestProvider)

withDigestEngineProvider

public XadesVerificationProfile withDigestEngineProvider(Class<? extends MessageDigestEngineProvider> digestProviderClass)

withPolicyDocumentProvider

public XadesVerificationProfile withPolicyDocumentProvider(SignaturePolicyDocumentProvider policyDocProvider)
By default no policies are supported.


withPolicyDocumentProvider

public XadesVerificationProfile withPolicyDocumentProvider(Class<? extends SignaturePolicyDocumentProvider> policyDocProviderClass)
By default no policies are supported.


withTimeStampTokenVerifier

public XadesVerificationProfile withTimeStampTokenVerifier(TimeStampVerificationProvider tsTokenVerifProv)

withTimeStampTokenVerifier

public XadesVerificationProfile withTimeStampTokenVerifier(Class<? extends TimeStampVerificationProvider> tsTokenVerifProvClass)

withPropertiesUnmarshaller

public XadesVerificationProfile withPropertiesUnmarshaller(QualifyingPropertiesUnmarshaller propsUnmarshaller)

withPropertiesUnmarshaller

public XadesVerificationProfile withPropertiesUnmarshaller(Class<? extends QualifyingPropertiesUnmarshaller> propsUnmarshallerClass)

acceptUnknownProperties

public XadesVerificationProfile acceptUnknownProperties(boolean accept)
Indicates whether the resulting verifiers should accept unknown properties. Actually, this is a property of the underlying QualifyingPropertiesUnmarshaller which controls if a GenericDOMData should be used when an unknown property is found.

The schema for signed signature and data object properties is closed; as such, this only affects the unsigned properties.

Note that it is also possible to implement a custom QualifyingPropertiesUnmarshallers.

The withElementVerifier method can be used to register verifiers for unknown properties.

See Also:
QualifyingPropertiesUnmarshaller

withGlobalDataObjsStructureVerifier

public XadesVerificationProfile withGlobalDataObjsStructureVerifier(CustomPropertiesDataObjsStructureVerifier v)

withCustomSignatureVerifier

public XadesVerificationProfile withCustomSignatureVerifier(CustomSignatureVerifier v)

withElementVerifier

public XadesVerificationProfile withElementVerifier(QName elemName,
                                                    Class<? extends QualifyingPropertyVerifier> vClass)

withQualifyingPropertyVerifier

public <TData extends PropertyDataObject> XadesVerificationProfile withQualifyingPropertyVerifier(Class<TData> propDataClass,
                                                                                                  Class<? extends QualifyingPropertyVerifier<TData>> verifierClass)

withQualifyingPropertyVerifier

public <TData extends PropertyDataObject> XadesVerificationProfile withQualifyingPropertyVerifier(Class<TData> propDataClass,
                                                                                                  QualifyingPropertyVerifier<TData> verifier)


Copyright © 2012. All Rights Reserved.