aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib
diff options
context:
space:
mode:
authorBojan Suzic <bojan.suzic@iaik.tugraz.at>2014-03-05 21:36:01 +0100
committerBojan Suzic <bojan.suzic@iaik.tugraz.at>2014-03-05 21:36:01 +0100
commitb757096ff32fa80908527220f8e08046015c2449 (patch)
tree837e839c74366a2b3af0c0dacf26cba1dc6f828d /id/server/idserverlib
parented54650118390e2747dece3bad6bd74b6eefec7a (diff)
parent31a10590f3efee8aca463b43623ee689f7b0c605 (diff)
downloadmoa-id-spss-b757096ff32fa80908527220f8e08046015c2449.tar.gz
moa-id-spss-b757096ff32fa80908527220f8e08046015c2449.tar.bz2
moa-id-spss-b757096ff32fa80908527220f8e08046015c2449.zip
Merge branch 'bs_3_fr' into moa2_0_tlenz_bs_3
Conflicts: id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java
Diffstat (limited to 'id/server/idserverlib')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java11
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java40
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java16
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java13
4 files changed, 54 insertions, 26 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 0317322ee..f660e1b33 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
@@ -119,6 +119,7 @@ public class AttributeCollector implements IAction {
*/
IPersonalAttributeList aquiredAttributes = new PersonalAttributeList();
currentAttribute.setStatus("notAvailable");
+ aquiredAttributes.add((PersonalAttribute) currentAttribute.clone());
addOrUpdateAll(container.getResponse().getPersonalAttributeList(), aquiredAttributes);
// - check if we can find a suitable AttributeProvider Plugin
@@ -252,11 +253,19 @@ public class AttributeCollector implements IAction {
*
* @param target the target
* @param source the source
+ * @throws MOAIDException
*/
- private void addOrUpdateAll(IPersonalAttributeList target, IPersonalAttributeList source) {
+ private void addOrUpdateAll(IPersonalAttributeList target, IPersonalAttributeList source) throws MOAIDException {
for (PersonalAttribute current : source) {
// check if we need to update the current pa
if (target.containsKey(current.getName())) {
+ PersonalAttribute existing = target.get(current.getName());
+ if(!(existing.isEmptyValue() && existing.isEmptyComplexValue()))
+ if(!(existing.getValue().equals(current.getValue()) || existing.getComplexValue().equals(current.getComplexValue()))) {
+ Logger.error("Attribute Value does not match the value from first authentication!");
+ throw new MOAIDException("stork.14", null);
+ }
+
target.get(current.getName()).setStatus(current.getStatus());
target.get(current.getName()).setValue(current.getValue());
target.get(current.getName()).setComplexValue(current.getComplexValue());
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java
index 538e59401..dbeaf94e9 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java
@@ -1,10 +1,10 @@
package at.gv.egovernment.moa.id.protocols.stork2;
-import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin;
-
import java.util.ArrayList;
import java.util.List;
+import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin;
+
/**
* A factory for creating AttributeProvider objects.
*/
@@ -34,9 +34,9 @@ public class AttributeProviderFactory {
* the simpleName for the providers class
* @return the attribute provider
*/
- public static AttributeProvider create(String shortname, String url) {
+ public static AttributeProvider create(String shortname, String url, String attributes) {
if (shortname.equals("StorkAttributeRequestProvider")) {
- return new StorkAttributeRequestProvider(url);
+ return new StorkAttributeRequestProvider(url, attributes);
} else if(shortname.equals("EHvdAttributeProvider")) {
return new EHvdAttributeProviderPlugin(url);
} else if(shortname.equals("SignedDocAttributeRequestProvider")) {
@@ -44,23 +44,25 @@ public class AttributeProviderFactory {
} else if (shortname.equals("MISAttributeProvider")) {
return new MISAttributeProvider(url);
} else {
+ return new EHvdAttributeProviderPlugin(url, attributes);
+ } else {
return null;
}
}
- /**
- * Gets fresh instances of the configured plugins.
- *
- * @param configuredAPs the configured a ps
- * @return the configured plugins
- */
- public static List<AttributeProvider> getConfiguredPlugins(
- List<AttributeProviderPlugin> configuredAPs) {
-
- List<AttributeProvider> result = new ArrayList<AttributeProvider>();
- for (AttributeProviderPlugin current : configuredAPs)
- result.add(create(current.getName(), current.getUrl()));
-
- return result;
- }
+ /**
+ * Gets fresh instances of the configured plugins.
+ *
+ * @param configuredAPs the configured a ps
+ * @return the configured plugins
+ */
+ public static List<AttributeProvider> getConfiguredPlugins(
+ List<AttributeProviderPlugin> configuredAPs) {
+
+ List<AttributeProvider> result = new ArrayList<AttributeProvider>();
+ for(AttributeProviderPlugin current : configuredAPs)
+ result.add(create(current.getName(), current.getUrl(), current.getAttributes()));
+
+ return result;
+ }
}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java
index d387bfcea..a36855d33 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java
@@ -44,25 +44,31 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider {
/** The destination. */
private Object destination;
+
+ /** The attributes. */
+ private String attributes;
/**
* Instantiates a new e hvd attribute provider plugin.
*
* @param url the service url
+ * @param attributes
*/
- public EHvdAttributeProviderPlugin(String url) {
+ public EHvdAttributeProviderPlugin(String url, String supportedAttributes) {
destination = url;
+ attributes = supportedAttributes;
}
/* (non-Javadoc)
* @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#acquire(eu.stork.peps.auth.commons.PersonalAttribute)
*/
- public IPersonalAttributeList acquire(PersonalAttribute attributes, AuthenticationSession moasession)
+ @Override
+ public IPersonalAttributeList acquire(PersonalAttribute attribute, AuthenticationSession moasession)
throws UnsupportedAttributeException,
ExternalAttributeRequestRequiredException, MOAIDException {
// break when we cannot handle the requested attribute
- if(!attributes.getName().equals("isHealthCareProfessional"))
+ if(!attributes.contains(attribute.getName()))
throw new UnsupportedAttributeException();
try {
@@ -219,7 +225,8 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider {
/* (non-Javadoc)
* @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#performRedirect(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, at.gv.egovernment.moa.id.config.auth.OAAuthParameter)
*/
- public void performRedirect(String url, String citizenCountyCode,
+ @Override
+ public void performRedirect(String url, String spCountyCode,
HttpServletRequest req, HttpServletResponse resp,
OAAuthParameter oaParam) throws MOAIDException {
// there is no redirect required
@@ -228,6 +235,7 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider {
/* (non-Javadoc)
* @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#parse(javax.servlet.http.HttpServletRequest)
*/
+ @Override
public IPersonalAttributeList parse(HttpServletRequest httpReq)
throws UnsupportedAttributeException, MOAIDException {
// there is no redirect required, so we throw an exception when someone asks us to parse a response
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java
index 797695a00..d8becaaf7 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java
@@ -34,14 +34,19 @@ public class StorkAttributeRequestProvider implements AttributeProvider {
/** The destination. */
private String destination;
-
+
+ /** The attributes. */
+ private String attributes;
+
/**
* Instantiates a new stork attribute request provider.
*
* @param apUrl the AP location
+ * @param supportedAttributes the supported attributes as csv
*/
- public StorkAttributeRequestProvider(String apUrl) {
+ public StorkAttributeRequestProvider(String apUrl, String supportedAttributes) {
destination = apUrl;
+ attributes = supportedAttributes;
}
/* (non-Javadoc)
@@ -49,6 +54,10 @@ public class StorkAttributeRequestProvider implements AttributeProvider {
*/
public IPersonalAttributeList acquire(PersonalAttribute attribute, AuthenticationSession moasession)
throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException {
+
+ if (!attributes.contains(attribute.getName()))
+ throw new UnsupportedAttributeException();
+
requestedAttributes = new PersonalAttributeList(1);
requestedAttributes.add(attribute);
throw new ExternalAttributeRequestRequiredException(this);