aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src
diff options
context:
space:
mode:
authorFlorian Reimair <florian.reimair@iaik.tugraz.at>2014-02-12 11:37:06 +0100
committerFlorian Reimair <florian.reimair@iaik.tugraz.at>2014-02-13 22:06:01 +0100
commitd8302a2f7f3aae63593cd55bf0d5d4a4f9e5f55a (patch)
tree1821696b9f58ea4e8afd316c3fbf8de0dbd8bcf7 /id/server/idserverlib/src
parent366d0f285e0e1a2fa89e512d91f349488cbc82d9 (diff)
downloadmoa-id-spss-d8302a2f7f3aae63593cd55bf0d5d4a4f9e5f55a.tar.gz
moa-id-spss-d8302a2f7f3aae63593cd55bf0d5d4a4f9e5f55a.tar.bz2
moa-id-spss-d8302a2f7f3aae63593cd55bf0d5d4a4f9e5f55a.zip
sketched redirecting ap plugin
Diffstat (limited to 'id/server/idserverlib/src')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java46
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java2
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeRequestOngoingException.java5
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java31
-rw-r--r--id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties1
5 files changed, 74 insertions, 11 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java
index e74cf4e8b..93204f2ab 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java
@@ -7,10 +7,14 @@ import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
import at.gv.egovernment.moa.id.auth.exception.MOAIDException;
import at.gv.egovernment.moa.id.moduls.IAction;
import at.gv.egovernment.moa.id.moduls.IRequest;
+import at.gv.egovernment.moa.id.storage.AssertionStorage;
+import at.gv.egovernment.moa.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.opensaml.common.impl.SecureRandomIdentifierGenerator;
+
import eu.stork.peps.auth.commons.IPersonalAttributeList;
import eu.stork.peps.auth.commons.PersonalAttribute;
@@ -30,6 +34,7 @@ public class AttributeCollector implements IAction {
public AttributeCollector() {
// TODO generate from config
attributeProviders = new ArrayList<AttributeProvider>();
+ attributeProviders.add(new DemoRedirectAttributeProvider());
attributeProviders.add(new DemoNoRedirectAttributeProvider());
}
@@ -56,8 +61,9 @@ public class AttributeCollector implements IAction {
*
* @param container the {@link DataContainer} representing the status of the overall query.
* @return the string
+ * @throws MOAIDException
*/
- public String processRequest(DataContainer container) {
+ public String processRequest(DataContainer container) throws MOAIDException {
// check if there are attributes we need to fetch
IPersonalAttributeList requestAttributeList = container.getRequest().getPersonalAttributeList();
IPersonalAttributeList responseAttributeList = container.getResponse().getPersonalAttributeList();
@@ -71,18 +77,38 @@ public class AttributeCollector implements IAction {
for(String currentAttribute : missingAttributes) {
// - check if we can find a suitable AttributeProvider Plugin
for(AttributeProvider currentProvider : attributeProviders) {
- // - hand over control to the suitable plugin
- PersonalAttribute aquiredAttribute = currentProvider.acquire(currentAttribute);
+ try {
+ // - hand over control to the suitable plugin
+ PersonalAttribute aquiredAttribute = currentProvider.acquire(currentAttribute);
+
+ // - add the aquired attribute to the container
+ container.getResponse().getPersonalAttributeList().add(aquiredAttribute);
+ } catch(UnsupportedAttributeException e) {
+ // ok, try the next attributeprovider
+ }
- // - add the aquired attribute to the container
- container.getResponse().getPersonalAttributeList().add(aquiredAttribute);
}
}
- } catch(UnsupportedAttributeException e) {
- // TODO
- // memorize the container again
- return "12345"; // TODO what to do here?
- }
+ } catch (AttributeRequestOngoingException e) {
+ // the attribute request is ongoing and requires an external service.
+ try {
+ // memorize the container again
+ // - generate new key
+ String newArtifactId = new SecureRandomIdentifierGenerator()
+ .generateIdentifier();
+
+ // - put container in temporary store.
+ AssertionStorage.getInstance().put(newArtifactId, container);
+
+ // TODO - add container-key to httpresponse
+ } catch (Exception e1) {
+ // TODO should we return the response as is to the PEPS?
+ Logger.error("Error putting incomplete Stork response into temporary storage", e);
+ throw new MOAIDException("stork.11", null);
+ }
+
+ return "12345"; // TODO what to do here?
+ }
// build response
// done
return "12345"; // AssertionId
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java
index 2e4f2d8c5..fd35b0c71 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java
@@ -20,7 +20,7 @@ public interface AttributeProvider {
* @return the personal attribute
* @throws UnsupportedDataTypeException when the provider cannot acquire the specified attribute
*/
- public PersonalAttribute acquire(String attributeName) throws UnsupportedAttributeException;
+ public PersonalAttribute acquire(String attributeName) throws UnsupportedAttributeException, AttributeRequestOngoingException;
/**
* Parses the response we got from the external attribute provider.
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeRequestOngoingException.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeRequestOngoingException.java
new file mode 100644
index 000000000..be5a53f34
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeRequestOngoingException.java
@@ -0,0 +1,5 @@
+package at.gv.egovernment.moa.id.protocols.stork2;
+
+public class AttributeRequestOngoingException extends Exception {
+
+}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java
new file mode 100644
index 000000000..f44fbed07
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java
@@ -0,0 +1,31 @@
+package at.gv.egovernment.moa.id.protocols.stork2;
+
+import java.util.ArrayList;
+
+import javax.servlet.http.HttpServletRequest;
+
+import eu.stork.peps.auth.commons.PersonalAttribute;
+
+/**
+ * Just a simple demoprovider who can fetch any attribute you ask him.
+ */
+public class DemoRedirectAttributeProvider implements AttributeProvider {
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#acquire(java.lang.String)
+ */
+ @Override
+ public PersonalAttribute acquire(String attributeName)
+ throws UnsupportedAttributeException, AttributeRequestOngoingException {
+ throw new AttributeRequestOngoingException();
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#parse(javax.servlet.http.HttpServletRequest)
+ */
+ @Override
+ public PersonalAttribute parse(HttpServletRequest httpReq) {
+ return new PersonalAttribute("sepp", true, new ArrayList<String>(), "");
+ }
+
+}
diff --git a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties
index a6c0601e4..d6995a98e 100644
--- a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties
+++ b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties
@@ -202,6 +202,7 @@ stork.07=Es existiert kein STORK AuthnRequest f\u00FCr diese STORK Response
stork.08=STORK SAML Assertion Validierung fehlgeschlagen
stork.09=Fehler beim \u00FCberpr\u00FCfen der STORK B\u00FCrgerInnen Signatur
stork.10=Fehler in der Verbindung zum SZR-Gateway
+stork.11=Fehler beim Sammeln von StorkAttributen
pvp2.00={0} ist kein gueltiger consumer service index
pvp2.01=Fehler beim kodieren der PVP2 Antwort