aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MOAAttributeProvider.java48
1 files changed, 34 insertions, 14 deletions
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 d7d6601c9..021eaee37 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
@@ -25,8 +25,11 @@ package at.gv.egovernment.moa.id.protocols.stork2;
import at.gv.egovernment.moa.id.auth.builder.BPKBuilder;
import at.gv.egovernment.moa.id.auth.data.IdentityLink;
import at.gv.egovernment.moa.id.auth.exception.BuildException;
+import at.gv.egovernment.moa.id.data.AuthenticationRole;
import at.gv.egovernment.moa.id.data.IAuthData;
+import at.gv.egovernment.moa.id.util.PVPtoSTORKRoleMapper;
import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
import eu.stork.peps.auth.commons.PersonalAttribute;
import eu.stork.peps.auth.commons.PersonalAttributeList;
import eu.stork.peps.auth.commons.STORKStatusCode;
@@ -58,11 +61,11 @@ public class MOAAttributeProvider {
Map<String, String> tempSimpleMap = new HashMap<String, String>();
tempSimpleMap.put("givenName", "getGivenName");
tempSimpleMap.put("surname", "getFamilyName");
- tempSimpleMap.put("dateOfBirth", "getFormatedDateOfBirth");
storkAttributeSimpleMapping = Collections.unmodifiableMap(tempSimpleMap);
Map<String, String> tempFunctionMap = new HashMap<String, String>();
tempFunctionMap.put("eIdentifier", "geteIdentifier");
tempFunctionMap.put("ECApplicationRole","getECApplicationRole");
+ tempSimpleMap.put("dateOfBirth", "getFormatedDateOfBirth");
storkAttributeFunctionMapping = Collections.unmodifiableMap(tempFunctionMap);
}
@@ -112,23 +115,34 @@ public class MOAAttributeProvider {
private List<String> getECApplicationRole() {
List<String> storkRoles = null;
-
- if (authData.getAuthenticationRoles() != null
+
+ if (true || authData.getAuthenticationRoles() != null
&& authData.getAuthenticationRoles().size() > 0) {
-
-
- //TODO: implement PVP role -> STORK role mapping
-// storkRoles = new ArrayList<String>();
-// storkRoles.add("CIRCABC/viewer");
-
- }
-
+
+ storkRoles = new ArrayList<String>();
+ PVPtoSTORKRoleMapper mapper = PVPtoSTORKRoleMapper.getInstance();
+ for (AuthenticationRole el : authData.getAuthenticationRoles()) {
+ String storkRole = mapper.map(el);
+ if (MiscUtil.isNotEmpty(storkRole))
+ storkRoles.add(storkRole);
+
+ }
+ }
return storkRoles;
}
+ private String getFormatedDateOfBirth() {
+ if (authData.getDateOfBirth() != null)
+ return authData.getFormatedDateOfBirth();
+
+ else
+ return null;
+
+ }
+
private void populateAttributeWithMethod(Method method, Object object, PersonalAttributeList attributeList, String storkAttribute, Boolean isRequired) {
try {
- Object attributeValue = method.invoke(object, new Class[]{}).toString();
+ Object attributeValue = method.invoke(object, new Class[]{});
PersonalAttribute newAttribute = new PersonalAttribute();
newAttribute.setName(storkAttribute);
@@ -143,9 +157,15 @@ public class MOAAttributeProvider {
else if (attributeValue instanceof List<?>) {
List<?> attributeValueList = (List<?>) attributeValue;
- if (attributeValueList.size() > 0 && attributeValueList.get(0) instanceof String)
+ if (attributeValueList.size() > 0 && attributeValueList.get(0) instanceof String) {
newAttribute.setValue((List<String>) attributeValueList);
-
+
+ } else {
+ Logger.info("Attribute " + storkAttribute + " is not available.");
+ newAttribute.setStatus(STORKStatusCode.STATUS_NOT_AVAILABLE.name());
+
+ }
+
} else {
Logger.error("Receive an unsupported type for attribute " + storkAttribute);