aboutsummaryrefslogtreecommitdiff
path: root/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java')
-rw-r--r--DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java b/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java
new file mode 100644
index 000000000..b80c63dc2
--- /dev/null
+++ b/DocumentService/src/eu/stork/documentservice/utils/GetDSSFileAction.java
@@ -0,0 +1,84 @@
+package eu.stork.documentservice.utils;
+/*
+ * This work is Open Source and licensed by the European Commission under the
+ * conditions of the European Public License v1.1
+ *
+ * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1);
+ *
+ * any use of this file implies acceptance of the conditions of this license.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.apache.log4j.Logger;
+import org.bouncycastle.util.encoders.UrlBase64;
+
+import eu.stork.peps.auth.commons.IPersonalAttributeList;
+import eu.stork.peps.auth.commons.PEPSUtil;
+
+import eu.stork.peps.auth.commons.PersonalAttribute;
+import eu.stork.peps.auth.commons.STORKAttrQueryRequest;
+
+//import eu.stork.peps.auth.cpeps.AUCPEPS;
+import eu.stork.peps.auth.engine.STORKSAMLEngine;
+import eu.stork.peps.exceptions.STORKSAMLEngineException;
+
+/**
+ * This Action will be invoked by file transfer in order to validate saml
+ *
+ * @author Advania
+ *
+ * @version $Revision: $, $Date: $
+ *
+ */
+public final class GetDSSFileAction {
+ /**
+ * Unique identifier.
+ */
+ private static final long serialVersionUID = 6233180247896844849L;
+ /**
+ * Logger object.
+ */
+ private static final Logger LOG = Logger.getLogger(GetDSSFileAction.class.getName());
+// public String SAMLRequest;
+// public String docId;
+ private static final String SAML_INSTANCE = "VIDP";
+
+ public static String processDocRequest(String samlRequest)
+ {
+ String result = "";
+ //final Map<String, String> parameters = getHttpRequestParameters();
+ STORKAttrQueryRequest request;
+ try {
+ request = processDocRequest_(samlRequest);
+ final IPersonalAttributeList pal = request.getPersonalAttributeList();
+ final PersonalAttribute sdoc = pal.get("docRequest");
+ if (sdoc != null)
+ {
+ String docId = sdoc.getValue().get(0);
+ return docId;
+ }
+ } catch (final STORKSAMLEngineException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static STORKAttrQueryRequest processDocRequest_(String samlRequest)
+ throws STORKSAMLEngineException{
+
+ // fetch the samlToken from the request
+ final byte[] samlToken = UrlBase64.decode(samlRequest);
+
+ final STORKSAMLEngine engine = STORKSAMLEngine.getInstance(SAML_INSTANCE);
+
+ final STORKAttrQueryRequest attrData= engine.validateSTORKAttrQueryRequest(samlToken);
+ //SAMLRequest = new String(samlToken);
+ LOG.trace("Processing doc request done. SAML: " + new String(samlToken));
+ return attrData;
+ }
+}