aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/sig
diff options
context:
space:
mode:
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.java16
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/signatureobject/SignatureObjectHelper.java14
2 files changed, 27 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 52c986a..fc58bd1 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
@@ -26,6 +26,8 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
@@ -689,6 +691,20 @@ public class SignatureObject implements Serializable
setSigValue(SIG_CER, x509Certificate);
storeCertificate(getSignationSerialNumber(), getSignationIssuer(), x509Certificate, getX509CertificateDigest());
}
+
+ public void setX509Certificate(X509Certificate cert)
+ {
+ try
+ {
+ byte [] der = cert.getEncoded();
+ String certStr = CodingHelper.encodeBase64(der);
+ setX509Certificate(certStr);
+ }
+ catch (CertificateEncodingException e)
+ {
+ logger_.error(e);
+ }
+ }
/**
* return the 509v3 certificate of the given serialNumber and the given issuer
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/signatureobject/SignatureObjectHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/signatureobject/SignatureObjectHelper.java
index 1eb432e..bb5dc86 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/signatureobject/SignatureObjectHelper.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/signatureobject/SignatureObjectHelper.java
@@ -3,11 +3,12 @@
*/
package at.knowcenter.wag.egov.egiz.sig.signatureobject;
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException;
import at.knowcenter.wag.egov.egiz.sig.SignatureObject;
+import at.knowcenter.wag.egov.egiz.sig.X509Cert;
import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject;
/**
@@ -31,17 +32,24 @@ public final class SignatureObjectHelper
so.setSignationIDs(sso.getSigID());
so.setKZ(new PdfASID(sso.getSigKZ()));
so.setSignationName(sso.getName());
+
+ so.setX509Certificate(sso.getX509Certificate());
return so;
}
- public static SignSignatureObject convertSignatureObjectToSignSignatureObject (SignatureObject so) throws InvalidIDException
+ public static SignSignatureObject convertSignatureObjectToSignSignatureObject (SignatureObject so) throws SignatureException
{
SignSignatureObject sso = new SignSignatureObject();
sso.date = so.getSignationDate();
sso.signatureValue = so.getSignationValue();
sso.issuer = so.getSignationIssuer();
- sso.x509Certificate = so.getX509Cert().getX509Certificate();
+ X509Cert cert = so.getX509Cert();
+ if (cert == null)
+ {
+ throw new SignatureException(ErrorCode.CERTIFICATE_NOT_FOUND, "so.getX509Cert returned null. No cert found.");
+ }
+ sso.x509Certificate = cert.getX509Certificate();
sso.id = so.getSignationIds();
sso.kz = so.getKZ() == null ? null : so.getKZ().toString();