aboutsummaryrefslogtreecommitdiff
path: root/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2014-03-21 14:45:05 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2014-03-21 14:45:05 +0100
commitf3f35663f362ce6722eaa26598fb5aa8c4c6d962 (patch)
treebc9d66ebe1b5b840c6e3bf0087a8dd58040528a1 /id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java
parent05212e955f2c44bd3150b47d9d534c5a73eb71d1 (diff)
parent658cb68c445d5b73815c43b66dd717483a425ea5 (diff)
downloadmoa-id-spss-f3f35663f362ce6722eaa26598fb5aa8c4c6d962.tar.gz
moa-id-spss-f3f35663f362ce6722eaa26598fb5aa8c4c6d962.tar.bz2
moa-id-spss-f3f35663f362ce6722eaa26598fb5aa8c4c6d962.zip
Merge remote-tracking branch 'remotes/origin/vidp' into moa2_0_tlenz
Conflicts: id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/PEPSConnectorServlet.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties id/server/moa-id-commons/pom.xml id/server/stork2-saml-engine/pom.xml pom.xml repository/iaik/iaik_tsl/1.0/iaik_tsl-1.0.jar repository/iaik/iaik_tsl/1.0/iaik_tsl-1.0.pom
Diffstat (limited to 'id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java')
-rw-r--r--id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java276
1 files changed, 141 insertions, 135 deletions
diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java
index b40e3f7dd..c53e18662 100644
--- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java
+++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/configuration/ConfigurationCreator.java
@@ -1,136 +1,142 @@
-/*
- * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence. You may
- * obtain a copy of the Licence at:
- *
- * http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * Licence for the specific language governing permissions and limitations under
- * the Licence.
- */
-
-package eu.stork.peps.configuration;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.InvalidPropertiesFormatException;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import eu.stork.peps.exceptions.STORKSAMLEngineException;
-
-/**
- * The Class InstanceCreator.
- *
- * @author fjquevedo
- */
-public final class ConfigurationCreator {
-
- /** The Constant LOGGER. */
- private static final Logger LOGGER = LoggerFactory
- .getLogger(ConfigurationCreator.class.getName());
-
- /**
- * Creates the configuration.
- *
- * @param instanceConfs the instance configuration
- *
- * @return the map< string, map< string, object>>
- *
- * @throws STORKSAMLEngineException the STORKSAML engine exception
- */
- public static Map<String, Map<String, Object>> createConfiguration(
- final Map<String, InstanceEngine> instanceConfs) throws STORKSAMLEngineException {
-
- final HashMap<String, Map<String, Object>> instances =
- new HashMap<String, Map<String, Object>>();
-
- LOGGER.info("Create configuration.");
- try {
- // Only create instances for SAMLEngine configuration.
- // INSTANCE
- for (Map.Entry<String, InstanceEngine> entry : instanceConfs
- .entrySet()) {
- final InstanceEngine iEngine = entry.getValue();
-
- final Map<String, Object> intance = new HashMap<String, Object>();
-
- // CONFIGURATION
- for (ConfigurationEngine configuration : iEngine
- .getConfiguration()) {
- // Properties only for configuration SamlEngine.
- if (configuration.getName().equalsIgnoreCase(
- "SamlEngineConf")) {
- intance.put(configuration.getName(),
- getNewInstance(configuration.getParameters()
- .get("fileConfiguration")));
- } else {
- intance.put(configuration.getName(), configuration
- .getParameters());
- }
- }
- instances.put(entry.getKey(), intance);
- }
- } catch (STORKSAMLEngineException ex) {
- LOGGER.error("Can not create instance from file configuration.");
- throw new STORKSAMLEngineException(ex);
- }
- return instances;
- }
-
-
- /**
- * Gets the new instance.
- *
- * @param fileName the file name
- *
- * @return the properties from the new instance
- *
- * @throws STORKSAMLEngineException the STORKSAML engine
- * runtime exception
- */
- private static Properties getNewInstance(final String fileName)
- throws STORKSAMLEngineException {
- LOGGER.info("Create file configuration properties to Stork Saml Engine.");
- InputStream fileEngineProp = null;
- try {
- // fetch base from system properties, give a default if there is nothing configured
- String base = System.getProperty("eu.stork.samlengine.config.location");
- if(null != base)
- if(!base.endsWith("/"))
- base += "/";
-
- if(null != base)
- fileEngineProp = new FileInputStream(base + fileName);
- else
- fileEngineProp = ConfigurationCreator.class.getResourceAsStream("/" + fileName);
- final Properties configuration = new Properties();
- configuration.loadFromXML(fileEngineProp);
- return configuration;
- } catch (InvalidPropertiesFormatException e) {
- LOGGER.error("Invalid properties format.");
- throw new STORKSAMLEngineException(e);
- } catch (IOException e) {
- LOGGER.error("Error read file: " + fileName);
- throw new STORKSAMLEngineException(e);
- } finally {
- IOUtils.closeQuietly(fileEngineProp);
- }
- }
-
- /**
- * Instantiates a new instance creator.
- */
- private ConfigurationCreator() {
- }
+/*
+ * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence. You may
+ * obtain a copy of the Licence at:
+ *
+ * http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * Licence for the specific language governing permissions and limitations under
+ * the Licence.
+ */
+
+package eu.stork.peps.configuration;
+
+import eu.stork.peps.exceptions.STORKSAMLEngineException;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.InvalidPropertiesFormatException;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * The Class InstanceCreator.
+ *
+ * @author fjquevedo
+ */
+public final class ConfigurationCreator {
+
+ /**
+ * The Constant LOGGER.
+ */
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(ConfigurationCreator.class.getName());
+
+ /**
+ * Creates the configuration.
+ *
+ * @param instanceConfs the instance configuration
+ * @return the map< string, map< string, object>>
+ * @throws STORKSAMLEngineException the STORKSAML engine exception
+ */
+ public static Map<String, Map<String, Object>> createConfiguration(
+ final Map<String, InstanceEngine> instanceConfs) throws STORKSAMLEngineException {
+
+ final HashMap<String, Map<String, Object>> instances =
+ new HashMap<String, Map<String, Object>>();
+
+ LOGGER.info("Create configuration.");
+ try {
+ // Only create instances for SAMLEngine configuration.
+ // INSTANCE
+ for (Map.Entry<String, InstanceEngine> entry : instanceConfs
+ .entrySet()) {
+ final InstanceEngine iEngine = entry.getValue();
+
+ final Map<String, Object> intance = new HashMap<String, Object>();
+
+ // CONFIGURATION
+ for (ConfigurationEngine configuration : iEngine
+ .getConfiguration()) {
+ // Properties only for configuration SamlEngine.
+ if (configuration.getName().equalsIgnoreCase(
+ "SamlEngineConf")) {
+ intance.put(configuration.getName(),
+ getNewInstance(configuration.getParameters()
+ .get("fileConfiguration")));
+ } else {
+ intance.put(configuration.getName(), configuration
+ .getParameters());
+ }
+ }
+ instances.put(entry.getKey(), intance);
+ }
+ } catch (STORKSAMLEngineException ex) {
+ LOGGER.error("Can not create instance from file configuration.");
+ throw new STORKSAMLEngineException(ex);
+ }
+ return instances;
+ }
+
+
+ /**
+ * Gets the new instance.
+ *
+ * @param fileName the file name
+ * @return the properties from the new instance
+ * @throws STORKSAMLEngineException the STORKSAML engine
+ * runtime exception
+ */
+ private static Properties getNewInstance(final String fileName)
+ throws STORKSAMLEngineException {
+ InputStream fileEngineProp = null;
+
+ // fetch base from system properties, give a default if there is nothing configured
+ String base = System.getProperty("eu.stork.samlengine.config.location");
+ if (null != base) {
+ if (!base.endsWith("/")) {
+ base += "/";
+ }
+ } else {
+ base = "/";
+ }
+
+ LOGGER.info("Create file configuration properties to Stork Saml Engine: " + base + fileName);
+
+ try {
+
+ if (null != base)
+ fileEngineProp = new FileInputStream(base + fileName);
+ else
+ fileEngineProp = ConfigurationCreator.class
+ .getResourceAsStream(base + fileName);
+
+ final Properties configuration = new Properties();
+ configuration.loadFromXML(fileEngineProp);
+ return configuration;
+ } catch (InvalidPropertiesFormatException e) {
+ LOGGER.error("Invalid properties format.");
+ throw new STORKSAMLEngineException(e);
+ } catch (IOException e) {
+ LOGGER.error("Error read file: " + base + fileName);
+ throw new STORKSAMLEngineException(e);
+ } finally {
+ IOUtils.closeQuietly(fileEngineProp);
+ }
+ }
+
+ /**
+ * Instantiates a new instance creator.
+ */
+ private ConfigurationCreator() {
+ }
} \ No newline at end of file