es.caib.signatura.impl
Class WebSignature

java.lang.Object
  extended by es.caib.signatura.impl.WebSignature
All Implemented Interfaces:
Signature, java.io.Serializable

public class WebSignature
extends java.lang.Object
implements Signature, java.io.Serializable

Implementation of the interface Signature for a web signature.

Version:
0.98
Author:
Jesús Reyes (3dígits)
See Also:
Signer, Signature, Serialized Form

Field Summary
protected  byte[] signatureBytes
           
 
Constructor Summary
WebSignature(java.lang.String firma)
          Creates a signature object from a web signature.
 
Method Summary
 java.security.cert.X509Certificate getCert()
          Returns the X509 certificate used to sign.
 java.lang.String getCertCaName()
          Gets the name of the certification authority of the certificate used to sign.
 java.security.cert.X509Certificate[] getCertificateChain()
          Returns the certificate chain.
 java.lang.String getCertSubjectAlternativeNames()
          Gets the concatenation of the subject's alternate name of the certificate used to sign as follows: name0 = value, name1 = value, ...
 java.lang.String getCertSubjectCommonName()
          Gets the subject's Common Name of the certificate used to sign.
 java.lang.String getContentType()
          Returns the content type of the signature.
 java.util.Date getDate()
          Gets the date of the signature timestamp.
protected  java.lang.String getInternalClassName()
          Gets the implementing class name.
 ParsedCertificate getParsedCertificate()
          Gets a ParsedCertificate object with the subject's credentials.
 byte[] getPkcs7()
          Returns the signature in PKCS#7 format.
 void setContentType(java.lang.String contentType)
           
 void setPkcs7(byte[] pkcs7)
           
 boolean verify()
          Determinate the certificate validity of the signature.
 boolean verify(java.io.InputStream contentStream)
          Verifies the digital signature of a document.
 boolean verifyAPosterioriTimestamp(java.io.InputStream contentStream)
          Verifies the digital signature of a document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

signatureBytes

protected byte[] signatureBytes
Constructor Detail

WebSignature

public WebSignature(java.lang.String firma)
             throws SignatureDataException
Creates a signature object from a web signature. The signature has the following format: <Software identifier>:<MIME type>:<Base 64 codified signature>. The software identifier can be FF (Firefox) or IE (Internet Explorer).

Parameters:
firma - Web signature.
Throws:
java.io.IOException
SignatureDataException
Method Detail

setContentType

public void setContentType(java.lang.String contentType)

setPkcs7

public void setPkcs7(byte[] pkcs7)

getInternalClassName

protected java.lang.String getInternalClassName()
Gets the implementing class name.


getCertCaName

public java.lang.String getCertCaName()
Gets the name of the certification authority of the certificate used to sign.

Specified by:
getCertCaName in interface Signature
Returns:
the name of the certification authority.

getCertSubjectCommonName

public java.lang.String getCertSubjectCommonName()
Gets the subject's Common Name of the certificate used to sign.

Specified by:
getCertSubjectCommonName in interface Signature
Returns:
the subject common name.

getCertSubjectAlternativeNames

public java.lang.String getCertSubjectAlternativeNames()
Gets the concatenation of the subject's alternate name of the certificate used to sign as follows: name0 = value, name1 = value, ...

Specified by:
getCertSubjectAlternativeNames in interface Signature
Returns:
a string containing the subject's alternate name of the certificate.

getPkcs7

public byte[] getPkcs7()
Returns the signature in PKCS#7 format.

Specified by:
getPkcs7 in interface Signature
Returns:
a byte array containing the signature in PKCS#7 format.

getDate

public java.util.Date getDate()
                       throws SignatureTimestampException
Gets the date of the signature timestamp.

Specified by:
getDate in interface Signature
Returns:
the date of the signature timestamp or null if the signature doesn't include timestamp.
Throws:
SignatureTimestampException

verify

public boolean verify()
               throws SignatureVerifyException
Determinate the certificate validity of the signature.

Specified by:
verify in interface Signature
Returns:
true if the certificate is valid; false otherwise.
Throws:
SignatureVerifyException
See Also:
Signer.verify(java.io.InputStream, es.caib.signatura.api.Signature)

getContentType

public java.lang.String getContentType()
Returns the content type of the signature.

Specified by:
getContentType in interface Signature
Returns:
the content type of the signature.

getCert

public java.security.cert.X509Certificate getCert()
Returns the X509 certificate used to sign.

Specified by:
getCert in interface Signature
Returns:
the X509Certificate used to sign.

getCertificateChain

public java.security.cert.X509Certificate[] getCertificateChain()
                                                         throws java.lang.Exception
Returns the certificate chain.

Specified by:
getCertificateChain in interface Signature
Returns:
the certificate chain.
Throws:
java.lang.Exception

getParsedCertificate

public ParsedCertificate getParsedCertificate()
Gets a ParsedCertificate object with the subject's credentials.

Specified by:
getParsedCertificate in interface Signature
Returns:
a ParsedCertificate object with the subject's credentials.

verify

public boolean verify(java.io.InputStream contentStream)
               throws SignatureProviderException,
                      java.io.IOException,
                      SignatureVerifyException
Verifies the digital signature of a document. The verification process is independent of signature timestamp.

Specified by:
verify in interface Signature
Parameters:
contentStream - byte stream of the document.
Returns:
true if the verification process is correct; false otherwise.
Throws:
SignatureProviderException - If the API provider cannot be accessed.
java.io.IOException - If the document or the timestamp server is not available.
SignatureVerifyException - If failed the verification process.

verifyAPosterioriTimestamp

public boolean verifyAPosterioriTimestamp(java.io.InputStream contentStream)
                                   throws SignatureProviderException,
                                          java.io.IOException,
                                          SignatureVerifyException
Verifies the digital signature of a document. If the digital signature requires a timestamp and don't have it then a timestamp is added (if possible).

Specified by:
verifyAPosterioriTimestamp in interface Signature
Parameters:
contentStream - byte stream of the document.
Returns:
true if the verification process is correct; false otherwise.
Throws:
SignatureProviderException - If the API provider cannot be accessed.
java.io.IOException - If the document or the timestamp server is not available.
SignatureVerifyException - If failed the verification process.


Copyright © 2011 Direcció General de Tecnologia i Comunicacions. Govern de les Illes Balears. All Rights Reserved.