From 1ba3c2042e0c4da08af39db6172ff1206dfece36 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 5 Mar 2014 10:22:46 +0100 Subject: ap plugins can be configured to listen to certain attributes --- .../moa/id/protocols/stork2/AttributeProviderFactory.java | 8 ++++---- .../id/protocols/stork2/EHvdAttributeProviderPlugin.java | 11 ++++++++--- .../id/protocols/stork2/StorkAttributeRequestProvider.java | 13 +++++++++++-- 3 files changed, 23 insertions(+), 9 deletions(-) (limited to 'id/server/idserverlib/src/main') 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 23edf69f9..de079c960 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 @@ -31,11 +31,11 @@ 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); + return new EHvdAttributeProviderPlugin(url, attributes); } else { return null; } @@ -52,7 +52,7 @@ public class AttributeProviderFactory { List result = new ArrayList(); for(AttributeProviderPlugin current : configuredAPs) - result.add(create(current.getName(), current.getUrl())); + 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 f97d8c804..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,26 +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) */ @Override - public IPersonalAttributeList acquire(PersonalAttribute attributes, AuthenticationSession moasession) + 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 { 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); -- cgit v1.2.3