aboutsummaryrefslogtreecommitdiff
path: root/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2015-07-22 07:12:50 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2015-07-22 07:12:50 +0200
commitfa22d2f7f43d1faa8c3ce12ada3802e9c55c4d33 (patch)
tree24c807612d5ffac5eb885463dadd838617568ee3 /id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper
parente993db9862741f7a861c03878176576a765dc917 (diff)
downloadmoa-id-spss-fa22d2f7f43d1faa8c3ce12ada3802e9c55c4d33.tar.gz
moa-id-spss-fa22d2f7f43d1faa8c3ce12ada3802e9c55c4d33.tar.bz2
moa-id-spss-fa22d2f7f43d1faa8c3ce12ada3802e9c55c4d33.zip
stor correct BASE64 content into configuration
Diffstat (limited to 'id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper')
-rw-r--r--id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/GUIDataParser.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/GUIDataParser.java b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/GUIDataParser.java
new file mode 100644
index 000000000..be47a404f
--- /dev/null
+++ b/id/moa-id-webgui/src/main/java/at/gv/egovernment/moa/id/config/webgui/helper/GUIDataParser.java
@@ -0,0 +1,67 @@
+/*
+ * 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.config.webgui.helper;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.util.Base64Utils;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+/**
+ * @author tlenz
+ *
+ */
+public class GUIDataParser {
+ private static final Logger log = LoggerFactory.getLogger(GUIDataParser.class);
+ /**
+ * Extract the BASE64 content from GUI upload
+ *
+ * @param guiUpload {String}, which is committed by GUI
+ * @return Base64 encoded data or null if data is not parseable or empty
+ */
+ public static String getBase64ContentFromGUIUpload(String guiUpload) {
+ if (MiscUtil.isNotEmpty(guiUpload) &&
+ !guiUpload.equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT) ) {
+ String[] bkuSelectTemplateSplitted = guiUpload.split(",");
+ String base64 = null;
+ if (bkuSelectTemplateSplitted.length > 1)
+ base64 = bkuSelectTemplateSplitted[1];
+ else
+ base64 = guiUpload;
+
+ try {
+ if (Base64Utils.decode(base64, false) == null)
+ return base64;
+
+ } catch (IOException e) {
+ log.debug("GUI upoad is not decodeable.", e);
+
+ }
+ }
+ return null;
+ }
+}