From 1d83dd9a304c35cc6ec7994504c42fbd403719f1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Mar 2014 18:23:39 +0100 Subject: Extract secureSignatureCreationDevice and IssuerCountryCode from MOA 1.5.2 response --- .../at/gv/egiz/pdfas/api/verify/VerifyResult.java | 14 ++++++++++++++ .../pdfas/impl/api/verify/VerifyResultAdapter.java | 10 +++++++++- .../wag/egov/egiz/sig/SignatureResponse.java | 20 ++++++++++++++++++++ .../wag/egov/egiz/sig/connectors/MOAConnector.java | 20 +++++++++++++++++++- .../wag/egov/egiz/sig/connectors/bku/BKUHelper.java | 20 ++++++++++++++++++++ 5 files changed, 82 insertions(+), 2 deletions(-) diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java index fb48e5e..52aa10f 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java @@ -80,6 +80,13 @@ public interface VerifyResult extends SignatureInformation */ public boolean isQualifiedCertificate(); + /** + * Returns the null if no secure signing devices was used, or "certificate" or "TSL" if a secure signing devices was used. + * + * @return Returns the null if no secure signing devices was used, or "certificate" or "TSL" if a secure signing devices was used. + */ + public String getSecureSignatureCreationDevice(); + /** * Returns {@code true} if public authority is indicated. * @return {@code true} if public authority. @@ -176,4 +183,11 @@ public interface VerifyResult extends SignatureInformation */ public XMLDsigData getReconstructedXMLDsig(); + /** + * Returns the issuer country code. + * + * @return Returns the issuer country code. + */ + public String getIssuerCountryCode(); + } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java index 09d247d..713a6dd 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java @@ -61,7 +61,6 @@ public class VerifyResultAdapter extends SignatureInformationAdapter implements private String timestamp; private XMLDsigData xmlDsigData; - /** * Constructor. @@ -201,5 +200,14 @@ public class VerifyResultAdapter extends SignatureInformationAdapter implements public XMLDsigData getReconstructedXMLDsig() { return this.xmlDsigData; } + + + public String getSecureSignatureCreationDevice() { + return this.sigRes.getSecureSignatureCreationDevice(); + } + + public String getIssuerCountryCode() { + return this.sigRes.getIssuerCountryCode(); + } } diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java index 1756fa3..c294dae 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java @@ -111,6 +111,9 @@ public class SignatureResponse private boolean qualifiedCertificate = false; // [tknall] stop qualified certificate + private String secureSignatureCreationDevice; + private String issuerCountryCode; + private boolean publicAuthority = false; private String publicAuthorityCode = null; @@ -541,6 +544,23 @@ public class SignatureResponse return props; } + + public String getSecureSignatureCreationDevice() { + return secureSignatureCreationDevice; + } + + public void setSecureSignatureCreationDevice( + String secureSignatureCreationDevice) { + this.secureSignatureCreationDevice = secureSignatureCreationDevice; + } + + public String getIssuerCountryCode() { + return issuerCountryCode; + } + + public void setIssuerCountryCode(String issuerCountryCode) { + this.issuerCountryCode = issuerCountryCode; + } /** * The toString method diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java index d413a29..a56f807 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java @@ -646,6 +646,13 @@ public class MOAConnector implements Connector Pattern cert_qualified_p = Pattern.compile(""); Matcher cert_qualified_m = cert_qualified_p.matcher(xmlResponse); // [tknall] stop qualified certificate + + String secureSignatureCreationDevice_certificate = "";//TODO use XPATH + String secureSignatureCreationDevice_tsl = "";//TODO use XPATH + Pattern issuerCountryCode_p_s = Pattern.compile(""); + Pattern issuerCountryCode_p_e = Pattern.compile(""); + Matcher issuerCountryCode_m_s = issuerCountryCode_p_s.matcher(xmlResponse); + Matcher issuerCountryCode_m_e = issuerCountryCode_p_e.matcher(xmlResponse); Pattern sig_chk_p_s = Pattern.compile(""); Pattern sig_chk_p_e = Pattern.compile(""); @@ -682,7 +689,18 @@ public class MOAConnector implements Connector // [tknall] start qualified certificate sig_res.setQualifiedCertificate(cert_qualified_m.find()); // [tknall] stop qualified certificate - + + sig_res.setSecureSignatureCreationDevice(null);//TODO use XPATH + if(xmlResponse.contains(secureSignatureCreationDevice_tsl)) + sig_res.setSecureSignatureCreationDevice("TSL"); + if(xmlResponse.contains(secureSignatureCreationDevice_certificate)) + sig_res.setSecureSignatureCreationDevice("Certificate"); + + try{ + String issuerCountry = xmlResponse.substring(issuerCountryCode_m_s.end(), issuerCountryCode_m_e.start()); + sig_res.setIssuerCountryCode(issuerCountry); + }catch(Exception e){logger_.debug("IssuerCountryCode not found in MOA response");} + // public authority Pattern publicAuthority_p = Pattern.compile(""); Matcher publicAuthority_m = publicAuthority_p.matcher(xmlResponse); diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java index 908ed57..5aff091 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java @@ -458,6 +458,13 @@ public final class BKUHelper Matcher cert_qualified_m = cert_qualified_p.matcher(xmlResponse); // [tknall] stop qualified certificate + String secureSignatureCreationDevice_certificate = "";//TODO use XPATH + String secureSignatureCreationDevice_tsl = "";//TODO use XPATH + Pattern issuerCountryCode_p_s = Pattern.compile(""); + Pattern issuerCountryCode_p_e = Pattern.compile(""); + Matcher issuerCountryCode_m_s = issuerCountryCode_p_s.matcher(xmlResponse); + Matcher issuerCountryCode_m_e = issuerCountryCode_p_e.matcher(xmlResponse); + Pattern code_p_s = Pattern.compile("<[\\w]*:?Code>"); //$NON-NLS-1$ Pattern code_p_e = Pattern.compile(""); //$NON-NLS-1$ Pattern info_p_s = Pattern.compile("<[\\w]*:?Info>"); //$NON-NLS-1$ @@ -517,6 +524,19 @@ public final class BKUHelper sig_res.setQualifiedCertificate(cert_qualified_m.find()); // [tknall] stop qualified certificate + + sig_res.setSecureSignatureCreationDevice(null);//TODO use XPATH + if(xmlResponse.contains(secureSignatureCreationDevice_tsl)) + sig_res.setSecureSignatureCreationDevice("TSL"); + if(xmlResponse.contains(secureSignatureCreationDevice_certificate)) + sig_res.setSecureSignatureCreationDevice("Certificate"); + + try{ + String issuerCountry = xmlResponse.substring(issuerCountryCode_m_s.end(), issuerCountryCode_m_e.start()); + sig_res.setIssuerCountryCode(issuerCountry); + }catch(Exception e){log.debug("IssuerCountryCode not found in MOA response");} + + if (hash_data_m_s.find() && hash_data_m_e.find()) { String hashInputData = xmlResponse.substring(hash_data_m_s.end(), hash_data_m_e.start()); -- cgit v1.2.3