aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java115
1 files changed, 60 insertions, 55 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java
index 136b40295..9532aa9ab 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java
@@ -25,7 +25,6 @@
*/
package at.gv.egovernment.moa.id.config.stork;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -33,16 +32,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
-import at.gv.egovernment.moa.id.commons.db.dao.config.SAMLSigningParameter;
-import at.gv.egovernment.moa.id.commons.db.dao.config.STORK;
-import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.config.ConfigurationException;
+import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProviderFactory;
import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
import at.gv.egovernment.moa.util.StringUtils;
-import org.opensaml.ws.message.encoder.MessageEncodingException;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
/**
* Encapsulates several STORK configuration parameters according MOA configuration
@@ -54,63 +51,71 @@ public class STORKConfig {
/** STORK SAML signature creation parameters */
private Properties props = null;
- private Map<String, CPEPS> cpepsMap = null;
+ private Map<String, CPEPS> cpepsMap = new HashMap<String, CPEPS>();
private String basedirectory = null;
private SignatureVerificationParameter sigverifyparam = null;
private List<StorkAttribute> attr = null;
- public STORKConfig(STORK stork, Properties props, String basedirectory) {
+ public STORKConfig(Properties props, String basedirectory) throws ConfigurationException {
this.basedirectory = basedirectory;
this.props = props;
//create CPEPS map
- //List<at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS> cpeps = stork.getCPEPS();
- List<at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS> cpeps = new ArrayList<at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS>(); // TODO Change this
-
- try {
- cpeps = stork.getCPEPS();
-
- } catch (NullPointerException ex) {
- Logger.error("CPEPS not configured!");
+ List<CPEPS> cpeps = new ArrayList<CPEPS>();
+
+ Map<String, String> storkCPEPSProps =
+ AuthConfigurationProviderFactory.getInstance().getConfigurationWithPrefix(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST + ".");
+ if (storkCPEPSProps != null) {
+ Set<String> keyValues = storkCPEPSProps.keySet();
+ for (Object elObj : keyValues) {
+ if (elObj instanceof String) {
+ String el = (String) elObj;
+ if (el.endsWith(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY)) {
+ int index = el.indexOf(".");
+ String listCounter = el.substring(0, index);
+
+ if (MiscUtil.isNotEmpty(storkCPEPSProps.get(listCounter + "." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY))) {
+ try {
+ CPEPS moacpep =
+ new CPEPS(storkCPEPSProps.get(listCounter + "." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY),
+ new URL(storkCPEPSProps.get(listCounter + "." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_URL)),
+ Boolean.valueOf(storkCPEPSProps.get(listCounter + "." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_SUPPORT_XMLDSIG)));
+ cpepsMap.put(moacpep.getCountryCode(), moacpep);
+
+ } catch (MalformedURLException e) {
+ Logger.warn("CPEPS URL " +
+ storkCPEPSProps.get(listCounter + "." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_CPEPS_LIST_URL) +
+ " are not parseable.", e);
+
+ }
+ }
+ }
+ }
+ }
+ }
+
+ attr = new ArrayList<StorkAttribute>();
+ Map<String, String> storkAttributeProps =
+ AuthConfigurationProviderFactory.getInstance().getConfigurationWithPrefix(
+ MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST);
+ if (storkAttributeProps != null) {
+ Set<String> keyValues = storkAttributeProps.keySet();
+ for (Object elObj : keyValues) {
+ if (elObj instanceof String) {
+ String el = (String) elObj;
+ if (el.endsWith(MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME)) {
+ int index = el.indexOf(".");
+ String listCounter = el.substring(0, index);
+ StorkAttribute moaStorkAttr =
+ new StorkAttribute(storkAttributeProps.get(listCounter + "." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME),
+ Boolean.valueOf(storkAttributeProps.get(listCounter + "." + MOAIDConfigurationConstants.GENERAL_AUTH_STORK_ATTRIBUTES_LIST_MANDATORY)));
+ attr.add(moaStorkAttr);
+ }
+ }
+ }
}
-
- cpepsMap = new HashMap<String, CPEPS>();
-
- if (cpeps != null) {
- for(at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS cpep : cpeps) {
-
- try {
- CPEPS moacpep = new CPEPS(cpep.getCountryCode(), new URL(cpep.getURL()), cpep.isSupportsXMLSignature());
-
- cpepsMap.put(cpep.getCountryCode(), moacpep);
-
- } catch (MalformedURLException e) {
- Logger.warn("Error in MOA-ID Configuration. CPEP entry for country "
- + cpep.getCountryCode() + " has an invalid URL and is ignored.");
- }
- }
- /*catch (ParserConfigurationException e) {
- Logger.warn("Error in MOA-ID Configuration. CPEP entry for country "
- + cpep.getCountryCode() + " has an invalid Attribute and is ignored.");
- } catch (SAXException e) {
- Logger.warn("Error in MOA-ID Configuration. CPEP entry for country "
- + cpep.getCountryCode() + " has an invalid Attribute and is ignored.");
- } catch (IOException e) {
- Logger.warn("Error in MOA-ID Configuration. CPEP entry for country "
- + cpep.getCountryCode() + " has an invalid Attribute and is ignored.");
- } catch (MessageEncodingException e) {
- Logger.warn("Error in MOA-ID Configuration. CPEP entry for country "
- + cpep.getCountryCode() + " has an invalid Attribute and is ignored.");
- }*/
- }
- attr = new ArrayList<StorkAttribute>();
- if (stork != null && stork.getAttributes() != null) {
- for(StorkAttribute current : stork.getAttributes()) {
- attr.add(current);
- }
- }
-
}
public SignatureCreationParameter getSignatureCreationParameter() {