From 49acb697426d3c313ad047449ea62ac1bf3f4fd0 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Thu, 18 Jul 2013 12:01:21 +0200 Subject: MOA-ID 2.x Configuration implemented -SSO deaktivated -Login with mandate and normal tested --- .../CreateXMLSignatureResponseValidator.java | 2 +- .../VerifyXMLSignatureResponseValidator.java | 2 +- .../validator/parep/ParepInputProcessorImpl.java | 486 ++++----- .../id/auth/validator/parep/ParepValidator.java | 1104 ++++++++++---------- .../validator/parep/config/ParepConfiguration.java | 762 +++++++------- 5 files changed, 1204 insertions(+), 1152 deletions(-) (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/CreateXMLSignatureResponseValidator.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/CreateXMLSignatureResponseValidator.java index 115c52688..ba7893412 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/CreateXMLSignatureResponseValidator.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/CreateXMLSignatureResponseValidator.java @@ -55,7 +55,7 @@ public class CreateXMLSignatureResponseValidator { /** Xpath expression to the dsig:Signature element */ private static final String SIGNATURE_XPATH = Constants.DSIG_PREFIX + ":Signature"; - private static final String XADES_SIGNINGTIME_PATH = Constants.XADES_1_1_1_NS_PREFIX + ":SigningTime"; + //private static final String XADES_SIGNINGTIME_PATH = Constants.XADES_1_1_1_NS_PREFIX + ":SigningTime"; /** Singleton instance. null, if none has been created. */ private static CreateXMLSignatureResponseValidator instance; diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java index 892607c16..ed826c615 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/VerifyXMLSignatureResponseValidator.java @@ -81,7 +81,7 @@ public class VerifyXMLSignatureResponseValidator { * @throws ValidateException on any validation error */ public void validate(VerifyXMLSignatureResponse verifyXMLSignatureResponse, - List identityLinkSignersSubjectDNNames, + List identityLinkSignersSubjectDNNames, String whatToCheck, boolean ignoreManifestValidationResult) throws ValidateException { diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepInputProcessorImpl.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepInputProcessorImpl.java index 88c4a8feb..a154c9ece 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepInputProcessorImpl.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepInputProcessorImpl.java @@ -83,241 +83,255 @@ public class ParepInputProcessorImpl implements ParepInputProcessor{ this.rpGivenName = rpGivenName; this.rpDateOfBirth = rpDateOfBirth; this.request = request; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.validator.parep.ParepInputProcessor#start(boolean, String, String, String, String, String, String, String, String, String, String, String) - */ - public String start( - boolean physical, String familyName, String givenName, String dateOfBirth, - String streetName, String buildingNumber, String unit, String postalCode, String municipality, - String cbFullName, String cbIdentificationType, String cbIdentificationValue) - { - // Load the form - String form = loadForm( - physical, familyName, givenName, dateOfBirth, - streetName, buildingNumber, unit, postalCode, municipality, - cbFullName, cbIdentificationType, cbIdentificationValue, ""); - try { - request.setMandator(familyName, givenName, dateOfBirth, postalCode, municipality, streetName, buildingNumber, unit, physical, cbFullName, - cbIdentificationType, cbIdentificationValue); - } catch (SZRGWClientException e) { - //e.printStackTrace(); - Logger.info(e); - return null; - } - return form; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.validator.parep.ParepInputProcessor#validate(Map, String) - */ - public String validate(Map parameters, String extErrortext) - { - - // Process the gotten parameters - String form = null; - boolean formNecessary = false; - if (!ParepUtils.isEmpty(extErrortext)) formNecessary = true; - String locErrortext = "Folgende Parameter fehlen: "; - - String familyName = (String) parameters.get("familyname_"); - if (null == familyName) familyName =""; - String givenName = (String) parameters.get("givenname_"); - if (null == givenName) givenName =""; - boolean physical = "true".equals(parameters.get("physical_")); - String dobday = (String) parameters.get("dobday_"); - if (null!=dobday && dobday.equalsIgnoreCase("TT")) dobday=""; - String dobmonth = (String) parameters.get("dobmonth_"); - if (null!=dobmonth && dobmonth.equalsIgnoreCase("MM")) dobmonth=""; - String dobyear = (String) parameters.get("dobyear_"); - if (null!=dobyear && dobyear.equalsIgnoreCase("JJJJ")) dobyear=""; - String dateOfBirth = ""; - dobyear = (" ".substring(0, 4-dobyear.length()) + dobyear); - dobmonth = (" ".substring(0, 2-dobmonth.length()) + dobmonth); - dobday = (" ".substring(0, 2-dobday.length()) + dobday); - dateOfBirth = dobyear + "-" + dobmonth + "-" + dobday; - String cbFullName = (String) parameters.get("fullname_"); - if (null == cbFullName) cbFullName =""; - String cbIdentificationType = (String) parameters.get("cbidentificationtype_"); - if (null == cbIdentificationType) cbIdentificationType =""; - String cbIdentificationValue = (String) parameters.get("cbidentificationvalue_"); - if (null == cbIdentificationValue) cbIdentificationValue =""; - String postalCode = (String) parameters.get("postalcode_"); - if (null == postalCode) postalCode =""; - String municipality = (String) parameters.get("municipality_"); - if (null == municipality) municipality =""; - String streetName = (String) parameters.get("streetname_"); - if (null == streetName) streetName =""; - String buildingNumber = (String) parameters.get("buildingnumber_"); - if (null == buildingNumber) buildingNumber =""; - String unit = (String) parameters.get("unit_"); - if (null == unit) unit =""; - - if (physical) { - if (ParepUtils.isEmpty(familyName)) { - formNecessary = true; - locErrortext = locErrortext + "Familienname"; - } - if (ParepUtils.isEmpty(givenName)) { - formNecessary = true; - if (!locErrortext.endsWith(": ")) locErrortext = locErrortext + ", "; - locErrortext = locErrortext + "Vorname"; - } - // Auf existierendes Datum prüfen - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.setLenient(false); // Wir wollen keine künstliche Pareserintelligenz, nur Datum prüfen - try { - format.parse(dateOfBirth); - } - catch(ParseException pe) - { - formNecessary = true; - if (!locErrortext.endsWith("fehlen: ")) locErrortext = locErrortext + ", "; - locErrortext = locErrortext + "korrektes Geburtsdatum"; - } - } else { - if (ParepUtils.isEmpty(cbFullName) || ParepUtils.isEmpty(cbIdentificationType) || ParepUtils.isEmpty(cbIdentificationValue)) { - formNecessary = true; - if (ParepUtils.isEmpty(cbFullName)) { - locErrortext = locErrortext + "Name der Organisation"; - } - if (ParepUtils.isEmpty(cbIdentificationType)) { - if (!locErrortext.endsWith("fehlen: ")) locErrortext = locErrortext + ", "; - locErrortext = locErrortext + "Auswahl des Registers"; - } - if (ParepUtils.isEmpty(cbIdentificationValue)) { - if (!locErrortext.endsWith("fehlen: ")) locErrortext = locErrortext + ", "; - locErrortext = locErrortext + "Ordnungsnummer im ausgewählten Register"; - } - } - } - try { - request.setMandator(familyName, givenName, dateOfBirth, postalCode, municipality, streetName, buildingNumber, unit, physical, cbFullName, - cbIdentificationType, cbIdentificationValue); - if (formNecessary) { - // Daten noch nicht vollständig oder anderer Fehler - if (locErrortext.endsWith("fehlen: ")) locErrortext =""; - String error = ""; - if (!ParepUtils.isEmpty(extErrortext)) { - error = extErrortext; - if (!ParepUtils.isEmpty(locErrortext)) error = error + "; "; - } - if (!ParepUtils.isEmpty(locErrortext)) error = error + locErrortext; - if (!ParepUtils.isEmpty(error)) { - error = "
\"Rufezeichen\"  " + error + "
"; - } - form = loadForm(physical, familyName, givenName, dateOfBirth, streetName, buildingNumber, unit, postalCode, municipality, cbFullName, cbIdentificationType, cbIdentificationValue, error); - if (form == null) { - return null; - } - } else { - return ""; // everything is ok - } - } catch (Exception e) { - //e.printStackTrace(); - Logger.info(e); - return null; - } - return form; - } - - /** - * Loads the empty user input form and replaces tag occurences with given variables - * - * @param physical - * @param familyName - * @param givenName - * @param dateOfBirth - * @param streetName - * @param buildingNumber - * @param unit - * @param postalCode - * @param municipality - * @param cbFullName - * @param cbIdentificationType - * @param cbIdentificationValue - * @param errorText - * @return - */ - private String loadForm( - boolean physical, String familyName, String givenName, String dateOfBirth, - String streetName, String buildingNumber, String unit, String postalCode, String municipality, - String cbFullName, String cbIdentificationType, String cbIdentificationValue, String errorText) - { - String form = ""; - try { - String fileName = parepConfiguration.getInputProcessorTemplate(representationID); - InputStream instream = null; - File file = new File(fileName); - if (file.exists()) { - //if this resolves to a file, load it - instream = new FileInputStream(fileName); - } else { - fileName = parepConfiguration.getFullDirectoryName(fileName); - if (fileName.startsWith("file:\\")) fileName = fileName.substring(6); - file = new File(fileName); - if (file.exists()) { - //if this resolves to a file, load it - instream = new FileInputStream(fileName); - } else { - //else load a named resource in our classloader. - instream = this.getClass().getResourceAsStream(parepConfiguration.getInputProcessorTemplate(representationID)); - if (instream == null) { - Logger.error("Form Prozessor Input Template \"" + fileName + "\" fehlt"); - return null; - } - } - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ParepUtils.dumpInputOutputStream(instream, bos); - form = bos.toString("UTF-8"); - } catch(Exception e) { - Logger.error("Fehler beim Einlesen des Input-Templates.", e); - } - - if (!ParepUtils.isEmpty(form)) { - boolean cbEnabled = parepConfiguration.isRepresentingCorporateParty(representationID); - boolean physEnabled = parepConfiguration.isRepresentingPhysicalParty(representationID); - boolean reducedSelection = (!physEnabled || !cbEnabled); - if (reducedSelection) { - physical = !cbEnabled;//wird somit umgesetzt falls jur. Person nicht vetretbar - } - if (ParepUtils.isEmpty(dateOfBirth)) dateOfBirth = "JJJJ-MM-TT"; - form = ParepUtils.replaceAll(form, "", rpGivenName); - form = ParepUtils.replaceAll(form, "", rpFamilyName); - form = ParepUtils.replaceAll(form, "", rpDateOfBirth.substring(0,4)); - form = ParepUtils.replaceAll(form, "", rpDateOfBirth.substring(5,7)); - form = ParepUtils.replaceAll(form, "", rpDateOfBirth.substring(8,10)); - //darf zw. phys. und jur. Person gewählt werden: - //form = replaceAll(form, "seldisabled=\"\"", reducedSelection ? "disabled=\"true\"" : ""); - form = ParepUtils.replaceAll(form, "physdisabled=\"\"", physEnabled ? "" : "disabled=\"true\""); - form = ParepUtils.replaceAll(form, "physselected=\"\"", physical ? "checked=\"checked\"" : ""); - form = ParepUtils.replaceAll(form, "", givenName); - form = ParepUtils.replaceAll(form, "", familyName); - form = ParepUtils.replaceAll(form, "", dateOfBirth.substring(0,4).trim()); - form = ParepUtils.replaceAll(form, "", dateOfBirth.substring(5,7).trim()); - form = ParepUtils.replaceAll(form, "", dateOfBirth.substring(8,10).trim()); - form = ParepUtils.replaceAll(form, "", streetName); - form = ParepUtils.replaceAll(form, "", buildingNumber); - form = ParepUtils.replaceAll(form, "", unit); - form = ParepUtils.replaceAll(form, "", postalCode); - form = ParepUtils.replaceAll(form, "", municipality); - form = ParepUtils.replaceAll(form, "cbdisabled=\"\"", cbEnabled ? "" : "disabled=\"true\""); - form = ParepUtils.replaceAll(form, "", cbFullName); - form = ParepUtils.replaceAll(form, "cbseldisabled=\"\"", cbEnabled ? "" : "disabled=\"disabled\""); - form = ParepUtils.replaceAll(form, "cbselected=\"\"", physical ? "" : "checked=\"checked\""); - form = ParepUtils.replaceAll(form, "fnselected=\"\"", cbIdentificationType.equals("urn:publicid:gv.at:baseid+XFN") ? "selected=\"selected\"" : ""); - form = ParepUtils.replaceAll(form, "vrselected=\"\"", cbIdentificationType.equals("urn:publicid:gv.at:baseid+XVR") ? "selected=\"selected\"" : ""); - form = ParepUtils.replaceAll(form, "ersbselected=\"\"", cbIdentificationType.equals("urn:publicid:gv.at:baseid+XERSB") ? "selected=\"selected\"" : ""); - form = ParepUtils.replaceAll(form, "", cbIdentificationValue); - form = ParepUtils.replaceAll(form, "", errorText); - } - return form; - } + } + +public String start(boolean physical, String familyName, String givenName, + String dateOfBirth, String streetName, String buildingNumber, + String unit, String postalCode, String municipality, String cbFullName, + String cbIdentificationType, String cbIdentificationValue) { + // TODO Auto-generated method stub + return null; +} + +public String validate(Map parameters, String extErrortext) { + // TODO Auto-generated method stub + return null; +} + + //TODO: check correctness +// /* +// * (non-Javadoc) +// * +// * @see at.gv.egovernment.moa.id.auth.validator.parep.ParepInputProcessor#start(boolean, String, String, String, String, String, String, String, String, String, String, String) +// */ +// public String start( +// boolean physical, String familyName, String givenName, String dateOfBirth, +// String streetName, String buildingNumber, String unit, String postalCode, String municipality, +// String cbFullName, String cbIdentificationType, String cbIdentificationValue) +// { +// // Load the form +// String form = loadForm( +// physical, familyName, givenName, dateOfBirth, +// streetName, buildingNumber, unit, postalCode, municipality, +// cbFullName, cbIdentificationType, cbIdentificationValue, ""); +// try { +// request.setMandator(familyName, givenName, dateOfBirth, postalCode, municipality, streetName, buildingNumber, unit, physical, cbFullName, +// cbIdentificationType, cbIdentificationValue); +// } catch (SZRGWClientException e) { +// //e.printStackTrace(); +// Logger.info(e); +// return null; +// } +// return form; +// } +// +// /* +// * (non-Javadoc) +// * +// * @see at.gv.egovernment.moa.id.auth.validator.parep.ParepInputProcessor#validate(Map, String) +// */ +// public String validate(Map parameters, String extErrortext) +// { +// +// // Process the gotten parameters +// String form = null; +// boolean formNecessary = false; +// if (!ParepUtils.isEmpty(extErrortext)) formNecessary = true; +// String locErrortext = "Folgende Parameter fehlen: "; +// +// String familyName = (String) parameters.get("familyname_"); +// if (null == familyName) familyName =""; +// String givenName = (String) parameters.get("givenname_"); +// if (null == givenName) givenName =""; +// boolean physical = "true".equals(parameters.get("physical_")); +// String dobday = (String) parameters.get("dobday_"); +// if (null!=dobday && dobday.equalsIgnoreCase("TT")) dobday=""; +// String dobmonth = (String) parameters.get("dobmonth_"); +// if (null!=dobmonth && dobmonth.equalsIgnoreCase("MM")) dobmonth=""; +// String dobyear = (String) parameters.get("dobyear_"); +// if (null!=dobyear && dobyear.equalsIgnoreCase("JJJJ")) dobyear=""; +// String dateOfBirth = ""; +// dobyear = (" ".substring(0, 4-dobyear.length()) + dobyear); +// dobmonth = (" ".substring(0, 2-dobmonth.length()) + dobmonth); +// dobday = (" ".substring(0, 2-dobday.length()) + dobday); +// dateOfBirth = dobyear + "-" + dobmonth + "-" + dobday; +// String cbFullName = (String) parameters.get("fullname_"); +// if (null == cbFullName) cbFullName =""; +// String cbIdentificationType = (String) parameters.get("cbidentificationtype_"); +// if (null == cbIdentificationType) cbIdentificationType =""; +// String cbIdentificationValue = (String) parameters.get("cbidentificationvalue_"); +// if (null == cbIdentificationValue) cbIdentificationValue =""; +// String postalCode = (String) parameters.get("postalcode_"); +// if (null == postalCode) postalCode =""; +// String municipality = (String) parameters.get("municipality_"); +// if (null == municipality) municipality =""; +// String streetName = (String) parameters.get("streetname_"); +// if (null == streetName) streetName =""; +// String buildingNumber = (String) parameters.get("buildingnumber_"); +// if (null == buildingNumber) buildingNumber =""; +// String unit = (String) parameters.get("unit_"); +// if (null == unit) unit =""; +// +// if (physical) { +// if (ParepUtils.isEmpty(familyName)) { +// formNecessary = true; +// locErrortext = locErrortext + "Familienname"; +// } +// if (ParepUtils.isEmpty(givenName)) { +// formNecessary = true; +// if (!locErrortext.endsWith(": ")) locErrortext = locErrortext + ", "; +// locErrortext = locErrortext + "Vorname"; +// } +// // Auf existierendes Datum prüfen +// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); +// format.setLenient(false); // Wir wollen keine künstliche Pareserintelligenz, nur Datum prüfen +// try { +// format.parse(dateOfBirth); +// } +// catch(ParseException pe) +// { +// formNecessary = true; +// if (!locErrortext.endsWith("fehlen: ")) locErrortext = locErrortext + ", "; +// locErrortext = locErrortext + "korrektes Geburtsdatum"; +// } +// } else { +// if (ParepUtils.isEmpty(cbFullName) || ParepUtils.isEmpty(cbIdentificationType) || ParepUtils.isEmpty(cbIdentificationValue)) { +// formNecessary = true; +// if (ParepUtils.isEmpty(cbFullName)) { +// locErrortext = locErrortext + "Name der Organisation"; +// } +// if (ParepUtils.isEmpty(cbIdentificationType)) { +// if (!locErrortext.endsWith("fehlen: ")) locErrortext = locErrortext + ", "; +// locErrortext = locErrortext + "Auswahl des Registers"; +// } +// if (ParepUtils.isEmpty(cbIdentificationValue)) { +// if (!locErrortext.endsWith("fehlen: ")) locErrortext = locErrortext + ", "; +// locErrortext = locErrortext + "Ordnungsnummer im ausgewählten Register"; +// } +// } +// } +// try { +// request.setMandator(familyName, givenName, dateOfBirth, postalCode, municipality, streetName, buildingNumber, unit, physical, cbFullName, +// cbIdentificationType, cbIdentificationValue); +// if (formNecessary) { +// // Daten noch nicht vollständig oder anderer Fehler +// if (locErrortext.endsWith("fehlen: ")) locErrortext =""; +// String error = ""; +// if (!ParepUtils.isEmpty(extErrortext)) { +// error = extErrortext; +// if (!ParepUtils.isEmpty(locErrortext)) error = error + "; "; +// } +// if (!ParepUtils.isEmpty(locErrortext)) error = error + locErrortext; +// if (!ParepUtils.isEmpty(error)) { +// error = "
\"Rufezeichen\"  " + error + "
"; +// } +// form = loadForm(physical, familyName, givenName, dateOfBirth, streetName, buildingNumber, unit, postalCode, municipality, cbFullName, cbIdentificationType, cbIdentificationValue, error); +// if (form == null) { +// return null; +// } +// } else { +// return ""; // everything is ok +// } +// } catch (Exception e) { +// //e.printStackTrace(); +// Logger.info(e); +// return null; +// } +// return form; +// } +// +// /** +// * Loads the empty user input form and replaces tag occurences with given variables +// * +// * @param physical +// * @param familyName +// * @param givenName +// * @param dateOfBirth +// * @param streetName +// * @param buildingNumber +// * @param unit +// * @param postalCode +// * @param municipality +// * @param cbFullName +// * @param cbIdentificationType +// * @param cbIdentificationValue +// * @param errorText +// * @return +// */ +// private String loadForm( +// boolean physical, String familyName, String givenName, String dateOfBirth, +// String streetName, String buildingNumber, String unit, String postalCode, String municipality, +// String cbFullName, String cbIdentificationType, String cbIdentificationValue, String errorText) +// { +// String form = ""; +// try { +// String fileName = parepConfiguration.getInputProcessorTemplate(representationID); +// InputStream instream = null; +// File file = new File(fileName); +// if (file.exists()) { +// //if this resolves to a file, load it +// instream = new FileInputStream(fileName); +// } else { +// fileName = parepConfiguration.getFullDirectoryName(fileName); +// if (fileName.startsWith("file:\\")) fileName = fileName.substring(6); +// file = new File(fileName); +// if (file.exists()) { +// //if this resolves to a file, load it +// instream = new FileInputStream(fileName); +// } else { +// //else load a named resource in our classloader. +// instream = this.getClass().getResourceAsStream(parepConfiguration.getInputProcessorTemplate(representationID)); +// if (instream == null) { +// Logger.error("Form Prozessor Input Template \"" + fileName + "\" fehlt"); +// return null; +// } +// } +// } +// ByteArrayOutputStream bos = new ByteArrayOutputStream(); +// ParepUtils.dumpInputOutputStream(instream, bos); +// form = bos.toString("UTF-8"); +// } catch(Exception e) { +// Logger.error("Fehler beim Einlesen des Input-Templates.", e); +// } +// +// if (!ParepUtils.isEmpty(form)) { +// boolean cbEnabled = parepConfiguration.isRepresentingCorporateParty(representationID); +// boolean physEnabled = parepConfiguration.isRepresentingPhysicalParty(representationID); +// boolean reducedSelection = (!physEnabled || !cbEnabled); +// if (reducedSelection) { +// physical = !cbEnabled;//wird somit umgesetzt falls jur. Person nicht vetretbar +// } +// if (ParepUtils.isEmpty(dateOfBirth)) dateOfBirth = "JJJJ-MM-TT"; +// form = ParepUtils.replaceAll(form, "", rpGivenName); +// form = ParepUtils.replaceAll(form, "", rpFamilyName); +// form = ParepUtils.replaceAll(form, "", rpDateOfBirth.substring(0,4)); +// form = ParepUtils.replaceAll(form, "", rpDateOfBirth.substring(5,7)); +// form = ParepUtils.replaceAll(form, "", rpDateOfBirth.substring(8,10)); +// //darf zw. phys. und jur. Person gewählt werden: +// //form = replaceAll(form, "seldisabled=\"\"", reducedSelection ? "disabled=\"true\"" : ""); +// form = ParepUtils.replaceAll(form, "physdisabled=\"\"", physEnabled ? "" : "disabled=\"true\""); +// form = ParepUtils.replaceAll(form, "physselected=\"\"", physical ? "checked=\"checked\"" : ""); +// form = ParepUtils.replaceAll(form, "", givenName); +// form = ParepUtils.replaceAll(form, "", familyName); +// form = ParepUtils.replaceAll(form, "", dateOfBirth.substring(0,4).trim()); +// form = ParepUtils.replaceAll(form, "", dateOfBirth.substring(5,7).trim()); +// form = ParepUtils.replaceAll(form, "", dateOfBirth.substring(8,10).trim()); +// form = ParepUtils.replaceAll(form, "", streetName); +// form = ParepUtils.replaceAll(form, "", buildingNumber); +// form = ParepUtils.replaceAll(form, "", unit); +// form = ParepUtils.replaceAll(form, "", postalCode); +// form = ParepUtils.replaceAll(form, "", municipality); +// form = ParepUtils.replaceAll(form, "cbdisabled=\"\"", cbEnabled ? "" : "disabled=\"true\""); +// form = ParepUtils.replaceAll(form, "", cbFullName); +// form = ParepUtils.replaceAll(form, "cbseldisabled=\"\"", cbEnabled ? "" : "disabled=\"disabled\""); +// form = ParepUtils.replaceAll(form, "cbselected=\"\"", physical ? "" : "checked=\"checked\""); +// form = ParepUtils.replaceAll(form, "fnselected=\"\"", cbIdentificationType.equals("urn:publicid:gv.at:baseid+XFN") ? "selected=\"selected\"" : ""); +// form = ParepUtils.replaceAll(form, "vrselected=\"\"", cbIdentificationType.equals("urn:publicid:gv.at:baseid+XVR") ? "selected=\"selected\"" : ""); +// form = ParepUtils.replaceAll(form, "ersbselected=\"\"", cbIdentificationType.equals("urn:publicid:gv.at:baseid+XERSB") ? "selected=\"selected\"" : ""); +// form = ParepUtils.replaceAll(form, "", cbIdentificationValue); +// form = ParepUtils.replaceAll(form, "", errorText); +// } +// return form; +// } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepValidator.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepValidator.java index 735117094..f2f897432 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepValidator.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/ParepValidator.java @@ -61,547 +61,583 @@ import at.gv.egovernment.moa.util.Constants; * * @author Peter Danner */ -public class ParepValidator implements InfoboxValidator { - - /** activates debug settings */ - private boolean PAREP_DEBUG = false; - - /** contains the parameters the validator initially was called with */ - private InfoboxValidatorParams params = null; - - /** contains the configuration of the validator */ - private ParepConfiguration parepConfiguration = null; - - /** the requested representation ID (currently * or OID) */ - private String representationID = null; - - /** holds the information of the SZR-request */ - private CreateMandateRequest request = null; - - /** List of extended SAML attributes. */ - private Vector extendedSamlAttributes = new Vector(); - - /** the class which processes the user input */ - private ParepInputProcessor inputProcessor = null; - - /** The form if user input is necessary */ - private String form = null; - - /** unspecified error of parep-validator (must not know more about)*/ - private final static String COMMON_ERROR = "Es ist ein Fehler bei der �berpr�fung f�r berufsm��ige Parteienvetretung aufgetreten"; - - /** Default class to gather remaining mandator data. */ - public final static String PAREP_INPUT_PROCESSOR = "at.gv.egovernment.moa.id.auth.validator.parep.ParepInputProcessorImpl"; - - /** Default template to gather remaining mandator data. */ - public final static String PAREP_INPUT_TEMPLATE = "/resources/templates/ParepMinTemplate.html"; - - /** kind of representation text in AUTH block*/ - public final static String STANDARD_REPRESENTATION_TEXT = "berufsm��ige(r) Parteienvertreter(in)"; - - /** Names of the produced SAML-attributes. */ - public final static String EXT_SAML_MANDATE_RAW = "Mandate"; - public final static String EXT_SAML_MANDATE_NAME = "MandatorName"; - public final static String EXT_SAML_MANDATE_DOB = "MandatorDateOfBirth"; - public final static String EXT_SAML_MANDATE_WBPK = "MandatorWbpk"; - public final static String EXT_SAML_MANDATE_REPRESENTATIONTYPE = "RepresentationType"; +public class ParepValidator implements InfoboxValidator { + public final static String EXT_SAML_MANDATE_OIDTEXTUALDESCRIPTION = "OIDTextualDescription"; public final static String EXT_SAML_MANDATE_OID = "OID"; + public final static String EXT_SAML_MANDATE_RAW = "Mandate"; + public final static String EXT_SAML_MANDATE_NAME = "MandatorName"; + public final static String EXT_SAML_MANDATE_DOB = "MandatorDateOfBirth"; + public final static String EXT_SAML_MANDATE_WBPK = "MandatorWbpk"; + public final static String EXT_SAML_MANDATE_REPRESENTATIONTYPE = "RepresentationType"; + public final static String EXT_SAML_MANDATE_REPRESENTATIONTEXT = "Vollmachtsvertreter"; + public final static String EXT_SAML_MANDATE_CB_BASE_ID = "MandatorDomainIdentifier"; - /** */ - public final static String EXT_SAML_MANDATE_REPRESENTATIONTEXT = "Vollmachtsvertreter"; - - /** register and register number for non physical persons - the domain identifier for business applications*/ - public final static String EXT_SAML_MANDATE_CB_BASE_ID = "MandatorDomainIdentifier"; - - /** - * Parses the XML configuration element and creates the validators configuration - * Use this function if you want to preconfigure the validator. - * - * @param configElem - * the XML configuration element to parse. - * @throws ConfigurationException - * if an error occurs during the configuration process - */ - public void Configure(Element configElem) throws ConfigurationException { - if (this.parepConfiguration == null) { - Logger.debug("Lade Konfiguration."); - parepConfiguration = new ParepConfiguration(configElem); - Logger.debug("Konfiguration erfolgreich geladen."); - } - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#validate(at.gv.egovernment.moa.id.auth.data.InfoboxValidatorParams) - */ - public InfoboxValidationResult validate(InfoboxValidatorParams params) throws ValidateException { - - InfoboxValidationResultImpl validationResult = new InfoboxValidationResultImpl(false, null, null); - - try { - Logger.debug("Starte Organwalter-/berufsmäßige Parteienvertreterprüfung."); - this.params = params; - - Element mandate = extractPrimaryToken(this.params.getInfoboxTokenList()); - // ParepUtils.serializeElement(mandate, System.out); - this.representationID = ParepUtils.extractRepresentativeID(mandate); - if (ParepUtils.isEmpty(representationID)) { - validationResult.setErrorMessage("Fehlende oder falsche MandateID in standardisierter Vollmacht"); - return validationResult; - } - - // überprüfen der Identifikation (Type/Value). - String identificationType = this.params.getIdentificationType(); - String identificationValue = this.params.getIdentificationValue(); - if (this.params.getBusinessApplication()) { - if (representationID.startsWith(MOAIDAuthConstants.PARTY_ORGAN_REPRESENTATION_OID_NUMBER)) { - validationResult.setErrorMessage("Eine Vertretung durch Organwalter im privatwirtschaftlichen Bereich ist nicht vorgesehen."); - return validationResult; - - } else { - Logger.debug("Parteienvertreter wird mit wbPK identifiziert"); - } - } else { - if (representationID.startsWith(MOAIDAuthConstants.PARTY_ORGAN_REPRESENTATION_OID_NUMBER)) { - //Für Organwalter wird die Stammzahl zur Berechnung der Organwalter-bPK benötigt - if (!Constants.URN_PREFIX_BASEID.equals(this.params.getIdentificationType())) { - Logger.error("Für eine Vertretung durch Organwalter ist es notwendig dessen Stammzahl an das Stammzahlenregister-Gateway zu �bermitteln. In der MOA-ID Konfiguration muss die �bermittlung Stammzahl aktiviert sein."); - validationResult.setErrorMessage("Die standardisierte Vollmacht wird von diesem Server nicht akzeptiert."); - return validationResult; - } else { - Logger.debug("Organwalter wird mit Stammzahl identifiziert"); - } - } else { - if (Constants.URN_PREFIX_BASEID.equals(this.params.getIdentificationType())) { - // bPK berechnen, da dem SZR-Gateway das Target nicht bekannt ist - identificationType = Constants.URN_PREFIX_CDID; - String bpkBase64 = new BPKBuilder().buildBPK(this.params.getIdentificationValue(), this.params.getTarget()); - identificationValue = bpkBase64; - Logger.debug("bPK für Parteienvertreter wurde berechnet. Parteienvertreter wird mit bPK identifiziert"); - } else { - Logger.debug("Parteienvertreter wird mit bPK identifiziert"); - } - } - } - - Configure(this.params.getApplicationSpecificParams()); - // check if we have a configured party representative for that - if (!parepConfiguration.isPartyRepresentative(representationID)) { - Logger.info("Kein berufsmäßiger Parteienvertreter für MandateID \"" + representationID + "\" konfiguriert."); - validationResult.setErrorMessage("Die standardisierte Vollmacht wird von diesem Server nicht akzeptiert."); - return validationResult; - } - - // Vertreter - this.request = new CreateMandateRequest(); - request.setRepresentative(this.params, identificationType, identificationValue); - // ParepUtils.serializeElement(request.getRepresentative(), System.out); - //ParepUtils.saveElementToFile(request.getRepresentative(), new File("c:/representative.xml")); - - Logger.debug("Prüfe vorausgefüllte Daten..."); - boolean physical = true; - String familyName = ""; - String givenName = ""; - String dateOfBirth = ""; - String cbFullName = ""; - String cbIdentificationType = ""; - String cbIdentificationValue = ""; - String postalCode = ""; - String municipality = ""; - String streetName = ""; - String buildingNumber = ""; - String unit = ""; - - boolean formNecessary = false; - // Vertretener (erstes Vorkommen) - Element mandator = ParepUtils.extractMandator(mandate); - if (mandator != null) { - // ParepUtils.serializeElement(mandator, System.out); - // ParepUtils.saveElementToFile(mandator, new File("c:/mandator.xml")); - if (ParepUtils.isPhysicalPerson(mandator)) { - familyName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:FamilyName/text()"); - givenName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:GivenName/text()"); - dateOfBirth = ParepUtils.extractMandatorDateOfBirth(mandator); - } else { - physical = false; - cbFullName = ParepUtils.extractMandatorFullName(mandator); - cbIdentificationType = ParepUtils.getIdentification(mandator, "Type"); - cbIdentificationValue = ParepUtils.extractMandatorWbpk(mandator); - } - postalCode = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:PostalCode/text()"); - municipality = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:Municipality/text()"); - streetName = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:StreetName/text()"); - buildingNumber = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:BuildingNumber/text()"); - unit = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:Unit/text()"); - - } - if (physical) { - if (!parepConfiguration.isRepresentingPhysicalParty(representationID)) { - validationResult.setErrorMessage("Vertretung von natürlichen Personen für diese standardisierte Vollmacht nicht erlaubt."); - return validationResult; - } - if (ParepUtils.isEmpty(familyName) || ParepUtils.isEmpty(givenName) || ParepUtils.isEmpty(dateOfBirth)) { - formNecessary = true; - } - } else { - if (!parepConfiguration.isRepresentingCorporateParty(representationID)) { - validationResult.setErrorMessage("Vertretung von juristischen Personen für diese standardisierte Vollmacht nicht erlaubt."); - return validationResult; - } - if (ParepUtils.isEmpty(cbFullName) || ParepUtils.isEmpty(cbIdentificationType) || ParepUtils.isEmpty(cbIdentificationValue)) { - formNecessary = true; - } - } - - //Zeigen wir, dass die Daten �bernommen wurden: - if (parepConfiguration.isAlwaysShowForm()) formNecessary=true; - - // Input processor - this.form = ""; - if (formNecessary) { - ParepInputProcessor inputProcessor= getInputProcessor(); - this.form = inputProcessor.start( - physical, familyName, givenName, dateOfBirth, streetName, buildingNumber, unit, postalCode, municipality, - cbFullName, cbIdentificationType, cbIdentificationValue); - if (this.form == null) { - validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); - return validationResult; - } - } else { - // Request vorbereiten mit vorgegebenen Daten - request.setMandator(familyName, givenName, dateOfBirth, postalCode, municipality, streetName, buildingNumber, unit, physical, cbFullName, - cbIdentificationType, cbIdentificationValue); - } - - - // ParepUtils.serializeElement(request.getMandator(), System.out); - // ParepUtils.saveElementToFile(request.getMandator(), new File("c:/mandator.xml")); - - addAuthBlockExtendedSamlAttributes(); - validationResult.setExtendedSamlAttributes(getExtendedSamlAttributes()); - Logger.debug("�berpr�fung der vertretenen Partei erfolgreich beendet"); - validationResult.setValid(true); - return validationResult; - } catch (Exception e) { - e.printStackTrace(); - Logger.info(e); - validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); - return validationResult; - } - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#validate(java.util.Map) - */ - public InfoboxValidationResult validate(Map parameters) throws ValidateException { - - InfoboxValidationResultImpl validationResult = new InfoboxValidationResultImpl(false, null, null); - Logger.debug("Intermediate processing von Organwalter-/berufsmäßige Parteienvertreterprüfung"); - Logger.debug("Prüfe im Formular ausgefüllte Daten..."); - if (PAREP_DEBUG) Logger.debug("Got parameters from user input form: " + parameters.toString()); - - // Input processor - ParepInputProcessor inputProcessor= getInputProcessor(); - this.form = inputProcessor.validate(parameters, null); - if (this.form == null) { - validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); - return validationResult; - } - - addAuthBlockExtendedSamlAttributes(); - validationResult.setExtendedSamlAttributes(getExtendedSamlAttributes()); - validationResult.setValid(true); - Logger.debug("Intermediate processing von Organwalter-/berufsmäßige Parteienvertreterprüfung erfolgreich beendet"); - return validationResult; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#validate(org.w3c.dom.Element) - */ - public InfoboxValidationResult validate(Element samlAssertion) throws ValidateException { - - InfoboxValidationResultImpl validationResult = new InfoboxValidationResultImpl(false, null, null); - Logger.debug("Post processing von Organwalter-/berufsm��ige Parteienvertreterpr�fung"); - this.form = ""; - try { - - - request.setSignature(samlAssertion); - -//DPO debug -// Element mandate = (ParepUtils.readDocFromIs(new FileInputStream("c:/vertetervollmacht_1.2.40.0.10.3.1_origin-fixed.xml"))).getDocumentElement(); -// String id = representationID; + + public InfoboxValidationResult validate(InfoboxValidatorParams params) + throws ValidateException { + // TODO Auto-generated method stub + return null; + } + + public InfoboxValidationResult validate(Map parameters) + throws ValidateException { + // TODO Auto-generated method stub + return null; + } + + public InfoboxValidationResult validate(Element samlAssertion) + throws ValidateException { + // TODO Auto-generated method stub + return null; + } + + public String getForm() { + // TODO Auto-generated method stub + return null; + } + + + //TODO: check correctness!!!! +// /** activates debug settings */ +// private boolean PAREP_DEBUG = false; +// +// /** contains the parameters the validator initially was called with */ +// private InfoboxValidatorParams params = null; +// +// /** contains the configuration of the validator */ +// private ParepConfiguration parepConfiguration = null; +// +// /** the requested representation ID (currently * or OID) */ +// private String representationID = null; +// +// /** holds the information of the SZR-request */ +// private CreateMandateRequest request = null; +// +// /** List of extended SAML attributes. */ +// private Vector extendedSamlAttributes = new Vector(); +// +// /** the class which processes the user input */ +// private ParepInputProcessor inputProcessor = null; +// +// /** The form if user input is necessary */ +// private String form = null; +// +// /** unspecified error of parep-validator (must not know more about)*/ +// private final static String COMMON_ERROR = "Es ist ein Fehler bei der �berpr�fung f�r berufsm��ige Parteienvetretung aufgetreten"; +// +// /** Default class to gather remaining mandator data. */ +// public final static String PAREP_INPUT_PROCESSOR = "at.gv.egovernment.moa.id.auth.validator.parep.ParepInputProcessorImpl"; +// +// /** Default template to gather remaining mandator data. */ +// public final static String PAREP_INPUT_TEMPLATE = "/resources/templates/ParepMinTemplate.html"; +// +// /** kind of representation text in AUTH block*/ +// public final static String STANDARD_REPRESENTATION_TEXT = "berufsm��ige(r) Parteienvertreter(in)"; +// +// /** Names of the produced SAML-attributes. */ +// public final static String EXT_SAML_MANDATE_RAW = "Mandate"; +// public final static String EXT_SAML_MANDATE_NAME = "MandatorName"; +// public final static String EXT_SAML_MANDATE_DOB = "MandatorDateOfBirth"; +// public final static String EXT_SAML_MANDATE_WBPK = "MandatorWbpk"; +// public final static String EXT_SAML_MANDATE_REPRESENTATIONTYPE = "RepresentationType"; +// public final static String EXT_SAML_MANDATE_OIDTEXTUALDESCRIPTION = "OIDTextualDescription"; +// public final static String EXT_SAML_MANDATE_OID = "OID"; +// +// /** */ +// public final static String EXT_SAML_MANDATE_REPRESENTATIONTEXT = "Vollmachtsvertreter"; +// +// /** register and register number for non physical persons - the domain identifier for business applications*/ +// public final static String EXT_SAML_MANDATE_CB_BASE_ID = "MandatorDomainIdentifier"; +// +// /** +// * Parses the XML configuration element and creates the validators configuration +// * Use this function if you want to preconfigure the validator. +// * +// * @param configElem +// * the XML configuration element to parse. +// * @throws ConfigurationException +// * if an error occurs during the configuration process +// */ +// public void Configure(Element configElem) throws ConfigurationException { +// if (this.parepConfiguration == null) { +// Logger.debug("Lade Konfiguration."); +// parepConfiguration = new ParepConfiguration(configElem); +// Logger.debug("Konfiguration erfolgreich geladen."); +// } +// } +// +// /* +// * (non-Javadoc) +// * +// * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#validate(at.gv.egovernment.moa.id.auth.data.InfoboxValidatorParams) +// */ +// public InfoboxValidationResult validate(InfoboxValidatorParams params) throws ValidateException { +// +// InfoboxValidationResultImpl validationResult = new InfoboxValidationResultImpl(false, null, null); +// +// try { +// Logger.debug("Starte Organwalter-/berufsmäßige Parteienvertreterprüfung."); +// this.params = params; +// +// Element mandate = extractPrimaryToken(this.params.getInfoboxTokenList()); +// // ParepUtils.serializeElement(mandate, System.out); +// this.representationID = ParepUtils.extractRepresentativeID(mandate); +// if (ParepUtils.isEmpty(representationID)) { +// validationResult.setErrorMessage("Fehlende oder falsche MandateID in standardisierter Vollmacht"); +// return validationResult; +// } +// +// // überprüfen der Identifikation (Type/Value). +// String identificationType = this.params.getIdentificationType(); +// String identificationValue = this.params.getIdentificationValue(); +// if (this.params.getBusinessApplication()) { +// if (representationID.startsWith(MOAIDAuthConstants.PARTY_ORGAN_REPRESENTATION_OID_NUMBER)) { +// validationResult.setErrorMessage("Eine Vertretung durch Organwalter im privatwirtschaftlichen Bereich ist nicht vorgesehen."); +// return validationResult; +// +// } else { +// Logger.debug("Parteienvertreter wird mit wbPK identifiziert"); +// } +// } else { +// if (representationID.startsWith(MOAIDAuthConstants.PARTY_ORGAN_REPRESENTATION_OID_NUMBER)) { +// //Für Organwalter wird die Stammzahl zur Berechnung der Organwalter-bPK benötigt +// if (!Constants.URN_PREFIX_BASEID.equals(this.params.getIdentificationType())) { +// Logger.error("Für eine Vertretung durch Organwalter ist es notwendig dessen Stammzahl an das Stammzahlenregister-Gateway zu �bermitteln. In der MOA-ID Konfiguration muss die �bermittlung Stammzahl aktiviert sein."); +// validationResult.setErrorMessage("Die standardisierte Vollmacht wird von diesem Server nicht akzeptiert."); +// return validationResult; +// } else { +// Logger.debug("Organwalter wird mit Stammzahl identifiziert"); +// } +// } else { +// if (Constants.URN_PREFIX_BASEID.equals(this.params.getIdentificationType())) { +// // bPK berechnen, da dem SZR-Gateway das Target nicht bekannt ist +// identificationType = Constants.URN_PREFIX_CDID; +// String bpkBase64 = new BPKBuilder().buildBPK(this.params.getIdentificationValue(), this.params.getTarget()); +// identificationValue = bpkBase64; +// Logger.debug("bPK für Parteienvertreter wurde berechnet. Parteienvertreter wird mit bPK identifiziert"); +// } else { +// Logger.debug("Parteienvertreter wird mit bPK identifiziert"); +// } +// } +// } +// +// Configure(this.params.getApplicationSpecificParams()); +// // check if we have a configured party representative for that +// if (!parepConfiguration.isPartyRepresentative(representationID)) { +// Logger.info("Kein berufsmäßiger Parteienvertreter für MandateID \"" + representationID + "\" konfiguriert."); +// validationResult.setErrorMessage("Die standardisierte Vollmacht wird von diesem Server nicht akzeptiert."); +// return validationResult; +// } +// +// // Vertreter +// this.request = new CreateMandateRequest(); +// request.setRepresentative(this.params, identificationType, identificationValue); +// // ParepUtils.serializeElement(request.getRepresentative(), System.out); +// //ParepUtils.saveElementToFile(request.getRepresentative(), new File("c:/representative.xml")); +// +// Logger.debug("Prüfe vorausgefüllte Daten..."); +// boolean physical = true; +// String familyName = ""; +// String givenName = ""; +// String dateOfBirth = ""; +// String cbFullName = ""; +// String cbIdentificationType = ""; +// String cbIdentificationValue = ""; +// String postalCode = ""; +// String municipality = ""; +// String streetName = ""; +// String buildingNumber = ""; +// String unit = ""; +// +// boolean formNecessary = false; +// // Vertretener (erstes Vorkommen) +// Element mandator = ParepUtils.extractMandator(mandate); +// if (mandator != null) { +// // ParepUtils.serializeElement(mandator, System.out); +// // ParepUtils.saveElementToFile(mandator, new File("c:/mandator.xml")); +// if (ParepUtils.isPhysicalPerson(mandator)) { +// familyName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:FamilyName/text()"); +// givenName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:GivenName/text()"); +// dateOfBirth = ParepUtils.extractMandatorDateOfBirth(mandator); +// } else { +// physical = false; +// cbFullName = ParepUtils.extractMandatorFullName(mandator); +// cbIdentificationType = ParepUtils.getIdentification(mandator, "Type"); +// cbIdentificationValue = ParepUtils.extractMandatorWbpk(mandator); +// } +// postalCode = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:PostalCode/text()"); +// municipality = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:Municipality/text()"); +// streetName = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:StreetName/text()"); +// buildingNumber = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:BuildingNumber/text()"); +// unit = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:Unit/text()"); +// +// } +// if (physical) { +// if (!parepConfiguration.isRepresentingPhysicalParty(representationID)) { +// validationResult.setErrorMessage("Vertretung von natürlichen Personen für diese standardisierte Vollmacht nicht erlaubt."); +// return validationResult; +// } +// if (ParepUtils.isEmpty(familyName) || ParepUtils.isEmpty(givenName) || ParepUtils.isEmpty(dateOfBirth)) { +// formNecessary = true; +// } +// } else { +// if (!parepConfiguration.isRepresentingCorporateParty(representationID)) { +// validationResult.setErrorMessage("Vertretung von juristischen Personen für diese standardisierte Vollmacht nicht erlaubt."); +// return validationResult; +// } +// if (ParepUtils.isEmpty(cbFullName) || ParepUtils.isEmpty(cbIdentificationType) || ParepUtils.isEmpty(cbIdentificationValue)) { +// formNecessary = true; +// } +// } +// +// //Zeigen wir, dass die Daten �bernommen wurden: +// if (parepConfiguration.isAlwaysShowForm()) formNecessary=true; +// +// // Input processor +// this.form = ""; +// if (formNecessary) { +// ParepInputProcessor inputProcessor= getInputProcessor(); +// this.form = inputProcessor.start( +// physical, familyName, givenName, dateOfBirth, streetName, buildingNumber, unit, postalCode, municipality, +// cbFullName, cbIdentificationType, cbIdentificationValue); +// if (this.form == null) { +// validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); +// return validationResult; +// } +// } else { +// // Request vorbereiten mit vorgegebenen Daten +// request.setMandator(familyName, givenName, dateOfBirth, postalCode, municipality, streetName, buildingNumber, unit, physical, cbFullName, +// cbIdentificationType, cbIdentificationValue); +// } +// +// +// // ParepUtils.serializeElement(request.getMandator(), System.out); +// // ParepUtils.saveElementToFile(request.getMandator(), new File("c:/mandator.xml")); +// +// addAuthBlockExtendedSamlAttributes(); +// validationResult.setExtendedSamlAttributes(getExtendedSamlAttributes()); +// Logger.debug("�berpr�fung der vertretenen Partei erfolgreich beendet"); +// validationResult.setValid(true); +// return validationResult; +// } catch (Exception e) { +// e.printStackTrace(); +// Logger.info(e); +// validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); +// return validationResult; +// } +// } +// +// /* +// * (non-Javadoc) +// * +// * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#validate(java.util.Map) +// */ +// public InfoboxValidationResult validate(Map parameters) throws ValidateException { +// +// InfoboxValidationResultImpl validationResult = new InfoboxValidationResultImpl(false, null, null); +// Logger.debug("Intermediate processing von Organwalter-/berufsmäßige Parteienvertreterprüfung"); +// Logger.debug("Prüfe im Formular ausgefüllte Daten..."); +// if (PAREP_DEBUG) Logger.debug("Got parameters from user input form: " + parameters.toString()); +// +// // Input processor +// ParepInputProcessor inputProcessor= getInputProcessor(); +// this.form = inputProcessor.validate(parameters, null); +// if (this.form == null) { +// validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); +// return validationResult; +// } +// +// addAuthBlockExtendedSamlAttributes(); +// validationResult.setExtendedSamlAttributes(getExtendedSamlAttributes()); +// validationResult.setValid(true); +// Logger.debug("Intermediate processing von Organwalter-/berufsmäßige Parteienvertreterprüfung erfolgreich beendet"); +// return validationResult; +// } +// +// /* +// * (non-Javadoc) +// * +// * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#validate(org.w3c.dom.Element) +// */ +// public InfoboxValidationResult validate(Element samlAssertion) throws ValidateException { +// +// InfoboxValidationResultImpl validationResult = new InfoboxValidationResultImpl(false, null, null); +// Logger.debug("Post processing von Organwalter-/berufsm��ige Parteienvertreterpr�fung"); +// this.form = ""; +// try { +// +// +// request.setSignature(samlAssertion); +// +////DPO debug +//// Element mandate = (ParepUtils.readDocFromIs(new FileInputStream("c:/vertetervollmacht_1.2.40.0.10.3.1_origin-fixed.xml"))).getDocumentElement(); +//// String id = representationID; +//// CreateMandateResponse response; +//// if (true) { +//// if (this.params.getHideStammzahl()) { +//// if (PAREP_DEBUG) ParepUtils.saveElementToFile(mandate, new File("c:/vertetervollmacht_"+ id +"_origin.xml")); +//// // Achtung: Es wird hier nicht spezifikationskonform vorgegangen, damit im Kompatibilit�tsmodus Personendaten ersetzt werden k�nnen. +//// // W�rden die Stammzahlen gel�scht (geblindet) werden, w�rde der Identifikationswert des Vertretenen g�nzlich fehlen. +//// // Im Falle einen business Anwendung berechnet MOA-ID nach R�ckkehr das wbPK +//// ParepUtils.HideStammZahlen(mandate, this.params.getBusinessApplication(), this.params.getTarget(), this.params.getDomainIdentifier(), false); +//// } +//// if (PAREP_DEBUG) ParepUtils.saveElementToFile(mandate, new File("c:/vertetervollmacht_"+ id +".xml")); +// +// //ParepUtils.serializeElement(request.toElement(), System.out); +// if (PAREP_DEBUG) ParepUtils.saveElementToFile(request.toElement(), new File("c:/gwrequest.xml")); +// +// // configure szrgw client +// Logger.debug("Lade SZR-GW Client."); +// SZRGWClient client = new SZRGWClient(); +// // System.out.println("Parameters: " + cfg.getConnectionParameters()); +// Logger.debug("Initialisiere Verbindung..."); +// ConnectionParameter connectionParameters = parepConfiguration.getConnectionParameters(representationID); +// // Logger.debug("Connection Parameters: " + connectionParameters); +// Logger.debug("SZR-GW URL: " + connectionParameters.getUrl()); +// client.setAddress(connectionParameters.getUrl()); +// if (connectionParameters.getUrl().toLowerCase().startsWith("https:")) { +// Logger.debug("Initialisiere SSL Verbindung"); +// client.setSSLSocketFactory(SSLUtils.getSSLSocketFactory(AuthConfigurationProvider.getInstance(), connectionParameters)); +// } +// +// Logger.debug("Starte Kommunikation mit dem Stammzahlenregister Gateway..."); // CreateMandateResponse response; -// if (true) { +// Element requ = request.toElement(); +// try { +// response = client.createMandateResponse(requ); +// } catch (SZRGWClientException e) { +// // give him a second try - Nach dem Starten des Tomcat wird beim ersten Mal das Client-Zertifikat offenbar vom HTTPClient nicht mitgeschickt. +// client = new SZRGWClient(connectionParameters.getUrl()); +// if (connectionParameters.getUrl().toLowerCase().startsWith("https:")) client.setSSLSocketFactory(SSLUtils.getSSLSocketFactory(AuthConfigurationProvider.getInstance(), connectionParameters)); +// response = client.createMandateResponse(requ); +// } +// Logger.debug("SZR-Gateway Response Code: " + response.getResultCode()+ " " + response.getInfo()!=null ? response.getInfo():""); +// if (response.getResultCode()==2000) { +// if(response.getMandate()==null) { +// Logger.error("Keine Vollmacht vom SZR-Gateway erhalten"); +// validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); +// return validationResult; +// } +// +// +// //DPO debug output (2lines) +// String id = representationID; +// if (id.equals("*")) id="standardisiert"; +// +// Element mandate = response.getMandate(); +// // Replace Stammzahlen +// if (PAREP_DEBUG) ParepUtils.saveElementToFile(response.getMandate(), new File("c:/vertetervollmacht_"+ id +"_origin.xml")); // if (this.params.getHideStammzahl()) { -// if (PAREP_DEBUG) ParepUtils.saveElementToFile(mandate, new File("c:/vertetervollmacht_"+ id +"_origin.xml")); -// // Achtung: Es wird hier nicht spezifikationskonform vorgegangen, damit im Kompatibilit�tsmodus Personendaten ersetzt werden k�nnen. -// // W�rden die Stammzahlen gel�scht (geblindet) werden, w�rde der Identifikationswert des Vertretenen g�nzlich fehlen. -// // Im Falle einen business Anwendung berechnet MOA-ID nach R�ckkehr das wbPK // ParepUtils.HideStammZahlen(mandate, this.params.getBusinessApplication(), this.params.getTarget(), this.params.getDomainIdentifier(), false); +// if (PAREP_DEBUG) ParepUtils.saveElementToFile(mandate, new File("c:/vertetervollmacht_"+ id +"_hideStammzahl.xml")); // } -// if (PAREP_DEBUG) ParepUtils.saveElementToFile(mandate, new File("c:/vertetervollmacht_"+ id +".xml")); - - //ParepUtils.serializeElement(request.toElement(), System.out); - if (PAREP_DEBUG) ParepUtils.saveElementToFile(request.toElement(), new File("c:/gwrequest.xml")); - - // configure szrgw client - Logger.debug("Lade SZR-GW Client."); - SZRGWClient client = new SZRGWClient(); - // System.out.println("Parameters: " + cfg.getConnectionParameters()); - Logger.debug("Initialisiere Verbindung..."); - ConnectionParameter connectionParameters = parepConfiguration.getConnectionParameters(representationID); - // Logger.debug("Connection Parameters: " + connectionParameters); - Logger.debug("SZR-GW URL: " + connectionParameters.getUrl()); - client.setAddress(connectionParameters.getUrl()); - if (connectionParameters.getUrl().toLowerCase().startsWith("https:")) { - Logger.debug("Initialisiere SSL Verbindung"); - client.setSSLSocketFactory(SSLUtils.getSSLSocketFactory(AuthConfigurationProvider.getInstance(), connectionParameters)); - } - - Logger.debug("Starte Kommunikation mit dem Stammzahlenregister Gateway..."); - CreateMandateResponse response; - Element requ = request.toElement(); - try { - response = client.createMandateResponse(requ); - } catch (SZRGWClientException e) { - // give him a second try - Nach dem Starten des Tomcat wird beim ersten Mal das Client-Zertifikat offenbar vom HTTPClient nicht mitgeschickt. - client = new SZRGWClient(connectionParameters.getUrl()); - if (connectionParameters.getUrl().toLowerCase().startsWith("https:")) client.setSSLSocketFactory(SSLUtils.getSSLSocketFactory(AuthConfigurationProvider.getInstance(), connectionParameters)); - response = client.createMandateResponse(requ); - } - Logger.debug("SZR-Gateway Response Code: " + response.getResultCode()+ " " + response.getInfo()!=null ? response.getInfo():""); - if (response.getResultCode()==2000) { - if(response.getMandate()==null) { - Logger.error("Keine Vollmacht vom SZR-Gateway erhalten"); - validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); - return validationResult; - } - - - //DPO debug output (2lines) - String id = representationID; - if (id.equals("*")) id="standardisiert"; - - Element mandate = response.getMandate(); - // Replace Stammzahlen - if (PAREP_DEBUG) ParepUtils.saveElementToFile(response.getMandate(), new File("c:/vertetervollmacht_"+ id +"_origin.xml")); - if (this.params.getHideStammzahl()) { - ParepUtils.HideStammZahlen(mandate, this.params.getBusinessApplication(), this.params.getTarget(), this.params.getDomainIdentifier(), false); - if (PAREP_DEBUG) ParepUtils.saveElementToFile(mandate, new File("c:/vertetervollmacht_"+ id +"_hideStammzahl.xml")); - } - - extendedSamlAttributes.clear(); - // Vollmacht - extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_RAW, mandate, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.NOT_ADD_TO_AUTHBLOCK)); - - validationResult.setExtendedSamlAttributes(getExtendedSamlAttributes()); - validationResult.setValid(true); - Logger.debug("Post processing von Organwalter-/berufsm��ige Parteienvertreterpr�fung erfolgreich beendet"); - } else { - String errorMsg = "Fehler " + response.getResultCode() + " bei Stammzahlenregister-Gateway Anfrage"; - String responseInfo = response.getInfo(); - if (response.getResultCode()>=4000 && response.getResultCode()<4999) { - if (!ParepUtils.isEmpty(responseInfo)) errorMsg = errorMsg + ": " + responseInfo; - validationResult.setErrorMessage(errorMsg); - } else if (response.getResultCode()>=5000 && response.getResultCode()<=5999) { - // Person not found - ParepInputProcessor inputProcessor= getInputProcessor(); - switch (response.getResultCode()) { - case 5230: - errorMsg = "Keine mit den Eingaben übereinstimmende Person vorhanden. Bitte ergänzen/ändern Sie ihre Angaben."; - break; - case 5231: - errorMsg = "Die Person konnte nicht eindeutig identifiziert werden. Es existieren mehrere Personen zu Ihrer Suchanfrage. Bitte ergänzen/ändern Sie ihre Angaben."; - break; - default: - if (!ParepUtils.isEmpty(responseInfo)) errorMsg = errorMsg + ": " + responseInfo; - } - this.form = inputProcessor.validate(generateParameters(), errorMsg); - if (this.form == null) { - validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); - return validationResult; - } - validationResult.setValid(true); - } else { - // Do not inform the user too much - Logger.error(errorMsg); - validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); - } - - } - return validationResult; - } catch (Exception e) { - e.printStackTrace(); - Logger.info(e); - validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); - return validationResult; - } - } - - /** - * provides the primary infobox token of the given list. - * - * @param infoBoxTokens - * the list of infobox tokens. - * @return - * the XML element of the primary token. - * @throws ValidateException - * if an error occurs or list is not suitable. - */ - public static Element extractPrimaryToken(List infoBoxTokens) throws ValidateException { - if (infoBoxTokens == null || infoBoxTokens.size() == 0) { - throw new ValidateException("validator.62", null); - } - for (int i = 0; i < infoBoxTokens.size(); i++) { - InfoboxToken token = (InfoboxToken) infoBoxTokens.get(i); - if (token.isPrimary()) { - return token.getXMLToken(); - } - } - throw new ValidateException("validator.62", null); - } - - /* - * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#getExtendedSamlAttributes() - */ - public ExtendedSAMLAttribute[] getExtendedSamlAttributes() { - ExtendedSAMLAttribute[] ret = new ExtendedSAMLAttribute[extendedSamlAttributes.size()]; - extendedSamlAttributes.copyInto(ret); - Logger.debug("ParepValidator ExtendedSAML Attributes: " + ret.length); - return ret; - } - - - /** - * @return The next pending user input form, which is "" if no form is to be shown, and null on errors. - */ - public String getForm() { - return this.form; - } - - /** - * Gets the user form input processor (class) assigned to the current party representative - * If the method is called for the first time it initializes the input processor. - * - * @return The user form input processor - */ - private ParepInputProcessor getInputProcessor() { - - if (this.inputProcessor!=null) return inputProcessor; - String inputProcessorName = parepConfiguration.getInputProcessorClass(representationID); - ParepInputProcessor inputProcessor = null; - try { - Class inputProcessorClass = Class.forName(inputProcessorName); - inputProcessor= (ParepInputProcessor) inputProcessorClass.newInstance(); - inputProcessor.initialize(representationID, parepConfiguration, this.params.getFamilyName(), this.params.getGivenName(), this.params.getDateOfBirth(), request); - } catch (Exception e) { - Logger.error("Could not load input processor class \"" + inputProcessorName + "\": " + e.getMessage()); - } - this.inputProcessor = inputProcessor; - return inputProcessor; - } - - /** - * Generates the parameter list, which is needed to simulate a return from - * an user form. - * - * @return the form parameters - */ - private Map generateParameters() { - Map parameters = new HashMap(); - boolean physical = true; - String familyName = ""; - String givenName = ""; - String dateOfBirth = ""; - String cbFullName = ""; - String cbIdentificationType = ""; - String cbIdentificationValue = ""; - String postalCode = ""; - String municipality = ""; - String streetName = ""; - String buildingNumber = ""; - String unit = ""; - - try { - // Vertretener (erstes Vorkommen) - Element mandator = request.getMandator(); - if (mandator != null) { - if (ParepUtils.isPhysicalPerson(mandator)) { - familyName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:FamilyName/text()"); - givenName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:GivenName/text()"); - dateOfBirth = ParepUtils.extractMandatorDateOfBirth(mandator); - } else { - physical = false; - cbFullName = ParepUtils.extractMandatorFullName(mandator); - cbIdentificationType = ParepUtils.getIdentification(mandator, "Type"); - cbIdentificationValue = ParepUtils.extractMandatorWbpk(mandator); - } - postalCode = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:PostalCode/text()"); - municipality = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:Municipality/text()"); - streetName = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:StreetName/text()"); - buildingNumber = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:BuildingNumber/text()"); - unit = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:Unit/text()"); - } - } catch (Exception e) { - Logger.error("Could not extract Mandator form SZR-gateway request"); - } - parameters.put("familyname_", familyName); - parameters.put("givenname_", givenName); - parameters.put("dateofbirth_", dateOfBirth); - parameters.put("dobyear_", dateOfBirth.substring(0,4)); - parameters.put("dobmonth_", dateOfBirth.substring(5,7)); - parameters.put("dobday_", dateOfBirth.substring(8,10)); - parameters.put("physical_", physical ? "true" : "false"); - parameters.put("fullname_", cbFullName); - parameters.put("cbidentificationtype_", cbIdentificationType); - parameters.put("cbidentificationvalue_", cbIdentificationValue); - parameters.put("postalcode_", postalCode); - parameters.put("municipality_", municipality); - parameters.put("streetname_", streetName); - parameters.put("buildingnumber_", buildingNumber); - parameters.put("unit_", unit); - return parameters; - } - - /** - * Adds the AUTH block related SAML attributes to the validation result. - * This is needed always before the AUTH block is to be signed, because the - * name of the mandator has to be set - */ - private void addAuthBlockExtendedSamlAttributes() { - extendedSamlAttributes.clear(); - extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_REPRESENTATIONTYPE, parepConfiguration.getRepresentationText(representationID), SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); - Element mandator = request.getMandator(); - // Name - String name = ParepUtils.extractMandatorName(mandator); - extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_NAME, name, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); - // Geburtsdatum - String dob = ParepUtils.extractMandatorDateOfBirth(mandator); - if (dob != null && !"".equals(dob)) { - extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_DOB, dob, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); - } - // (w)bpk - String wbpk = ParepUtils.extractMandatorWbpk(mandator); - if (!ParepUtils.isEmpty(wbpk)) { - if (!ParepUtils.isPhysicalPerson(mandator)){ - String idType = ParepUtils.extractMandatorIdentificationType(mandator); - if (!ParepUtils.isEmpty(idType) && idType.startsWith(Constants.URN_PREFIX_BASEID + "+X")) { - extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_CB_BASE_ID, ParepUtils.getRegisterString(idType) + ": " + wbpk, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); - } - } else if (this.params.getBusinessApplication()) { - extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_WBPK, wbpk, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); - } - } - } - -// public static void main(String[] args) throws Exception { +// +// extendedSamlAttributes.clear(); +// // Vollmacht +// extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_RAW, mandate, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.NOT_ADD_TO_AUTHBLOCK)); +// +// validationResult.setExtendedSamlAttributes(getExtendedSamlAttributes()); +// validationResult.setValid(true); +// Logger.debug("Post processing von Organwalter-/berufsm��ige Parteienvertreterpr�fung erfolgreich beendet"); +// } else { +// String errorMsg = "Fehler " + response.getResultCode() + " bei Stammzahlenregister-Gateway Anfrage"; +// String responseInfo = response.getInfo(); +// if (response.getResultCode()>=4000 && response.getResultCode()<4999) { +// if (!ParepUtils.isEmpty(responseInfo)) errorMsg = errorMsg + ": " + responseInfo; +// validationResult.setErrorMessage(errorMsg); +// } else if (response.getResultCode()>=5000 && response.getResultCode()<=5999) { +// // Person not found +// ParepInputProcessor inputProcessor= getInputProcessor(); +// switch (response.getResultCode()) { +// case 5230: +// errorMsg = "Keine mit den Eingaben übereinstimmende Person vorhanden. Bitte ergänzen/ändern Sie ihre Angaben."; +// break; +// case 5231: +// errorMsg = "Die Person konnte nicht eindeutig identifiziert werden. Es existieren mehrere Personen zu Ihrer Suchanfrage. Bitte ergänzen/ändern Sie ihre Angaben."; +// break; +// default: +// if (!ParepUtils.isEmpty(responseInfo)) errorMsg = errorMsg + ": " + responseInfo; +// } +// this.form = inputProcessor.validate(generateParameters(), errorMsg); +// if (this.form == null) { +// validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); +// return validationResult; +// } +// validationResult.setValid(true); +// } else { +// // Do not inform the user too much +// Logger.error(errorMsg); +// validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); +// } +// +// } +// return validationResult; +// } catch (Exception e) { +// e.printStackTrace(); +// Logger.info(e); +// validationResult.setErrorMessage(ParepValidator.COMMON_ERROR); +// return validationResult; +// } +// } +// +// /** +// * provides the primary infobox token of the given list. +// * +// * @param infoBoxTokens +// * the list of infobox tokens. +// * @return +// * the XML element of the primary token. +// * @throws ValidateException +// * if an error occurs or list is not suitable. +// */ +// public static Element extractPrimaryToken(List infoBoxTokens) throws ValidateException { +// if (infoBoxTokens == null || infoBoxTokens.size() == 0) { +// throw new ValidateException("validator.62", null); +// } +// for (int i = 0; i < infoBoxTokens.size(); i++) { +// InfoboxToken token = (InfoboxToken) infoBoxTokens.get(i); +// if (token.isPrimary()) { +// return token.getXMLToken(); +// } +// } +// throw new ValidateException("validator.62", null); +// } +// +// /* +// * @see at.gv.egovernment.moa.id.auth.validator.InfoboxValidator#getExtendedSamlAttributes() +// */ +// public ExtendedSAMLAttribute[] getExtendedSamlAttributes() { +// ExtendedSAMLAttribute[] ret = new ExtendedSAMLAttribute[extendedSamlAttributes.size()]; +// extendedSamlAttributes.copyInto(ret); +// Logger.debug("ParepValidator ExtendedSAML Attributes: " + ret.length); +// return ret; +// } +// +// +// /** +// * @return The next pending user input form, which is "" if no form is to be shown, and null on errors. +// */ +// public String getForm() { +// return this.form; +// } +// +// /** +// * Gets the user form input processor (class) assigned to the current party representative +// * If the method is called for the first time it initializes the input processor. +// * +// * @return The user form input processor +// */ +// private ParepInputProcessor getInputProcessor() { +// +// if (this.inputProcessor!=null) return inputProcessor; +// String inputProcessorName = parepConfiguration.getInputProcessorClass(representationID); +// ParepInputProcessor inputProcessor = null; +// try { +// Class inputProcessorClass = Class.forName(inputProcessorName); +// inputProcessor= (ParepInputProcessor) inputProcessorClass.newInstance(); +// inputProcessor.initialize(representationID, parepConfiguration, this.params.getFamilyName(), this.params.getGivenName(), this.params.getDateOfBirth(), request); +// } catch (Exception e) { +// Logger.error("Could not load input processor class \"" + inputProcessorName + "\": " + e.getMessage()); +// } +// this.inputProcessor = inputProcessor; +// return inputProcessor; +// } +// +// /** +// * Generates the parameter list, which is needed to simulate a return from +// * an user form. +// * +// * @return the form parameters +// */ +// private Map generateParameters() { +// Map parameters = new HashMap(); +// boolean physical = true; +// String familyName = ""; +// String givenName = ""; +// String dateOfBirth = ""; +// String cbFullName = ""; +// String cbIdentificationType = ""; +// String cbIdentificationValue = ""; +// String postalCode = ""; +// String municipality = ""; +// String streetName = ""; +// String buildingNumber = ""; +// String unit = ""; +// +// try { +// // Vertretener (erstes Vorkommen) +// Element mandator = request.getMandator(); +// if (mandator != null) { +// if (ParepUtils.isPhysicalPerson(mandator)) { +// familyName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:FamilyName/text()"); +// givenName = ParepUtils.extractText(mandator, "descendant-or-self::pr:Name/pr:GivenName/text()"); +// dateOfBirth = ParepUtils.extractMandatorDateOfBirth(mandator); +// } else { +// physical = false; +// cbFullName = ParepUtils.extractMandatorFullName(mandator); +// cbIdentificationType = ParepUtils.getIdentification(mandator, "Type"); +// cbIdentificationValue = ParepUtils.extractMandatorWbpk(mandator); +// } +// postalCode = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:PostalCode/text()"); +// municipality = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:Municipality/text()"); +// streetName = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:StreetName/text()"); +// buildingNumber = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:BuildingNumber/text()"); +// unit = ParepUtils.extractText(mandator, "descendant-or-self::pr:PostalAddress/pr:DeliveryAddress/pr:Unit/text()"); +// } +// } catch (Exception e) { +// Logger.error("Could not extract Mandator form SZR-gateway request"); +// } +// parameters.put("familyname_", familyName); +// parameters.put("givenname_", givenName); +// parameters.put("dateofbirth_", dateOfBirth); +// parameters.put("dobyear_", dateOfBirth.substring(0,4)); +// parameters.put("dobmonth_", dateOfBirth.substring(5,7)); +// parameters.put("dobday_", dateOfBirth.substring(8,10)); +// parameters.put("physical_", physical ? "true" : "false"); +// parameters.put("fullname_", cbFullName); +// parameters.put("cbidentificationtype_", cbIdentificationType); +// parameters.put("cbidentificationvalue_", cbIdentificationValue); +// parameters.put("postalcode_", postalCode); +// parameters.put("municipality_", municipality); +// parameters.put("streetname_", streetName); +// parameters.put("buildingnumber_", buildingNumber); +// parameters.put("unit_", unit); +// return parameters; +// } +// +// /** +// * Adds the AUTH block related SAML attributes to the validation result. +// * This is needed always before the AUTH block is to be signed, because the +// * name of the mandator has to be set +// */ +// private void addAuthBlockExtendedSamlAttributes() { +// extendedSamlAttributes.clear(); +// extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_REPRESENTATIONTYPE, parepConfiguration.getRepresentationText(representationID), SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); +// Element mandator = request.getMandator(); +// // Name +// String name = ParepUtils.extractMandatorName(mandator); +// extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_NAME, name, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); +// // Geburtsdatum +// String dob = ParepUtils.extractMandatorDateOfBirth(mandator); +// if (dob != null && !"".equals(dob)) { +// extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_DOB, dob, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); +// } +// // (w)bpk +// String wbpk = ParepUtils.extractMandatorWbpk(mandator); +// if (!ParepUtils.isEmpty(wbpk)) { +// if (!ParepUtils.isPhysicalPerson(mandator)){ +// String idType = ParepUtils.extractMandatorIdentificationType(mandator); +// if (!ParepUtils.isEmpty(idType) && idType.startsWith(Constants.URN_PREFIX_BASEID + "+X")) { +// extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_CB_BASE_ID, ParepUtils.getRegisterString(idType) + ": " + wbpk, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); +// } +// } else if (this.params.getBusinessApplication()) { +// extendedSamlAttributes.add(new ExtendedSAMLAttributeImpl(ParepValidator.EXT_SAML_MANDATE_WBPK, wbpk, SZRGWConstants.MANDATE_NS, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY)); +// } +// } // } +// +//// public static void main(String[] args) throws Exception { +//// } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/config/ParepConfiguration.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/config/ParepConfiguration.java index bc5a0e061..ee5a57914 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/config/ParepConfiguration.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/config/ParepConfiguration.java @@ -49,386 +49,388 @@ import at.gv.egovernment.moa.util.Constants; * @author Peter Danner */ public class ParepConfiguration { - - /** - * System property for config file. - */ - public final static String PAREP_VALIDATOR_CONFIG = "parep.validator.config"; - - /** - * SZR-GW connection parameters. - */ - private ConnectionParameter standardConnectionParameters; - - /** - * Input field processor. - */ - private String standardInputProcessorClass; - - /** - * Input field processor template. - */ - private String standardInputProcessorTemplate; - - /** - * Configured party representatives. - */ - private HashMap partyRepresentatives; - - /** - * The configuration element. - */ - private Element configElement = null; - - /** - * Defines whether the user input form must be shown on each - * request or not (also predefined mandates) - */ - private boolean alwaysShowForm = false; - - /** - * The configuration base directory. - */ - private String baseDir_; - - /** - * Gets the SZR-GW connection parameters. - * - * @return the connection parameters. - */ - public ConnectionParameter getConnectionParameters(String representationID) { - if (partyRepresentatives == null || "*".equals(representationID)) - return standardConnectionParameters; - PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); - ConnectionParameter connectionParameters = pr.getConnectionParameters(); - if (connectionParameters==null) connectionParameters = standardConnectionParameters; - return connectionParameters; - } - - /** - * Sets the SZR-GW connection parameters for standard connection. - * - * @param connectionParameters - * the connection parameters. - */ - public void setStandardConnectionParameters(ConnectionParameter connectionParameters) { - this.standardConnectionParameters = connectionParameters; - } - - /* - * - */ - public String getFullDirectoryName(String fileString) { - return makeAbsoluteURL(fileString, baseDir_); - } - - /* - * - */ - private static String makeAbsoluteURL(String url, String root) { - // if url is relative to rootConfigFileDirName make it absolute - - File keyFile; - String newURL = url; - - if (null == url) - return null; - - if (url.startsWith("http:/") || url.startsWith("https:/") || url.startsWith("ftp:/") || url.startsWith("file:/") || url.startsWith("file:\\")) { - return url; - } else { - // check if absolute - if not make it absolute - keyFile = new File(url); - if (!keyFile.isAbsolute()) { - keyFile = new File(root, url); - newURL = keyFile.getPath(); - } - return newURL; - } - } - - /** - * Initializes the configuration with a given XML configuration element found - * in the MOA-ID configuration. - * - * @param configElem - * the configuration element. - * @throws ConfigurationException - * if an error occurs initializing the configuration. - */ - public ParepConfiguration(Element configElem) throws ConfigurationException { - - partyRepresentatives = new HashMap(); - partyRepresentatives.put("*", new PartyRepresentative(true, true)); - - String fileName = System.getProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME); - - try { - - baseDir_ = (new File(fileName)).getParentFile().toURL().toString(); - Logger.trace("Config base directory: " + baseDir_); - // check for configuration in system properties - if (System.getProperty(PAREP_VALIDATOR_CONFIG) != null) { - Document doc = ParepUtils.readDocFromIs(new FileInputStream(System.getProperty(PAREP_VALIDATOR_CONFIG))); - this.configElement = doc.getDocumentElement(); - } else { - this.configElement = configElem; - } - } catch (Exception e) { - throw new ConfigurationException("Allgemeiner Fehler beim Einlesen der ParepValidatorConfiguration", null, e); - } - load(); - } - - /* - * - */ - private void load() throws ConfigurationException { - Logger.debug("Parse ParepValidator Konfiguration"); - try { - Element nameSpaceNode = configElement.getOwnerDocument().createElement("NameSpaceNode"); - nameSpaceNode.setAttribute("xmlns:" + Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI); - // nameSpaceNode.setAttribute("xmlns:sgw", - // SZRGWConstants.SZRGW_PROFILE_NS); - - Node inputProcessorNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" - + Constants.MOA_ID_CONFIG_PREFIX + ":InputProcessor", nameSpaceNode); - if (inputProcessorNode != null) { - this.standardInputProcessorTemplate = ((Element) inputProcessorNode).getAttribute("template"); - Node inputProcessorClassNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" - + Constants.MOA_ID_CONFIG_PREFIX + ":InputProcessor/text()", nameSpaceNode); - if (inputProcessorClassNode != null) { - this.standardInputProcessorClass = inputProcessorClassNode.getNodeValue(); - } - } - Node alwaysShowFormNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" - + Constants.MOA_ID_CONFIG_PREFIX + ":AlwaysShowForm/text()", nameSpaceNode); - if (alwaysShowFormNode != null) { - this.setAlwaysShowForm(alwaysShowFormNode.getNodeValue()); - } - - // load connection parameters - Logger.debug("Lade SZR-Gateway Standard Verbindungsparameter"); - Element connectionParamElement = (Element) XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" - + Constants.MOA_ID_CONFIG_PREFIX + ":ConnectionParameter", nameSpaceNode); - if (connectionParamElement != null) { - // parse connection parameters - // ParepUtils.serializeElement(connectionParamElement, System.out); - this.standardConnectionParameters = buildConnectionParameter(connectionParamElement, nameSpaceNode); - } - - Logger.trace("Lade Konfiguration der Parteienvertreter"); - NodeList partyRepresentativeNodeList = XPathAPI.selectNodeList(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" - + Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentative", nameSpaceNode); - for (int i = 0; i < partyRepresentativeNodeList.getLength(); i++) { - - PartyRepresentative partyRepresentative = new PartyRepresentative(); - - Element partyRepresentativeElement = (Element) partyRepresentativeNodeList.item(i); - boolean representPhysicalParty = partyRepresentativeElement.getAttribute("representPhysicalParty").equalsIgnoreCase("true") ? true : false; - boolean representCorporateParty = partyRepresentativeElement.getAttribute("representCorporateParty").equalsIgnoreCase("true") ? true : false; - partyRepresentative.setOid(partyRepresentativeElement.getAttribute("oid")); - partyRepresentative.setRepresentingPhysicalParty(representPhysicalParty); - partyRepresentative.setRepresentingCorporateParty(representCorporateParty); - partyRepresentative.setRepresentationText(partyRepresentativeElement.getAttribute("representationText")); - - Node inputProcessorSubNode = XPathAPI.selectSingleNode(partyRepresentativeElement, Constants.MOA_ID_CONFIG_PREFIX + ":InputProcessor", nameSpaceNode); - if (inputProcessorSubNode != null) { - partyRepresentative.setInputProcessorTemplate(((Element) inputProcessorSubNode).getAttribute("template")); - Node inputProcessorClassSubNode = XPathAPI.selectSingleNode(partyRepresentativeElement, Constants.MOA_ID_CONFIG_PREFIX - + ":InputProcessor/text()", nameSpaceNode); - if (inputProcessorClassSubNode != null) { - partyRepresentative.setInputProcessorClass(inputProcessorClassSubNode.getNodeValue()); - } - } - - Element connectionParamSubElement = (Element) XPathAPI.selectSingleNode(partyRepresentativeElement, Constants.MOA_ID_CONFIG_PREFIX - + ":ConnectionParameter", nameSpaceNode); - if (connectionParamSubElement == null) { - if (this.standardConnectionParameters == null) { - throw new ConfigurationException("Fehler beim Parsen der ParepValidatorConfiguration: SZR-GW Verbindungsparameter zu Parteienvetreter " - + partyRepresentative.getOid() + " fehlen.", null, null); - } - } else { - // parse connection parameters - // ParepUtils.serializeElement(connectionParamSubElement, System.out); - partyRepresentative.setConnectionParameters(buildConnectionParameter(connectionParamSubElement, nameSpaceNode)); - } - partyRepresentatives.put(partyRepresentative.getOid(), partyRepresentative); - Logger.debug("Parteienvertreter: " + partyRepresentative.getOid() + " erfolgreich konfiguriert (representPhysicalParty=" - + partyRepresentative.isRepresentingPhysicalParty() + ", representCorporateParty=" + partyRepresentative.isRepresentingCorporateParty() - + ", representationText=" + partyRepresentative.getRepresentationText() - + ")"); - } - - Logger.debug("ParepValidator Konfiguration erfolgreich geparst."); - } catch (Exception e) { - throw new ConfigurationException("Allgemeiner Fehler beim Parsen der MandateValidatorConfiguration", null, e); - } - } - - /* - * - */ - private ConnectionParameter buildConnectionParameter(Element connParamElement, Element nameSpaceNode) throws ConfigurationException { - try { - ConnectionParameter connectionParameter = new ConnectionParameter(); - - // parse connection url - String URL = connParamElement.getAttribute("URL"); - connectionParameter.setUrl(URL); - - // accepted server certificates - Node accServerCertsNode = XPathAPI.selectSingleNode(connParamElement, Constants.MOA_ID_CONFIG_PREFIX + ":AcceptedServerCertificates/text()", - nameSpaceNode); - if (accServerCertsNode != null) { - - String serverCertsDir = getFullDirectoryName(accServerCertsNode.getNodeValue()); - Logger.debug("Full directory name of accepted server certificates: " + serverCertsDir); - connectionParameter.setAcceptedServerCertificates(serverCertsDir); - } - - // client key store - Node clientKeyStoreNode = XPathAPI.selectSingleNode(connParamElement, Constants.MOA_ID_CONFIG_PREFIX + ":ClientKeyStore/text()", nameSpaceNode); - if (clientKeyStoreNode != null) { - String clientKeystore = getFullDirectoryName(clientKeyStoreNode.getNodeValue()); - connectionParameter.setClientKeyStore(clientKeystore); - } - - // client key store password - Node clientKeyStorePasswordNode = XPathAPI.selectSingleNode(connParamElement, Constants.MOA_ID_CONFIG_PREFIX + ":ClientKeyStore/@password", - nameSpaceNode); - if (clientKeyStorePasswordNode != null) { - connectionParameter.setClientKeyStorePassword(clientKeyStorePasswordNode.getNodeValue()); - } - - return connectionParameter; - } catch (Exception e) { - throw new ConfigurationException("Allgemeiner Fehler beim Parsen der ParepValidator ConnectionParameter.", null, e); - } - } - - public boolean isPartyRepresentative(String representationID) { - if (partyRepresentatives == null) - return false; - PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); - return pr != null; - } - - public boolean isRepresentingCorporateParty(String representationID) { - if (partyRepresentatives == null) return false; - PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); - if (pr == null) return false; - return pr.isRepresentingCorporateParty(); - } - - public boolean isRepresentingPhysicalParty(String representationID) { - if (partyRepresentatives == null) return false; - PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); - if (pr == null) return false; - return pr.isRepresentingPhysicalParty(); - } - - public String getRepresentationText(String representationID) { - String result = ParepValidator.STANDARD_REPRESENTATION_TEXT; - if (partyRepresentatives != null) { - PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); - if (pr != null) { - if (!ParepUtils.isEmpty(pr.getRepresentationText())) result = pr.getRepresentationText(); - } - } - return result; - } - - /** - * @return the input processor classname corresponding to representationID - * @param representationID - * the representation ID. - */ - public String getInputProcessorClass(String representationID) { - String inputProcessorClass = standardInputProcessorClass; - if (ParepUtils.isEmpty(inputProcessorClass)) inputProcessorClass = ParepValidator.PAREP_INPUT_PROCESSOR; - if (!(partyRepresentatives == null || "*".equals(representationID))) { - PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); - if (pr!=null) { - String prInputProcessorClass = pr.getInputProcessorClass(); - if (!ParepUtils.isEmpty(prInputProcessorClass)) inputProcessorClass = prInputProcessorClass; - } - } - return inputProcessorClass; - } - - /** - * @param standardInputProcessorClass the standardInputProcessorClass to set - */ - public void setStandardInputProcessorClass(String standardInputProcessorClass) { - this.standardInputProcessorClass = standardInputProcessorClass; - } - - /** - * @return the InputProcessorTemplate - */ - public String getInputProcessorTemplate(String representationID) { - String inputProcessorTemplate = standardInputProcessorTemplate; - if (ParepUtils.isEmpty(inputProcessorTemplate)) inputProcessorTemplate = ParepValidator.PAREP_INPUT_TEMPLATE; - if (!(partyRepresentatives == null || "*".equals(representationID))) { - PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); - if (pr!=null) { - String prInputProcessorTemplate = pr.getInputProcessorTemplate(); - if (!ParepUtils.isEmpty(prInputProcessorTemplate)) inputProcessorTemplate = prInputProcessorTemplate; - } - } - return inputProcessorTemplate; - } - - /** - * @param standardInputProcessorTemplate the standardInputProcessorTemplate to set - */ - public void setStandardInputProcessorTemplate(String standardInputProcessorTemplate) { - this.standardInputProcessorTemplate = standardInputProcessorTemplate; - } - - /** - * @return the alwaysShowForm - */ - public boolean isAlwaysShowForm() { - return alwaysShowForm; - } - + + + //TODO: check correctness!!!! /** - * @param alwaysShowForm the alwaysShowForm to set - */ - public void setAlwaysShowForm(String alwaysShowForm) { - if (ParepUtils.isEmpty(alwaysShowForm)) { - this.alwaysShowForm = false; - } else { - this.alwaysShowForm = alwaysShowForm.equalsIgnoreCase("true"); - } - } - - public static boolean isMandateCompatibilityMode(Element configElement) throws ConfigurationException { - try { - if (configElement==null) return false; - Element nameSpaceNode = configElement.getOwnerDocument().createElement("NameSpaceNode"); - nameSpaceNode.setAttribute("xmlns:" + Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI); - Node mandateCompatibilityNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":CompatibilityMode/text()", nameSpaceNode); - if (mandateCompatibilityNode != null && !ParepUtils.isEmpty(mandateCompatibilityNode.getNodeValue())) { - return mandateCompatibilityNode.getNodeValue().equalsIgnoreCase("true"); - } - return false; - } catch (Exception e) { - throw new ConfigurationException("Allgemeiner Fehler beim Parsen des CompatibilityMode Parameters.", null, e); - } - - } - - -// public static void main(String[] args) throws Exception { -// System.setProperty(PAREP_VALIDATOR_CONFIG, "c:/Doku/work/Organwalter/ConfigurationSnippetAppSpecific.xml"); -// System.setProperty("moa.id.configuration", "c:/workspace33moa/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/moa-id/SampleMOAWIDConfiguration_withTestBKsProxy.xml"); -// System.setProperty("log4j.configuration", "file:c:/workspace33moa/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/moa-id/log4j.properties"); -// Configuration cfg = new Configuration(null); -// System.out.println(cfg.getInputProcessorClass("1.2.40.0.10.3.110")); -//} +// * System property for config file. +// */ +// public final static String PAREP_VALIDATOR_CONFIG = "parep.validator.config"; +// +// /** +// * SZR-GW connection parameters. +// */ +// private ConnectionParameter standardConnectionParameters; +// +// /** +// * Input field processor. +// */ +// private String standardInputProcessorClass; +// +// /** +// * Input field processor template. +// */ +// private String standardInputProcessorTemplate; +// +// /** +// * Configured party representatives. +// */ +// private HashMap partyRepresentatives; +// +// /** +// * The configuration element. +// */ +// private Element configElement = null; +// +// /** +// * Defines whether the user input form must be shown on each +// * request or not (also predefined mandates) +// */ +// private boolean alwaysShowForm = false; +// +// /** +// * The configuration base directory. +// */ +// private String baseDir_; +// +// /** +// * Gets the SZR-GW connection parameters. +// * +// * @return the connection parameters. +// */ +// public ConnectionParameter getConnectionParameters(String representationID) { +// if (partyRepresentatives == null || "*".equals(representationID)) +// return standardConnectionParameters; +// PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); +// ConnectionParameter connectionParameters = pr.getConnectionParameters(); +// if (connectionParameters==null) connectionParameters = standardConnectionParameters; +// return connectionParameters; +// } +// +// /** +// * Sets the SZR-GW connection parameters for standard connection. +// * +// * @param connectionParameters +// * the connection parameters. +// */ +// public void setStandardConnectionParameters(ConnectionParameter connectionParameters) { +// this.standardConnectionParameters = connectionParameters; +// } +// +// /* +// * +// */ +// public String getFullDirectoryName(String fileString) { +// return makeAbsoluteURL(fileString, baseDir_); +// } +// +// /* +// * +// */ +// private static String makeAbsoluteURL(String url, String root) { +// // if url is relative to rootConfigFileDirName make it absolute +// +// File keyFile; +// String newURL = url; +// +// if (null == url) +// return null; +// +// if (url.startsWith("http:/") || url.startsWith("https:/") || url.startsWith("ftp:/") || url.startsWith("file:/") || url.startsWith("file:\\")) { +// return url; +// } else { +// // check if absolute - if not make it absolute +// keyFile = new File(url); +// if (!keyFile.isAbsolute()) { +// keyFile = new File(root, url); +// newURL = keyFile.getPath(); +// } +// return newURL; +// } +// } +// +// /** +// * Initializes the configuration with a given XML configuration element found +// * in the MOA-ID configuration. +// * +// * @param configElem +// * the configuration element. +// * @throws ConfigurationException +// * if an error occurs initializing the configuration. +// */ +// public ParepConfiguration(Element configElem) throws ConfigurationException { +// +// partyRepresentatives = new HashMap(); +// partyRepresentatives.put("*", new PartyRepresentative(true, true)); +// +// String fileName = System.getProperty(ConfigurationProvider.CONFIG_PROPERTY_NAME); +// +// try { +// +// baseDir_ = (new File(fileName)).getParentFile().toURL().toString(); +// Logger.trace("Config base directory: " + baseDir_); +// // check for configuration in system properties +// if (System.getProperty(PAREP_VALIDATOR_CONFIG) != null) { +// Document doc = ParepUtils.readDocFromIs(new FileInputStream(System.getProperty(PAREP_VALIDATOR_CONFIG))); +// this.configElement = doc.getDocumentElement(); +// } else { +// this.configElement = configElem; +// } +// } catch (Exception e) { +// throw new ConfigurationException("Allgemeiner Fehler beim Einlesen der ParepValidatorConfiguration", null, e); +// } +// load(); +// } +// +// /* +// * +// */ +// private void load() throws ConfigurationException { +// Logger.debug("Parse ParepValidator Konfiguration"); +// try { +// Element nameSpaceNode = configElement.getOwnerDocument().createElement("NameSpaceNode"); +// nameSpaceNode.setAttribute("xmlns:" + Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI); +// // nameSpaceNode.setAttribute("xmlns:sgw", +// // SZRGWConstants.SZRGW_PROFILE_NS); +// +// Node inputProcessorNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" +// + Constants.MOA_ID_CONFIG_PREFIX + ":InputProcessor", nameSpaceNode); +// if (inputProcessorNode != null) { +// this.standardInputProcessorTemplate = ((Element) inputProcessorNode).getAttribute("template"); +// Node inputProcessorClassNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" +// + Constants.MOA_ID_CONFIG_PREFIX + ":InputProcessor/text()", nameSpaceNode); +// if (inputProcessorClassNode != null) { +// this.standardInputProcessorClass = inputProcessorClassNode.getNodeValue(); +// } +// } +// Node alwaysShowFormNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" +// + Constants.MOA_ID_CONFIG_PREFIX + ":AlwaysShowForm/text()", nameSpaceNode); +// if (alwaysShowFormNode != null) { +// this.setAlwaysShowForm(alwaysShowFormNode.getNodeValue()); +// } +// +// // load connection parameters +// Logger.debug("Lade SZR-Gateway Standard Verbindungsparameter"); +// Element connectionParamElement = (Element) XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" +// + Constants.MOA_ID_CONFIG_PREFIX + ":ConnectionParameter", nameSpaceNode); +// if (connectionParamElement != null) { +// // parse connection parameters +// // ParepUtils.serializeElement(connectionParamElement, System.out); +// this.standardConnectionParameters = buildConnectionParameter(connectionParamElement, nameSpaceNode); +// } +// +// Logger.trace("Lade Konfiguration der Parteienvertreter"); +// NodeList partyRepresentativeNodeList = XPathAPI.selectNodeList(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentation/" +// + Constants.MOA_ID_CONFIG_PREFIX + ":PartyRepresentative", nameSpaceNode); +// for (int i = 0; i < partyRepresentativeNodeList.getLength(); i++) { +// +// PartyRepresentative partyRepresentative = new PartyRepresentative(); +// +// Element partyRepresentativeElement = (Element) partyRepresentativeNodeList.item(i); +// boolean representPhysicalParty = partyRepresentativeElement.getAttribute("representPhysicalParty").equalsIgnoreCase("true") ? true : false; +// boolean representCorporateParty = partyRepresentativeElement.getAttribute("representCorporateParty").equalsIgnoreCase("true") ? true : false; +// partyRepresentative.setOid(partyRepresentativeElement.getAttribute("oid")); +// partyRepresentative.setRepresentingPhysicalParty(representPhysicalParty); +// partyRepresentative.setRepresentingCorporateParty(representCorporateParty); +// partyRepresentative.setRepresentationText(partyRepresentativeElement.getAttribute("representationText")); +// +// Node inputProcessorSubNode = XPathAPI.selectSingleNode(partyRepresentativeElement, Constants.MOA_ID_CONFIG_PREFIX + ":InputProcessor", nameSpaceNode); +// if (inputProcessorSubNode != null) { +// partyRepresentative.setInputProcessorTemplate(((Element) inputProcessorSubNode).getAttribute("template")); +// Node inputProcessorClassSubNode = XPathAPI.selectSingleNode(partyRepresentativeElement, Constants.MOA_ID_CONFIG_PREFIX +// + ":InputProcessor/text()", nameSpaceNode); +// if (inputProcessorClassSubNode != null) { +// partyRepresentative.setInputProcessorClass(inputProcessorClassSubNode.getNodeValue()); +// } +// } +// +// Element connectionParamSubElement = (Element) XPathAPI.selectSingleNode(partyRepresentativeElement, Constants.MOA_ID_CONFIG_PREFIX +// + ":ConnectionParameter", nameSpaceNode); +// if (connectionParamSubElement == null) { +// if (this.standardConnectionParameters == null) { +// throw new ConfigurationException("Fehler beim Parsen der ParepValidatorConfiguration: SZR-GW Verbindungsparameter zu Parteienvetreter " +// + partyRepresentative.getOid() + " fehlen.", null, null); +// } +// } else { +// // parse connection parameters +// // ParepUtils.serializeElement(connectionParamSubElement, System.out); +// partyRepresentative.setConnectionParameters(buildConnectionParameter(connectionParamSubElement, nameSpaceNode)); +// } +// partyRepresentatives.put(partyRepresentative.getOid(), partyRepresentative); +// Logger.debug("Parteienvertreter: " + partyRepresentative.getOid() + " erfolgreich konfiguriert (representPhysicalParty=" +// + partyRepresentative.isRepresentingPhysicalParty() + ", representCorporateParty=" + partyRepresentative.isRepresentingCorporateParty() +// + ", representationText=" + partyRepresentative.getRepresentationText() +// + ")"); +// } +// +// Logger.debug("ParepValidator Konfiguration erfolgreich geparst."); +// } catch (Exception e) { +// throw new ConfigurationException("Allgemeiner Fehler beim Parsen der MandateValidatorConfiguration", null, e); +// } +// } +// +// /* +// * +// */ +// private ConnectionParameter buildConnectionParameter(Element connParamElement, Element nameSpaceNode) throws ConfigurationException { +// try { +// ConnectionParameter connectionParameter = new ConnectionParameter(); +// +// // parse connection url +// String URL = connParamElement.getAttribute("URL"); +// connectionParameter.setUrl(URL); +// +// // accepted server certificates +// Node accServerCertsNode = XPathAPI.selectSingleNode(connParamElement, Constants.MOA_ID_CONFIG_PREFIX + ":AcceptedServerCertificates/text()", +// nameSpaceNode); +// if (accServerCertsNode != null) { +// +// String serverCertsDir = getFullDirectoryName(accServerCertsNode.getNodeValue()); +// Logger.debug("Full directory name of accepted server certificates: " + serverCertsDir); +// connectionParameter.setAcceptedServerCertificates(serverCertsDir); +// } +// +// // client key store +// Node clientKeyStoreNode = XPathAPI.selectSingleNode(connParamElement, Constants.MOA_ID_CONFIG_PREFIX + ":ClientKeyStore/text()", nameSpaceNode); +// if (clientKeyStoreNode != null) { +// String clientKeystore = getFullDirectoryName(clientKeyStoreNode.getNodeValue()); +// connectionParameter.setClientKeyStore(clientKeystore); +// } +// +// // client key store password +// Node clientKeyStorePasswordNode = XPathAPI.selectSingleNode(connParamElement, Constants.MOA_ID_CONFIG_PREFIX + ":ClientKeyStore/@password", +// nameSpaceNode); +// if (clientKeyStorePasswordNode != null) { +// connectionParameter.setClientKeyStorePassword(clientKeyStorePasswordNode.getNodeValue()); +// } +// +// return connectionParameter; +// } catch (Exception e) { +// throw new ConfigurationException("Allgemeiner Fehler beim Parsen der ParepValidator ConnectionParameter.", null, e); +// } +// } +// +// public boolean isPartyRepresentative(String representationID) { +// if (partyRepresentatives == null) +// return false; +// PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); +// return pr != null; +// } +// +// public boolean isRepresentingCorporateParty(String representationID) { +// if (partyRepresentatives == null) return false; +// PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); +// if (pr == null) return false; +// return pr.isRepresentingCorporateParty(); +// } +// +// public boolean isRepresentingPhysicalParty(String representationID) { +// if (partyRepresentatives == null) return false; +// PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); +// if (pr == null) return false; +// return pr.isRepresentingPhysicalParty(); +// } +// +// public String getRepresentationText(String representationID) { +// String result = ParepValidator.STANDARD_REPRESENTATION_TEXT; +// if (partyRepresentatives != null) { +// PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); +// if (pr != null) { +// if (!ParepUtils.isEmpty(pr.getRepresentationText())) result = pr.getRepresentationText(); +// } +// } +// return result; +// } +// +// /** +// * @return the input processor classname corresponding to representationID +// * @param representationID +// * the representation ID. +// */ +// public String getInputProcessorClass(String representationID) { +// String inputProcessorClass = standardInputProcessorClass; +// if (ParepUtils.isEmpty(inputProcessorClass)) inputProcessorClass = ParepValidator.PAREP_INPUT_PROCESSOR; +// if (!(partyRepresentatives == null || "*".equals(representationID))) { +// PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); +// if (pr!=null) { +// String prInputProcessorClass = pr.getInputProcessorClass(); +// if (!ParepUtils.isEmpty(prInputProcessorClass)) inputProcessorClass = prInputProcessorClass; +// } +// } +// return inputProcessorClass; +// } +// +// /** +// * @param standardInputProcessorClass the standardInputProcessorClass to set +// */ +// public void setStandardInputProcessorClass(String standardInputProcessorClass) { +// this.standardInputProcessorClass = standardInputProcessorClass; +// } +// +// /** +// * @return the InputProcessorTemplate +// */ +// public String getInputProcessorTemplate(String representationID) { +// String inputProcessorTemplate = standardInputProcessorTemplate; +// if (ParepUtils.isEmpty(inputProcessorTemplate)) inputProcessorTemplate = ParepValidator.PAREP_INPUT_TEMPLATE; +// if (!(partyRepresentatives == null || "*".equals(representationID))) { +// PartyRepresentative pr = (PartyRepresentative) partyRepresentatives.get(representationID); +// if (pr!=null) { +// String prInputProcessorTemplate = pr.getInputProcessorTemplate(); +// if (!ParepUtils.isEmpty(prInputProcessorTemplate)) inputProcessorTemplate = prInputProcessorTemplate; +// } +// } +// return inputProcessorTemplate; +// } +// +// /** +// * @param standardInputProcessorTemplate the standardInputProcessorTemplate to set +// */ +// public void setStandardInputProcessorTemplate(String standardInputProcessorTemplate) { +// this.standardInputProcessorTemplate = standardInputProcessorTemplate; +// } +// +// /** +// * @return the alwaysShowForm +// */ +// public boolean isAlwaysShowForm() { +// return alwaysShowForm; +// } +// +// /** +// * @param alwaysShowForm the alwaysShowForm to set +// */ +// public void setAlwaysShowForm(String alwaysShowForm) { +// if (ParepUtils.isEmpty(alwaysShowForm)) { +// this.alwaysShowForm = false; +// } else { +// this.alwaysShowForm = alwaysShowForm.equalsIgnoreCase("true"); +// } +// } +// +// public static boolean isMandateCompatibilityMode(Element configElement) throws ConfigurationException { +// try { +// if (configElement==null) return false; +// Element nameSpaceNode = configElement.getOwnerDocument().createElement("NameSpaceNode"); +// nameSpaceNode.setAttribute("xmlns:" + Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI); +// Node mandateCompatibilityNode = XPathAPI.selectSingleNode(configElement, Constants.MOA_ID_CONFIG_PREFIX + ":CompatibilityMode/text()", nameSpaceNode); +// if (mandateCompatibilityNode != null && !ParepUtils.isEmpty(mandateCompatibilityNode.getNodeValue())) { +// return mandateCompatibilityNode.getNodeValue().equalsIgnoreCase("true"); +// } +// return false; +// } catch (Exception e) { +// throw new ConfigurationException("Allgemeiner Fehler beim Parsen des CompatibilityMode Parameters.", null, e); +// } +// +// } +// +// +//// public static void main(String[] args) throws Exception { +//// System.setProperty(PAREP_VALIDATOR_CONFIG, "c:/Doku/work/Organwalter/ConfigurationSnippetAppSpecific.xml"); +//// System.setProperty("moa.id.configuration", "c:/workspace33moa/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/moa-id/SampleMOAWIDConfiguration_withTestBKsProxy.xml"); +//// System.setProperty("log4j.configuration", "file:c:/workspace33moa/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/moa-id/log4j.properties"); +//// Configuration cfg = new Configuration(null); +//// System.out.println(cfg.getInputProcessorClass("1.2.40.0.10.3.110")); +////} } -- cgit v1.2.3