public final class BatchSigner
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
sign(java.lang.String batchB64,
java.lang.String batchPresignerUrl,
java.lang.String batchPostSignerUrl,
java.security.cert.Certificate[] certificates,
java.security.PrivateKey pk)
Procesa un lote de firmas.
|
public static java.lang.String sign(java.lang.String batchB64, java.lang.String batchPresignerUrl, java.lang.String batchPostSignerUrl, java.security.cert.Certificate[] certificates, java.security.PrivateKey pk) throws java.security.cert.CertificateEncodingException, java.io.IOException, es.gob.afirma.core.AOException
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="signbatch"> <xs:complexType> <xs:sequence> <xs:element name="singlesign" maxOccurs="unbounded" minOccurs="1"> <xs:complexType> <xs:sequence> <xs:element type="xs:string" name="datasource"/> <xs:element name="format"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="XAdES"/> <xs:enumeration value="CAdES"/> <xs:enumeration value="PAdES"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="suboperation"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="sign"/> <xs:enumeration value="cosign"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="extraparams"> <xs:simpleType> <xs:restriction base="xs:base64Binary" /> </xs:simpleType> </xs:element> <xs:element name="signsaver"> <xs:complexType> <xs:sequence> <xs:element type="xs:string" name="class"/> <xs:element name="config"> <xs:simpleType> <xs:restriction base="xs:base64Binary" /> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute type="xs:string" name="id" use="required"/> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute type="xs:string" name="stoponerror" use="optional"/> <xs:attribute type="xs:string" name="algorithm" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="SHA1withRSA"/> <xs:enumeration value="SHA256withRSA"/> <xs:enumeration value="SHA384withRSA"/> <xs:enumeration value="SHA512withRSA"/> </xs:restriction> </xs:simpleType> <xs:attribute> </xs:complexType> </xs:element> </xs:schema>Un ejemplo de definición XML de lote de firmas podría ser este (ejemplo con dos firmas en el lote):
<?xml version="1.0" encoding="UTF-8" ?> <signbatch stoponerror="true" algorithm="SHA1withRSA"> <singlesign id="f8526f7b-d30a-4720-9e35-fe3494217944"> <datasource>http://google.com</datasource> <format>XAdES</format> <suboperation>sign</suboperation> <extraparams>Iw0KI1RodSBBdW[...]QNCg==</extraparams> <signsaver> <class>es.gob.afirma.signers.batch.SignSaverFile</class> <config>Iw0KI1RodSBBdWcgMT[...]wNCg==</config> </signsaver> </singlesign> <singlesign id="0e9cc5de-63ee-45ee-ae02-4a6591ab9a46"> <datasource>SG9sYSBNdW5kbw==</datasource> <format>CAdES</format> <suboperation>sign</suboperation> <extraparams>Iw0KI1RodSBBdWc[...]NCg==</extraparams> <signsaver> <class>es.gob.afirma.signers.batch.SignSaverFile</class> <config>Iw0KI1RodSBBdWcgMTM[...]Cg==</config> </signsaver> </singlesign> </signbatch>
batchB64
- XML de definición del lote de firmas.batchPresignerUrl
- URL del servicio remoto de preproceso de lotes de firma.batchPostSignerUrl
- URL del servicio remoto de postproceso de lotes de firma.certificates
- Cadena de certificados del firmante.pk
- Clave privada para realizar las firmas cliente.<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="signs"> <xs:complexType> <xs:sequence> <xs:element name="sign" maxOccurs="unbounded" minOccurs="1"> <xs:complexType> <xs:sequence> <xs:element name="result"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="OK"/> <xs:enumeration value="KO"/> <xs:enumeration value="NP"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element type="xs:string" name="reason" minOccurs="0"/> </xs:sequence> <xs:attribute type="xs:string" name="id" use="required"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
java.io.IOException
- Si hay problemas de red o en el tratamiento de datos.java.security.cert.CertificateEncodingException
- Si los certificados proporcionados no son válidos.es.gob.afirma.core.AOException
- Si hay errores en las firmas cliente.