Skip to content
Snippets Groups Projects
Commit 17b60c28 authored by uhensler's avatar uhensler
Browse files

OO-2947: Parse all attributes

parent 0a78a709
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@
*/
package org.olat.shibboleth.manager;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
......@@ -53,29 +54,15 @@ public class ShibbolethAttributes {
private DifferenceChecker differenceChecker;
public void init(Map<String, String> attributes) {
Map<String, String> attributesCopy = new HashMap<>(attributes);
// Get and parse all mapped attributes even when Shibboleth does not
// deliver the attribute. It is to ensure the null values are parsed as
// well as the base for the later synchronization.
for (Entry<String, String> attribute : getUserMappingEntrySet()) {
String attributeName = attribute.getKey();
String attributeValue = attributesCopy.remove(attributeName);
ShibbolethAttributeHandler handler = getAttributeHandler(attributeName);
String parsedValue = handler.parse(attributeValue);
shibbolethMap.put(attributeName, parsedValue);
}
Collection<String> shibbolethAttributeNames = shibbolethModule.getShibbolethAttributeNames();
shibbolethMap = new HashMap<>(shibbolethAttributeNames.size());
// Get and parse the not mapped but delivered attributes to ensure that
// all attributes are available e.g. for the AttributeTranslator.
for (Entry<String, String> attribute : attributesCopy.entrySet()) {
String attributeName = attribute.getKey();
String attributeValue = attribute.getValue();
for (String attributeName : shibbolethAttributeNames) {
String attributeValue = attributes.get(attributeName);
ShibbolethAttributeHandler handler = getAttributeHandler(attributeName);
String parsedValue = handler.parse(attributeValue);
shibbolethMap.put(attributeName, parsedValue);
}
}
private ShibbolethAttributeHandler getAttributeHandler(String attributeName) {
......
......@@ -90,6 +90,7 @@ public class ShibbolethAttributesTest {
ReflectionTestUtils.setField(sut, "shibbolethModule", shibbolethModuleMock);
Map<String, String> shibbolethUserMapping = initUserMapping();
when(shibbolethModuleMock.getUserMapping()).thenReturn(shibbolethUserMapping);
when(shibbolethModuleMock.getShibbolethAttributeNames()).thenReturn(initShibbolethMap().keySet());
when(shibbolethModuleMock.getUIDAttributeName()).thenReturn(SHIB_UID_KEY);
when(shibbolethModuleMock.getPreferredLanguageAttributeName()).thenReturn(SHIB_LANG_KEY);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment