aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/sig
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-06-11 12:09:06 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-06-11 12:09:06 +0000
commit046cb5b235866e66ca9d2c55bd20ed7ec85ef12d (patch)
treee13d9e2394d62945656c2b3309094bb37317c3c7 /src/main/java/at/knowcenter/wag/egov/egiz/sig
parentbe7c4af867e8f9144fdf88cb84ea92268d82f8ec (diff)
downloadpdf-as-3-046cb5b235866e66ca9d2c55bd20ed7ec85ef12d.tar.gz
pdf-as-3-046cb5b235866e66ca9d2c55bd20ed7ec85ef12d.tar.bz2
pdf-as-3-046cb5b235866e66ca9d2c55bd20ed7ec85ef12d.zip
Serious bug solved. Method storeCertificate tried to fetch a certificate from store before storing it. If not found (within the store resp. via ldap) the certificate was not stored.
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@282 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java14
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java21
2 files changed, 32 insertions, 3 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
index b4818cd..1b9b6a6 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
@@ -696,9 +696,12 @@ public class SignatureObject implements Serializable
{
try
{
- byte [] der = cert.getEncoded();
- String certStr = CodingHelper.encodeBase64(der);
- setX509Certificate(certStr);
+// byte [] der = cert.getEncoded();
+// String certStr = CodingHelper.encodeBase64(der);
+// setX509Certificate(certStr);
+ X509Cert knowcenterCert = X509Cert.initByX509Certificate(cert);
+ setSigValue(SIG_CER, knowcenterCert.getCertString());
+ storeCertificate(cert.getSerialNumber().toString(), knowcenterCert.getIssuerName(), knowcenterCert.getCertString(), knowcenterCert.getCertDigest());
}
catch (CertificateEncodingException e)
{
@@ -1322,17 +1325,20 @@ public class SignatureObject implements Serializable
boolean store_complete = false;
if (issuer != null && serialNumber != null)
{
+ logger_.debug("Storing certificate.");
// String issuer_b64 = CodingHelper.encodeBase64(issuer.getBytes());
String iss_hash = getIssuerFileHash(issuer);
File cert_path_dir = new File(certPath_);
if (!cert_path_dir.exists())
{
+ logger_.debug("Certstore path \"" + cert_path_dir + "\" does not exist. Creating.");
cert_path_dir.mkdir();
}
String cert_store_path = certPath_ + iss_hash;
File cert_store_dir = new File(cert_store_path);
if (!cert_store_dir.exists())
{
+ logger_.debug("Certstore dir \"" + cert_store_dir + "\" does not exist. Creating.");
cert_store_dir.mkdir();
}
if (cert_store_dir.isDirectory())
@@ -1344,6 +1350,8 @@ public class SignatureObject implements Serializable
}
boolean store_cert_file = FileHelper.writeToFile(cert_file_name, x509Certificate);
store_complete = store_cert_file;// && store_cert_meta;
+ } else {
+ logger_.warn("Certstore dir \"" + cert_store_dir + "\" is not a directory. Skipping storage.");
}
}
return store_complete;
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java
index 71ca754..148ac41 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java
@@ -166,6 +166,27 @@ public class X509Cert implements Serializable
}
return x509_cert;
}
+
+ public static X509Cert initByX509Certificate(X509Certificate cert) throws CertificateEncodingException {
+ X509Cert x509_cert = new X509Cert();
+ x509_cert.setX509Cert(cert);
+ x509_cert.setCertString(CodingHelper.encodeBase64(cert.getEncoded()));
+
+ String serial_num = cert.getSerialNumber().toString();
+ String issuer = cert.getIssuerDN().getName();
+ issuer = issuer.replaceAll(", ", ",");
+ String subject_name = cert.getSubjectDN().getName();
+ x509_cert.setSerialNumber(serial_num);
+ x509_cert.setIssuerName(issuer);
+ x509_cert.setSubjectName(subject_name);
+ if (logger_.isDebugEnabled())
+ {
+ logger_.debug("Serial number from certificate:" + serial_num);
+ logger_.debug("Issuer name from certificate :" + issuer);
+ logger_.debug("Subject name from certificate :" + subject_name);
+ }
+ return x509_cert;
+ }
public static X509Cert initByByteArray(byte[] data)
{