Skip to content

Commit

Permalink
fix: properly returning multivalue attributes for non ldap persistenc…
Browse files Browse the repository at this point in the history
… stores

Signed-off-by: Rolain Djeumen <[email protected]>
  • Loading branch information
uprightech committed Oct 22, 2024
1 parent 72f7499 commit 306a8f6
Showing 1 changed file with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,50 @@
#if( $attribute.name.equals('eppnForNIH') )
<AttributeDefinition id="eduPersonPrincipalName" xsi:type="Scoped" scope="%{idp.scope}">
<InputDataConnector ref="siteDataConnector" attributeNames="uid"/>
<!-- AttributeEncoder xsi:type="SAML2ScopedString" name="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" friendlyName="eduPersonPrincipalName" encodeType="false" / -->
</AttributeDefinition
#else
#elseif( $resovlerParams.persistenceType.equals('ldap'))
<AttributeDefinition xsi:type="Simple" id="$attribute.name">
<InputDataConnector ref="siteDataConnector" attributeNames="$attribute.name"/>
<!-- AttributeEncoder xsi:type="SAML2String" name="$attrParams.attributeSAML2Strings.get($attribute.name)" friendlyName="$attribute.name" encodeType="false" / -->
</AttributeDefinition>
#elseif( $resovlerParams.persistenceType.equals('sql') && $attribute.oxMultiValuedAttribute == false )
<AttributeDefinition xsi:type="Simple" id="$attribute.name">
<InputDataConnector ref="siteDataConnector" attributeNames="$attribute.name"/>
</AttributeDefinition>
#elseif( $attribute.oxMultiValuedAttribute == false)
<AttributeDefinition xsi:type="Simple" id="$attribute.name">
<InputDataConnector ref="siteDataConnector" attributeNames="$attribute.name"/>
</AttributeDefinition>
#else
<AttributeDefinition xsi:type="ScriptedAttribute" id="$attribute.name">
<InputDataConnector ref="siteDataConnector" attributeNames="$attribute.name" />
<Script> <![CDATA[
logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.gluu.service.PythonService");
_JsonObjectType = Java.type("org.json.JSONObject");
_ArrayListType = Java.type("java.util.ArrayList");
_StringAttributeValueType = Java.type("net.shibboleth.idp.attribute.StringAttributeValue");
idpattr = ${attribute.name}.getNativeAttribute();
idpattr_values = idpattr.getValues();
if(idpattr_values.size() == 1) {
attrvalue = idpattr_values.get(0).getNativeValue();
try {
json = new _JsonObjectType(attrvalue);
jsonvalues = json.getJSONArray("v");
newidpattr_values = new _ArrayListType();
logger.info("here");
for(i = 0 ; i < jsonvalues.length() ;i++) {
val = jsonvalues.getString(i);
newidpattr_values.add(new _StringAttributeValueType(val));
logger.info("Added value {}",val);
}
idpattr.setValues(newidpattr_values);
logger.info("done");
}catch(e) {
logger.info("Error parsing multivalue attribute",e);
}
}
]]>
</Script>
</AttributeDefinition>
#end
#end
Expand Down

0 comments on commit 306a8f6

Please sign in to comment.