aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2006-12-01 13:12:05 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2006-12-01 13:12:05 +0000
commit3f351b6572f3da47aa3e1d76770302fe5ccf49f2 (patch)
treea91ef1ae25c7401eb9933221bd7e61234a2c344b /src/main/java
parent6025b6016517c6d898d8957d1d7e03ba71431912 (diff)
downloadpdf-as-3-3f351b6572f3da47aa3e1d76770302fe5ccf49f2.tar.gz
pdf-as-3-3f351b6572f3da47aa3e1d76770302fe5ccf49f2.tar.bz2
pdf-as-3-3f351b6572f3da47aa3e1d76770302fe5ccf49f2.zip
ldap-api support added
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@6 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java19
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/LDAPAPI.java25
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java103
3 files changed, 133 insertions, 14 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java
index 7e0834e..c771b06 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java
@@ -13,7 +13,7 @@
* LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES.
*
- * $Id: DummyLDAPAPI.java,v 1.3 2006/10/31 08:18:56 wprinz Exp $
+ * $Id: DummyLDAPAPI.java,v 1.2 2006/08/25 17:09:41 wprinz Exp $
*/
package at.knowcenter.wag.egov.egiz.sig;
@@ -27,8 +27,9 @@ import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
* implemented.
*
* @author wprinz
+ * @author modified by <a href="mailto:thomas.knall@iaik.tugraz.at">Thomas Knall</a>
*/
-public class DummyLDAPAPI
+public class DummyLDAPAPI implements LDAPAPI
{
String url_ = null;
@@ -37,15 +38,21 @@ public class DummyLDAPAPI
this.url_ = url;
}
- public String getURL()
+ /* (non-Javadoc)
+ * @see at.knowcenter.wag.egov.egiz.sig.LDAPAPI#getURL(String)
+ */
+ public String getURL(String issuer)
{
return this.url_;
}
- public byte[] loadCertificateFromLDAP(String serial_number, String issuer)
+ /* (non-Javadoc)
+ * @see at.knowcenter.wag.egov.egiz.sig.LDAPAPI#loadCertificateFromLDAP(java.lang.String, java.lang.String)
+ */
+public byte[] loadBase64CertificateFromLDAP(String serial_number, String issuer)
{
- //logger.debug("LDAP: serial_number = " + serial_number);
- //logger.debug("LDAP: issuer = " + issuer);
+ //System.out.println("LDAP: serial_number = " + serial_number);
+ //System.out.println("LDAP: issuer = " + issuer);
byte[] data = null;
if (serial_number.equals("153868") && issuer.equals("CN=a-sign-TEST-Premium-Sig-01,OU=a-sign-TEST-Premium-Sig-01,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT"))
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/LDAPAPI.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/LDAPAPI.java
new file mode 100644
index 0000000..143c34b
--- /dev/null
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/LDAPAPI.java
@@ -0,0 +1,25 @@
+package at.knowcenter.wag.egov.egiz.sig;
+
+/**
+ * @author <a href="mailto:thomas.knall@iaik.tugraz.at">Thomas Knall</a>
+ */
+public interface LDAPAPI {
+
+ public static final String SYS_PROP_IMPLEMENTATION = "pdfas.ldapapi.impl";
+
+ /**
+ * Returns the url of the ldap server.
+ * @param issuer The issuer name.
+ * @return The ldap url.
+ */
+ public String getURL(String issuer);
+
+ /**
+ * Retrieves an certificate from the ldap server identified by serial number and issuer name.
+ * @param serialNumber The serial number.
+ * @param issuer The issuer name.
+ * @return BASE64 encoded certificate
+ */
+ public byte[] loadBase64CertificateFromLDAP(String serialNumber, String issuer);
+
+} \ No newline at end of file
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 087ce4e..0d89460 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
@@ -13,16 +13,18 @@
* LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES.
*
- * $Id: SignatureObject.java,v 1.7 2006/10/31 08:18:56 wprinz Exp $
+ * $Id: SignatureObject.java,v 1.5 2006/08/25 17:09:41 wprinz Exp $
*/
package at.knowcenter.wag.egov.egiz.sig;
+import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -35,6 +37,7 @@ import org.apache.log4j.Logger;
import at.knowcenter.wag.egov.egiz.PdfASID;
import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
+import at.knowcenter.wag.egov.egiz.exceptions.ErrorCodeException;
import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException;
import at.knowcenter.wag.egov.egiz.exceptions.NormalizeException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException;
@@ -58,6 +61,7 @@ import at.knowcenter.wag.egov.egiz.tools.Normalizer;
* in the settings file.
*
* @author wlackner
+ * @author modified by <a href="mailto:thomas.knall@iaik.tugraz.at">Thomas Knall</a>
*/
public class SignatureObject implements Serializable
{
@@ -244,7 +248,7 @@ public class SignatureObject implements Serializable
defaultImageStyle_.setPadding(3);
defaultImageStyle_.setHAlign(Style.CENTER);
defaultImageStyle_.setVAlign(Style.MIDDLE);
- defaultImageStyle_.setBgColor(null);
+ defaultImageStyle_.setBgColor(new Color(255, 255, 255));
defaultCaptionStyle_.setHAlign(Style.CENTER);
defaultCaptionStyle_.setVAlign(Style.MIDDLE);
@@ -720,7 +724,10 @@ public class SignatureObject implements Serializable
*/
public void setSignationIDs(String[] sigIds)
{
- String join = "";
+
+ // TODO[tknall]: implement workaround resp. failsafe behaviour for ids like "Signature-123456789"
+
+ String join = "";
String base = null;
for (int arr_idx = 0; arr_idx < sigIds.length; arr_idx++)
{
@@ -1055,8 +1062,9 @@ public class SignatureObject implements Serializable
* @return Returns the DER certificate file as can be stored in the local
* repository. Returns null, if the document wasn't found on the
* server.
+ * @throws ClassNotFoundException
*/
- protected byte[] loadCertificateFromLDAP(String serialNumber, String issuer)
+ protected byte[] loadCertificateFromLDAP(String serialNumber, String issuer)
{
String ldap_server_url = null;
try
@@ -1071,10 +1079,36 @@ public class SignatureObject implements Serializable
}
logger_.debug("LDAP server url = " + ldap_server_url);
- // TODO connect to LDAP using the EGIZ API.
- DummyLDAPAPI api = new DummyLDAPAPI(ldap_server_url);
- byte[] cert = api.loadCertificateFromLDAP(serialNumber, issuer);
-
+ // START modification by TK
+ byte[] cert = null;
+ String implClassURI = System.getProperty(LDAPAPI.SYS_PROP_IMPLEMENTATION);
+ if (implClassURI != null && !"".equals(implClassURI)) {
+ LDAPAPI ldapAPIImpl = null;
+ try {
+ Class clazz = Class.forName(implClassURI);
+ Object ldapAPIImplObj = clazz.newInstance();
+ if (!(ldapAPIImplObj instanceof LDAPAPI)) {
+ throw new RuntimeException("Declared class does not implement \"" + LDAPAPI.class.getName() + "\".");
+ }
+ ldapAPIImpl = (LDAPAPI) ldapAPIImplObj;
+ cert = ldapAPIImpl.loadBase64CertificateFromLDAP(serialNumber, issuer);
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Declared implementation of \"" + LDAPAPI.class.getName() + "\" cannot be instantiated.");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Declared implementation of \"" + LDAPAPI.class.getName() + "\" cannot be instantiated (illegal access).");
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Unable to find class \"" + implClassURI + "\" as implementation of \"" + LDAPAPI.class.getName() + "\".");
+ }
+ if (cert == null) {
+ logger_.warn("Unable to retrieve certificate (serial=\"" + serialNumber + "\", issuer=\"" + issuer + "\") via ldap server \"" + ldapAPIImpl.getURL(issuer) + "\".");
+ }
+
+ } else {
+ logger_.warn("There was no implementation of \"" + LDAPAPI.class.getName() + "\" defined by system property \"" + LDAPAPI.SYS_PROP_IMPLEMENTATION + "\". Using fallback implementation \"" + DummyLDAPAPI.class.getName() + "\".");
+ LDAPAPI api = new DummyLDAPAPI(ldap_server_url);
+ cert = api.loadBase64CertificateFromLDAP(serialNumber, issuer);
+ }
+ // STOP modification by TK
return cert;
}
@@ -1496,4 +1530,57 @@ public class SignatureObject implements Serializable
return strg;
}
+ // /**
+ // * Used only for testing!
+ // *
+ // * @param args
+ // */
+ // public static void main(String[] args)
+ // {
+ //
+ // String sig_strg1 = " Verfahren
+ // urn:publicid:egov.graz.gv.at:AS+bescheid+tb-1.0 Datum 2006-01-18T14:57:33
+ // Inhaber A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH ,
+ // a-sign-corporate-light-02 Aussteller
+ // CN=a-sign-corporate-light-02,OU=a-sign-corporate-light-02,O=A-Trust Ges. f.
+ // Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT Seriennummer 86710
+ // Signaturwert
+ // p/EdZadVe0LPoWtvkMQmsCtH7nwH5Bm9hV0+lfSdT8k4oeKlNtqwNIYFm1mpGd3B
+ // bgggEtSvth/sbsm0BYMse33j3lYxYvT+kdui8QNa+iHCm23S2YdvzrTtay6/DSgZ
+ // 48c7vmMR7wOKNZsVx2SrZgoD4XK+xag9CCsbjGeEyyM= Hinweis: Dieses Dokument ist
+ // nur in elektronischer Form gültig!";
+ // String sig_strg2 = " Signiert von BMI SU-ZMR Datum 2006-02-08T15:03:07
+ // Zertifikat A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,
+ // a-sign-corporate-light-02, AT (80524) Verfahren
+ // urn:publicid:bmi.gv.at:ZP+bescheid+mb-1.2 Seriennummer 1234 56789
+ // Signaturwert
+ // c27g+sQ57rMYg6MaOjQ206VSQzkSszR/715RO/ZR3UYptP+YST7l9BEX1vUBi+3W
+ // h4oDEJtHJ+ubWfiu7yG8xWzmtCFwJLe1Ubg94v8SWCUgd2xg/PsN52+K6wolZF/i
+ // 0M1RTzFA2QisL3xKSVSw8h0pGp0r3/kigcQaCJ7AH1M= Weitere Hinweise zu dieser
+ // elektronischen Meldebestätigung finden Sie unter
+ // https://meldung.cio.gv.at/egovMB/info/mb_info.html,Informationen zur
+ // Signatur unter https://meldung.cio.gv.at/egovMB/info/mb_sig.html";
+ // String sig_strg3 = "Signaturwert
+ // c27g+sQ57rMYg6MaOjQ206VSQzkSszR/715RO/ZR3UYptP+YST7l9BEX1vUBi+3W
+ // h4oDEJtHJ+ubWfiu7yG8xWzmtCFwJLe1Ubg94v8SWCUgd2xg/PsN52+K6wolZF/i
+ // 0M1RTzFA2QisL3xKSVSw8h0pGp0r3/kigcQaCJ7AH1M= Datum 2006-02-08T15:03:07
+ // Unterzeichner Franz Morak Aussteller
+ // CN=a-sign-corporate-light-02,OU=a-sign-corporate-light-02,O=A-Trust Ges. f.
+ // Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT Seriennummer 43312
+ // Weitere Hinweise weiruqweruqweruqerqi4123491348123ß4";
+ // try
+ // {
+ // SignatureSeparator sig_sep = new SignatureSeparator();
+ // sig_sep.separateBlock(sig_strg3);
+ // SignatureObject sig_obj = sig_sep.getFirstSignatureObject();
+ // System.out.println(sig_obj.toString());
+ //
+ // Table table = sig_obj.getAbstractTable();
+ // System.out.println(table.toString());
+ // }
+ // catch (SignatureTypesException e)
+ // {
+ // e.printStackTrace();
+ // }
+ // }
} \ No newline at end of file