aboutsummaryrefslogtreecommitdiff
path: root/id
diff options
context:
space:
mode:
authorBojan Suzic <bojan.suzic@iaik.tugraz.at>2014-02-20 16:58:47 +0100
committerBojan Suzic <bojan.suzic@iaik.tugraz.at>2014-02-20 16:58:47 +0100
commit4e840ada79ad862494115374406b1ecb0b4a55ef (patch)
tree581d5521159d99f02775bc017d4a4ee665e3e9d8 /id
parent30f0d319f34d7fb13de2d1c7c6a72cdc918c335b (diff)
downloadmoa-id-spss-4e840ada79ad862494115374406b1ecb0b4a55ef.tar.gz
moa-id-spss-4e840ada79ad862494115374406b1ecb0b4a55ef.tar.bz2
moa-id-spss-4e840ada79ad862494115374406b1ecb0b4a55ef.zip
attribute changes
Diffstat (limited to 'id')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java33
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java74
2 files changed, 64 insertions, 43 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java
index a537a7708..446d942ab 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java
@@ -207,21 +207,18 @@ public class AuthenticationRequest implements IAction {
try {
for (PersonalAttribute personalAttribute : attrLst) {
- Logger.debug("Personal attribute found: " + personalAttribute.getName() + " status: " + personalAttribute.getStatus() + " isrequired: " + personalAttribute.isRequired() + " type: " + personalAttribute.getType());
-
- if ("givenName".equals(personalAttribute.getName())) {
- Logger.debug("Providing new attribute: " + personalAttribute.getName());
- PersonalAttribute newAttribute = new PersonalAttribute();
- newAttribute.setName("givenName");
- newAttribute.setValue(new ArrayList<String>(Collections.singletonList(moaSession.getIdentityLink().getGivenName())));
- attributeList.add(newAttribute);
- }
+ Logger.debug("Personal attribute found in request: " + personalAttribute.getName() + " isRequired: " + personalAttribute.isRequired());
+
+ moaAttributeProvider.populateAttribute(attributeList, personalAttribute);
+
+ // if ("givenName".equals(personalAttribute.getName())) {
+ // Logger.debug("Providing new attribute: " + personalAttribute.getName());
+ // PersonalAttribute newAttribute = new PersonalAttribute();
+ // newAttribute.setName("givenName");
+ // newAttribute.setValue(new ArrayList<String>(Collections.singletonList(moaSession.getIdentityLink().getGivenName())));
+ // attributeList.add(newAttribute);
+ // }
- if (personalAttribute.getValue().size() > 0) {
- for (String value : personalAttribute.getValue()) {
- Logger.info(" Value found: " + value);
- }
- }
}
} catch (Exception e) {
Logger.error("Exception, attributes: " + e.getMessage());
@@ -239,13 +236,13 @@ public class AuthenticationRequest implements IAction {
// moaAttributeProvider.populateAttribute(attributeList, personalAttribute.getName());
- moaAttributeProvider.populateAttribute(attributeList, "givenName");
+ // moaAttributeProvider.populateAttribute(attributeList, "givenName");
- moaAttributeProvider.populateAttribute(attributeList, "surname");
+ // moaAttributeProvider.populateAttribute(attributeList, "surname");
- moaAttributeProvider.populateAttribute(attributeList, "xxname");
+ // moaAttributeProvider.populateAttribute(attributeList, "xxname");
- moaAttributeProvider.populateAttribute(attributeList, "dateOfBirth");
+ // moaAttributeProvider.populateAttribute(attributeList, "dateOfBirth");
return attributeList;
}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java
index 33c1ffcd2..cde902e4d 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java
@@ -18,52 +18,76 @@ import java.util.Map;
*/
public class MOAAttributeProvider {
private final IdentityLink identityLink;
- private static final Map<String, String> storkAttributeMapping;
+ private static final Map<String, String> storkAttributeSimpleMapping;
+ private static final Map<String, String> storkAttributeFunctionMapping;
static {
- Map<String, String> tempMap = new HashMap<String, String>();
- tempMap.put("givenName", "getGivenName");
- tempMap.put("surname", "getFamilyName");
- tempMap.put("dateOfBirth", "getDateOfBirth");
- storkAttributeMapping = Collections.unmodifiableMap(tempMap);
+ Map<String, String> tempSimpleMap = new HashMap<String, String>();
+ tempSimpleMap.put("givenName", "getGivenName");
+ tempSimpleMap.put("surname", "getFamilyName");
+ tempSimpleMap.put("dateOfBirth", "getDateOfBirth");
+ storkAttributeSimpleMapping = Collections.unmodifiableMap(tempSimpleMap);
+ Map<String, String> tempFunctionMap = new HashMap<String, String>();
+ tempFunctionMap.put("eIdentifier", "geteIdentifier");
+ storkAttributeFunctionMapping = Collections.unmodifiableMap(tempFunctionMap);
}
-
public MOAAttributeProvider(IdentityLink identityLink) {
this.identityLink = identityLink;
Logger.debug("identity " + identityLink.getIdentificationType() + " " + identityLink.getIdentificationValue());
}
- public void populateAttribute(PersonalAttributeList attributeList, String storkAttribute) {
-
- if (storkAttributeMapping.containsKey(storkAttribute)) {
- Method method = null;
- Logger.debug("Trying to get value for attribute: " + storkAttribute);
+ public void populateAttribute(PersonalAttributeList attributeList, PersonalAttribute requestedAttribute ) {
+ String storkAttribute = requestedAttribute.getName();
+ if (storkAttributeSimpleMapping.containsKey(storkAttribute)) {
+ Logger.debug("Trying to get value for attribute using simple mapping [" + storkAttribute + "]");
try {
- method = identityLink.getClass().getDeclaredMethod(storkAttributeMapping.get(storkAttribute));
- String attributeValue = method.invoke(identityLink, new Class[]{}).toString();
- PersonalAttribute newAttribute = new PersonalAttribute();
- newAttribute.setName(storkAttribute);
- Logger.debug("Got attribute value: " + attributeValue);
- newAttribute.setValue(new ArrayList<String>(edu.emory.mathcs.backport.java.util.Collections.singletonList(attributeValue)));
- attributeList.add(newAttribute);
+ Method method = identityLink.getClass().getDeclaredMethod(storkAttributeSimpleMapping.get(storkAttribute));
+ populateAttributeWithMethod(method, identityLink, attributeList, storkAttribute, requestedAttribute.isRequired());
} catch (NoSuchMethodException e) {
Logger.error("Could not found MOA extraction method while getting attribute: " + storkAttribute);
e.printStackTrace();
- } catch (InvocationTargetException e) {
- Logger.error("Invocation target expcetiion while getting attribute: " + storkAttribute);
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- Logger.error("Illegal access exception while getting attribute: " + storkAttribute);
- e.printStackTrace();
}
+ } else if (storkAttributeFunctionMapping.containsKey(storkAttribute)) {
+
+ Logger.debug("Trying to get value for attribute using function mapping [" + storkAttribute + "]");
+ try {
+ Method method = this.getClass().getDeclaredMethod(storkAttributeFunctionMapping.get(storkAttribute));
+ populateAttributeWithMethod(method, this, attributeList, storkAttribute, requestedAttribute.isRequired());
+ } catch (NoSuchMethodException e) {
+ Logger.error("Could not found MOA extraction method while getting attribute: " + storkAttribute);
+ e.printStackTrace();
+ }
} else {
Logger.debug("MOA method for extraction of attribute " + storkAttribute + " not defined.");
}
+ }
+ private String geteIdentifier() {
+ return "askdlaskdlaskdsds";
+ }
+
+ private void populateAttributeWithMethod(Method method, Object object, PersonalAttributeList attributeList, String storkAttribute, Boolean isRequired) {
+ try {
+ String attributeValue = method.invoke(object, new Class[]{}).toString();
+ PersonalAttribute newAttribute = new PersonalAttribute();
+ newAttribute.setName(storkAttribute);
+ newAttribute.setStatus("Available");
+ newAttribute.setIsRequired(isRequired);
+ Logger.debug("Got attribute value: " + attributeValue);
+ newAttribute.setValue(new ArrayList<String>(edu.emory.mathcs.backport.java.util.Collections.singletonList(attributeValue)));
+ attributeList.add(newAttribute);
+ } catch (InvocationTargetException e) {
+ Logger.error("Invocation target exception while getting attribute: " + storkAttribute);
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ Logger.error("Illegal access exception while getting attribute: " + storkAttribute);
+ e.printStackTrace();
+ }
}
}
+