All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xades4j.production.XadesFormatExtenderProfile Maven / Gradle / Ivy

Go to download

The XAdES4j library is an high-level, configurable and extensible Java implementation of XML Advanced Electronic Signatures (XAdES 1.3.2 and 1.4.1). It enables producing, verifying and extending signatures in the main XAdES forms: XAdES-BES, XAdES-EPES, XAdES-T and XAdES-C. Also, extended forms are supported through the enrichment of an existing signature.

There is a newer version: 2.2.2
Show newest version
/*
 * XAdES4j - A Java library for generation and verification of XAdES signatures.
 * Copyright (C) 2010 Luis Goncalves.
 *
 * XAdES4j is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or any later version.
 *
 * XAdES4j is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License along
 * with XAdES4j. If not, see .
 */
package xades4j.production;

import com.google.inject.Module;
import xades4j.properties.QualifyingProperty;
import xades4j.utils.XadesProfileCore;
import xades4j.utils.XadesProfileResolutionException;
import xades4j.providers.AlgorithmsProvider;
import xades4j.providers.AlgorithmsProviderEx;
import xades4j.providers.MessageDigestEngineProvider;
import xades4j.providers.TimeStampTokenProvider;
import xades4j.utils.UtilsBindingsModule;
import xades4j.xml.marshalling.MarshallingBindingsModule;
import xades4j.xml.marshalling.UnsignedPropertiesMarshaller;
import xades4j.xml.marshalling.algorithms.AlgorithmParametersBindingsModule;

/**
 * A profile for signature format enrichment, after verification. A format extender
 * is used to add unsigned signature properties to an existing signature in order
 * augment its format. This can be done as part of the {@link xades4j.verification.XadesVerifier#verify(org.w3c.dom.Element, xades4j.verification.SignatureSpecificVerificationOptions, xades4j.production.XadesSignatureFormatExtender, xades4j.verification.XAdESForm) verification process}.
 * The {@code XadesSignatureFormatExtender} can also be used separately, but no
 * checks are made on the correctness of the signature.
 * 

* This profile follows the same principles of {@link XadesSigningProfile}. * @author Luís */ public class XadesFormatExtenderProfile { private final XadesProfileCore profileCore; public XadesFormatExtenderProfile() { this.profileCore = new XadesProfileCore(); } public final XadesFormatExtenderProfile withBinding( Class from, Class to) { this.profileCore.addBinding(from, to); return this; } public final XadesFormatExtenderProfile withBinding( Class from, T to) { this.profileCore.addBinding(from, to); return this; } private static final Module[] overridableModules = { new DefaultProductionBindingsModule(), new MarshallingBindingsModule() }; private static final Module[] sealedModules = { new UtilsBindingsModule(), new AlgorithmParametersBindingsModule() }; public final XadesSignatureFormatExtender getFormatExtender() throws XadesProfileResolutionException { return this.profileCore.getInstance(getFormatExtenderClass(),overridableModules, sealedModules); } protected Class getFormatExtenderClass() { return XadesSignatureFormatExtenderImpl.class; } /**/ /** * @deprecated This method is deprecated and might be removed on future versions * @see #withAlgorithmsProviderEx(xades4j.providers.AlgorithmsProviderEx) */ public XadesFormatExtenderProfile withAlgorithmsProvider( AlgorithmsProvider algsProvider) { // Adapt AlgorithmsProviderEx to the AlgorithmsProvider being registered withBinding(AlgorithmsProviderEx.class, AlgorithmsProvider_DeprecatedToEx_Adapter.class); return withBinding(AlgorithmsProvider.class, algsProvider); } /** * @deprecated this method is deprecated and might be removed on future versions * @see #withAlgorithmsProviderEx(java.lang.Class) */ public XadesFormatExtenderProfile withAlgorithmsProvider( Class algsProviderClass) { // Adapt AlgorithmsProviderEx to the AlgorithmsProvider being registered withBinding(AlgorithmsProviderEx.class, AlgorithmsProvider_DeprecatedToEx_Adapter.class); return withBinding(AlgorithmsProvider.class, algsProviderClass); } public XadesFormatExtenderProfile withAlgorithmsProviderEx( AlgorithmsProviderEx algsProvider) { return withBinding(AlgorithmsProviderEx.class, algsProvider); } public XadesFormatExtenderProfile withAlgorithmsProviderEx( Class algsProviderClass) { return withBinding(AlgorithmsProviderEx.class, algsProviderClass); } public XadesFormatExtenderProfile withDigestEngineProvider( MessageDigestEngineProvider digestProvider) { return withBinding(MessageDigestEngineProvider.class, digestProvider); } public XadesFormatExtenderProfile withDigestEngineProvider( Class digestProviderClass) { return withBinding(MessageDigestEngineProvider.class, digestProviderClass); } public XadesFormatExtenderProfile withTimeStampTokenProvider( TimeStampTokenProvider tsTokenProvider) { return withBinding(TimeStampTokenProvider.class, tsTokenProvider); } public XadesFormatExtenderProfile withTimeStampTokenProvider( Class tsTokenProviderClass) { return withBinding(TimeStampTokenProvider.class, tsTokenProviderClass); } public XadesFormatExtenderProfile withUnsignedPropertiesMarshaller( UnsignedPropertiesMarshaller uPropsMarshaller) { return withBinding(UnsignedPropertiesMarshaller.class, uPropsMarshaller); } public XadesFormatExtenderProfile withUnsignedPropertiesMarshaller( Class uPropsMarshallerClass) { return withBinding(UnsignedPropertiesMarshaller.class, uPropsMarshallerClass); } /*******************************************/ /****** Custom data object generation ******/ /*******************************************/ public XadesFormatExtenderProfile withPropertyDataObjectGenerator( final Class propClass, final PropertyDataObjectGenerator propDataGen) { this.profileCore.addGenericBinding(PropertyDataObjectGenerator.class, propDataGen, propClass); return this; } public XadesFormatExtenderProfile withPropertyDataObjectGenerator( final Class propClass, final Class> propDataGenClass) { this.profileCore.addGenericBinding(PropertyDataObjectGenerator.class, propDataGenClass, propClass); return this; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy