aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main
diff options
context:
space:
mode:
authorFlorian Reimair <florian.reimair@iaik.tugraz.at>2014-02-11 11:01:32 +0100
committerFlorian Reimair <florian.reimair@iaik.tugraz.at>2014-02-13 22:06:01 +0100
commit95ea36e8b84de119165ce8c14fc5c1e9facd797f (patch)
treeaf4c1d1986a030919eb8775676643833cbc0e9f8 /id/server/idserverlib/src/main
parent639017a14904323c0eb2cd5d8cccf65ad8f2a841 (diff)
downloadmoa-id-spss-95ea36e8b84de119165ce8c14fc5c1e9facd797f.tar.gz
moa-id-spss-95ea36e8b84de119165ce8c14fc5c1e9facd797f.tar.bz2
moa-id-spss-95ea36e8b84de119165ce8c14fc5c1e9facd797f.zip
added ap logic #1
Diffstat (limited to 'id/server/idserverlib/src/main')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java38
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java32
2 files changed, 66 insertions, 4 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 fbc959cc4..b93b31b49 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
@@ -1,12 +1,19 @@
package at.gv.egovernment.moa.id.protocols.stork2;
+import java.util.ArrayList;
+import java.util.List;
+
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import eu.stork.peps.auth.commons.IPersonalAttributeList;
+import eu.stork.peps.auth.commons.PersonalAttribute;
+
/**
* the AttributeCollector Action tries to get all requested attributes from a set of {@link AttributeProvider} Plugins.
* The class is called whenever the {@link AuthenticationRequest} Action is invoked and checks for missing attributes.
@@ -17,6 +24,14 @@ import javax.servlet.http.HttpServletResponse;
*
*/
public class AttributeCollector implements IAction {
+
+ private ArrayList<AttributeProvider> attributeProviders;
+
+ public AttributeCollector() {
+ // TODO generate from config
+ attributeProviders = new ArrayList<AttributeProvider>();
+ attributeProviders.add(new DemoNoRedirectAttributeProvider());
+ }
/* (non-Javadoc)
@@ -44,10 +59,25 @@ public class AttributeCollector implements IAction {
*/
public String processRequest(DataContainer container) {
// check if there are attributes we need to fetch
- // for each attribute still missing
- // - check if we can find a suitable AttributeProvider Plugin
- // - hand over control to the suitable plugin
- // - add the aquired attribute to the container
+ List<String> missingAttributes = new ArrayList<String>();
+ try {
+ // for each attribute still missing
+
+ 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);
+
+ // - 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?
+ }
// build response
// done
return "12345"; // AssertionId
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java
new file mode 100644
index 000000000..23afc2544
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java
@@ -0,0 +1,32 @@
+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 DemoNoRedirectAttributeProvider 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 {
+ return new PersonalAttribute("sepp", true, new ArrayList<String>(), "");
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#parse(javax.servlet.http.HttpServletRequest)
+ */
+ @Override
+ public PersonalAttribute parse(HttpServletRequest httpReq) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}