| File |
Line |
| es/caib/signatura/impl/CMSSignature.java |
106 |
| es/caib/signatura/impl/WebSignature.java |
121 |
}
/**
* {@inheritDoc}
*/
public String getCertCaName() {
return impl.getCertCaName();
}
/**
* {@inheritDoc}
*/
public String getCertSubjectCommonName() {
return impl.getCertSubjectCommonName();
}
/**
* {@inheritDoc}
*/
public String getCertSubjectAlternativeNames() {
return impl.getCertSubjectAlternativeNames();
}
/**
* {@inheritDoc}
*/
public byte[] getPkcs7() {
return this.signatureBytes;
}
// Sobreescribimos el método readObject que deserializa el objeto para
// llamar posteriormente al método privado de inicialización del objetco
// cuyo cometido es extraer el certificado de usuario de la firma
private void readObject(java.io.ObjectInputStream in) throws IOException,
ClassNotFoundException {
in.defaultReadObject();
init();
}
/**
* {@inheritDoc}
*/
public Date getDate() throws SignatureTimestampException {
return impl.getDate();
}
/**
* {@inheritDoc}
*/
public boolean verify() throws SignatureVerifyException {
return impl.verify();
}
/**
* {@inheritDoc}
*/
public String getContentType() {
return contentType;
}
/**
* {@inheritDoc}
*/
public X509Certificate getCert() {
return impl.getCert();
}
/**
* {@inheritDoc}
*/
public X509Certificate[] getCertificateChain() throws Exception {
return impl.getCertificateChain();
}
/**
* {@inheritDoc}
*/
public ParsedCertificate getParsedCertificate() {
return impl.getParsedCertificate();
}
/**
* {@inheritDoc}
*/
public boolean verify(InputStream contentStream)
throws SignatureProviderException, IOException,
SignatureVerifyException {
boolean isVerified = true;
try {
// verificación interna de la firma
isVerified = isVerified && impl.verify(contentStream);
// isVerified = isVerified && verifyWS();
} catch (SignatureVerifyException e) {
throw e;
} catch (Exception e) {
throw new SignatureVerifyException(e);
}
return isVerified;
}
/**
* {@inheritDoc}
*/
public boolean verifyAPosterioriTimestamp(InputStream contentStream)
throws SignatureProviderException, IOException,
SignatureVerifyException {
boolean isVerified = true;
try {
// verificación interna de la firma
isVerified = isVerified
&& impl.verifyAPosterioriTimestamp(contentStream);
// *
// * Se actualiza la firma por si el validador ha añadido
// * un sello de tiempo
if (isVerified) {
this.setPkcs7(impl.getPkcs7());
}
} catch (SignatureVerifyException e) {
throw e;
} catch (Exception e) {
throw new SignatureVerifyException(e);
}
return isVerified;
}
/*
* private boolean WSResponseIsAVerifiedMessage(String result) throws
* SignatureVerifyException { String content = new String(); try {
* DocumentBuilderFactory documentBuilderFactory =
* DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder =
* documentBuilderFactory.newDocumentBuilder(); Document document;
* StringBufferInputStream inputStream = new
* StringBufferInputStream(result); document =
* documentBuilder.parse((InputStream)inputStream); //Element element =
* document.getDocumentElement(); try{ NodeList nodeList =
* document.getElementsByTagName("valido"); Node node = nodeList.item(0);
* Element element = (Element) node; String tagName = element.getTagName();
* Node textData = null; boolean stop = false; NodeList nodeDataList =
* element.getChildNodes(); for(int i = 0;i < nodeDataList.getLength() &&
* !stop;i++){ textData = nodeDataList.item(i); stop =
* textData.getNodeType() == org.w3c.dom.Node.TEXT_NODE; } content =
* ((org.w3c.dom.Text)textData).getData(); }catch(Exception e){ //* Para no
* llevar a malos entendidos // * se da la firma como falsa // * return
* false; } if(content == null){ throw new Exception("No content in 'valido'
* TAG. Response message: " + result); } }catch(Exception e){ throw new
* SignatureVerifyException(e); } return content.compareToIgnoreCase("true") ==
* 0; }
*/
}
|
| File |
Line |
| es/caib/signatura/impl/SMIMEInputStream.java |
102 |
| es/caib/signatura/impl/SMIMEPkcs7InputStream.java |
54 |
}
/* (non-Javadoc)
* @see java.io.InputStream#read()
*/
public synchronized int read ()
throws IOException {
do {
if ( buffer != null && bufferOffset < buffer.length)
{
byte b = buffer [ bufferOffset ++ ];
return b;
} else if (status == STATUS_END) {
return -1;
} else {
fetchData();
}
} while (true);
}
/* (non-Javadoc)
* @see java.io.InputStream#read(byte[], int, int)
*/
public synchronized int read (byte[] targetBuffer, int offset, int length)
throws IOException {
do {
if ( buffer != null && bufferOffset < buffer.length)
{
int actualLength = buffer.length - bufferOffset;
if ( actualLength > length)
actualLength = length;
System.arraycopy(buffer, bufferOffset, targetBuffer, offset, actualLength);
bufferOffset = bufferOffset + actualLength;
return actualLength;
} else if (status == STATUS_END) {
return -1;
} else {
fetchData();
}
} while (true);
}
/* (non-Javadoc)
* @see java.io.InputStream#available()
*/
public synchronized int available()
throws IOException {
do {
if ( buffer != null && bufferOffset < buffer.length)
{
return buffer.length - bufferOffset;
} else if (status == STATUS_END) {
return -1;
} else {
|
| File |
Line |
| es/caib/signatura/impl/CMSSignature.java |
106 |
| es/caib/signatura/provider/tradise/TradiseSignature.java |
103 |
}
/**
* Obtiene el nombre de la entidad certificadora usada en la firma
*
* @return nombre de la entidad certificadora
*/
public String getCertCaName() {
return impl.getCertCaName();
}
/**
* Obtiene el nombre del certificado usado en la firma
*
* @return nombre del certificado (CommonName)
*/
public String getCertSubjectCommonName() {
return impl.getCertSubjectCommonName();
}
public String getCertSubjectAlternativeNames() {
return impl.getCertSubjectAlternativeNames();
}
public byte[] getPkcs7() {
return this.signatureBytes;
}
// Sobreescribimos el método readObject que deserializa el objeto para
// llamar posteriormente al método privado de inicialización del objetco
// cuyo cometido es extraer el certificado de usuario de la firma
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
init();
}
public Date getDate()
throws SignatureTimestampException
{
return impl.getDate();
}
public boolean verify()
throws SignatureVerifyException
{
return impl.verify();
}
public String getContentType() {
return contentType;
}
public X509Certificate getCert() {
return impl.getCert();
}
public X509Certificate[] getCertificateChain()
throws Exception
{
return impl.getCertificateChain();
}
public ParsedCertificate getParsedCertificate() {
return impl.getParsedCertificate();
}
/*
* (non-Javadoc)
*
* @see es.caib.signatura.api.Signature#verify(java.io.InputStream)
*/
public boolean verifyAPosterioriTimestamp(InputStream contentStream)
|
| File |
Line |
| es/caib/signatura/impl/CMSSignature.java |
140 |
| es/caib/signatura/impl/SMIMESignatureProxy.java |
107 |
return impl.getCertSubjectAlternativeNames();
}
public Date getDate() throws SignatureTimestampException {
return impl.getDate();
}
public boolean verify() throws SignatureVerifyException {
return impl.verify();
}
public String getContentType() {
return contentType;
}
public X509Certificate getCert() {
return impl.getCert();
}
public X509Certificate[] getCertificateChain() throws Exception {
return impl.getCertificateChain();
}
public ParsedCertificate getParsedCertificate() {
return impl.getParsedCertificate();
}
public boolean verify(InputStream contentStream)
throws SignatureProviderException, IOException,
SignatureVerifyException {
boolean isVerified = true;
try{
// verificación interna de la firma
//TODO comprobar si ha de ser RAW o no per cridar a verifyRaw o a verify
isVerified = isVerified && impl.verify(contentStream);
}catch(SignatureVerifyException e){
throw e;
} catch(Exception e){
throw new SignatureVerifyException(e);
}
return isVerified;
}
public byte[] getPkcs7() {
|
| File |
Line |
| es/caib/signatura/impl/CMSSignature.java |
77 |
| es/caib/signatura/impl/SMIMESignatureProxy.java |
55 |
}
private void init() throws IOException {
if (impl == null) {
try {
ClassLoader cl = ClassLoaderFactory.getFactory().getMasterClassLoader();
Class clazz = cl .loadClass( getInternalClassName() );
impl =(SignatureProviderInterface)clazz.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
try {
impl.setContentType(contentType);
impl.setSignedData(signatureBytes);
} catch (Exception e) {
throw new IOException("Unable to parse signature");
}
}
/**
* @return
*/
protected String getInternalClassName() {
return "es.caib.signatura.provider.impl.common.SMIMESignatureImpl";
|
| File |
Line |
| es/caib/signatura/impl/CMSSignature.java |
77 |
| es/caib/signatura/impl/WebSignature.java |
84 |
}
private void init() throws IOException {
if (impl == null) {
try {
ClassLoader cl = ClassLoaderFactory.getFactory()
.getMasterClassLoader();
Class clazz = cl.loadClass(getInternalClassName());
impl = (SignatureProviderInterface) clazz.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
try {
impl.setContentType(contentType);
impl.setSignedData(signatureBytes);
} catch (Exception e) {
throw new IOException("Unable to parse signature");
}
}
/**
* Gets the implementing class name.
*
* @returns The implementing class name.
*/
protected String getInternalClassName() {
|
| File |
Line |
| es/caib/signatura/impl/SMIMEInputStream.java |
301 |
| es/caib/signatura/impl/SMIMEPkcs7InputStream.java |
158 |
"Content-Description: S/MIME Cryptographic Signature\r\n"+
"\r\n").getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException (e);
}
}
private byte [] fetchIdle() {
status = STATUS_HEADER;
return null;
}
/* (non-Javadoc)
* @see java.io.InputStream#skip(long)
*/
public synchronized long skip(long n) throws IOException {
for (long i = 0; i < n; i++)
if (this.read() < 0) return i;
return n;
}
/* (non-Javadoc)
* @see java.io.InputStream#mark(int)
*/
public void mark(int readlimit) {}
/* (non-Javadoc)
* @see java.io.InputStream#reset()
*/
public void reset() throws IOException {
throw new IOException("Base64InputStream does not support mark/reset");
}
/* (non-Javadoc)
* @see java.io.InputStream#markSupported()
*/
public boolean markSupported() { return false; }
// Own methods
}
|
| File |
Line |
| es/caib/signatura/impl/CAIBSigner.java |
333 |
| es/caib/signatura/impl/CAIBSigner.java |
364 |
public void signPDF(InputStream pdfInputStream, OutputStream signedStream, String certificateName, String password, String contentType, String textoAdicional, int stampOptions, float top, float left, float height, float width, float rotation, boolean allowMultipleSignature) throws IOException, SignatureException {
synchronized (lock) {
boolean recognized = properties.needsRecognizedCertificate(contentType);
SignerProviderInterface signer = getSigner (certificateName, contentType);
if ( SigDebug.isActive() ) {
SigDebug.write( "Comprovacio password null." );
}
if ( password == null ) {
if ( SigDebug.isActive() )
SigDebug.write( "Posem el password a cadena buida." );
password = "";
}
if ( SigDebug.isActive() ) {
SigDebug.write( "CAIBSigned.sign: password " + (password.length() == 0? "es" : "no es") + " buit." );
}
signer.signPDF(pdfInputStream, signedStream, certificateName, password, contentType, recognized, textoAdicional, stampOptions,top, left, height,width,rotation, allowMultipleSignature);
|