aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/builder/SPSpecificGUIBuilderConfigurationWithFileSystemLoad.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/builder/SPSpecificGUIBuilderConfigurationWithFileSystemLoad.java')
-rw-r--r--id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/builder/SPSpecificGUIBuilderConfigurationWithFileSystemLoad.java110
1 files changed, 110 insertions, 0 deletions
diff --git a/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/builder/SPSpecificGUIBuilderConfigurationWithFileSystemLoad.java b/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/builder/SPSpecificGUIBuilderConfigurationWithFileSystemLoad.java
new file mode 100644
index 000000000..b5c50004b
--- /dev/null
+++ b/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/builder/SPSpecificGUIBuilderConfigurationWithFileSystemLoad.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * 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/
+ *
+ * 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.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.auth.frontend.builder;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import at.gv.egovernment.moa.id.commons.api.IRequest;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.FileUtils;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+/**
+ * @author tlenz
+ *
+ */
+public class SPSpecificGUIBuilderConfigurationWithFileSystemLoad extends AbstractServiceProviderSpecificGUIFormBuilderConfiguration {
+
+ private String configKeyIdentifier = null;
+ private String configRootContextDir = null;
+
+ /**
+ * @param authURL PublicURLPrefix of the IDP but never null
+ * @param viewName Name of the template (with suffix) but never null
+ * @param configKeyIdentifier Identifier of the configuration key in OA configuration that holds the filesystem URI to template
+ * @param formSubmitEndpoint EndPoint on which the form should be submitted
+ * @param configRootContextDir Path to MOA-ID-Auth configuration root directory
+ * or null if the form must not submitted
+ */
+ public SPSpecificGUIBuilderConfigurationWithFileSystemLoad(String authURL, String viewName,
+ String configKeyIdentifier, String formSubmitEndpoint, String configRootContextDir) {
+ super(authURL, viewName, formSubmitEndpoint);
+ this.configKeyIdentifier = configKeyIdentifier;
+ this.configRootContextDir = configRootContextDir;
+
+ }
+
+ /**
+ * @param Current processed pending-request DAO but never null
+ * @param viewName Name of the template (with suffix) but never null
+ * @param configKeyIdentifier Identifier of the configuration key in OA configuration that holds the filesystem URI to template
+ * @param formSubmitEndpoint EndPoint on which the form should be submitted
+ * @param configRootContextDir Path to MOA-ID-Auth configuration root directory
+ */
+ public SPSpecificGUIBuilderConfigurationWithFileSystemLoad(IRequest pendingReq, String viewName,
+ String configKeyIdentifier, String formSubmitEndpoint, String configRootContextDir) {
+ super(pendingReq, viewName, formSubmitEndpoint);
+ this.configKeyIdentifier = configKeyIdentifier;
+ this.configRootContextDir = configRootContextDir;
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.auth.frontend.AbstractGUIFormBuilder#getTemplate(java.lang.String)
+ */
+ @Override
+ public InputStream getTemplate(String viewName) {
+ if (pendingReq != null && pendingReq.getOnlineApplicationConfiguration() != null &&
+ configKeyIdentifier != null) {
+ try {
+ String templateURL = pendingReq.getOnlineApplicationConfiguration().getConfigurationValue(configKeyIdentifier);
+ if (MiscUtil.isNotEmpty(templateURL)) {
+ String absURL = FileUtils.makeAbsoluteURL(templateURL, configRootContextDir);
+ if (!absURL.startsWith("file:")) {
+ Logger.warn("GUI template are only loadable from filesystem! "
+ + "(templateURL: " + absURL + ")");
+ return null;
+ }
+
+ Logger.debug("Load template URL for view: " + viewName + " from: " + absURL);
+ URI uri = new URL(absURL).toURI();
+ return new FileInputStream(new File(uri));
+
+ }
+ } catch (FileNotFoundException | URISyntaxException | MalformedURLException e) {
+ Logger.warn("Template for view: " + viewName + " is NOT loadable! -> Switch to default template", e);
+
+ }
+ }
+ Logger.trace("NO ServiceProvider specific template for view: " + viewName + " available");
+ return null;
+ }
+
+}