uppercase/lowercase an attribute
Jan Marek
jmarek at jcu.cz
Fri Feb 2 13:11:59 UTC 2024
Hello Martin,
Dne Čt, úno 01, 2024 at 11:44:05 CET napsal(a) Pavlik Martin:
> Good day,
>
> I am solving an example where there is an attribute called “test” which contains
> a different number of words with different letter sizes for different users.
> Shibboleth IdP version 4.
>
> I need to perform a conversion so that each word in this attribute has the first
> letter capitalized.
>
> For example from:
>
> WOrd WORD word
>
> I need use:
>
> Word Word Word
> 1. Is there a way to convert (uppercase/lowercase) an attribute before
> releasing it to the SP?
> 2. Or is it necessary to define a Script attribute definition?
>
> What would such a specific or similar example look like?
you can use a Scripted attribute definition like:
<AttributeDefinition xsi:type="ScriptedAttribute" id="displayNameNormalized">
<InputDataConnector ref="myLDAP" attributeNames="displayName"/>
<Script><![CDATA[
logger = Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute.resolver.displayNameNormalized");
stringValueType = Java.type("net.shibboleth.idp.attribute.StringAttributeValue");
logger.debug("displayName: " + displayName.getValues());
if (typeof displayName != "undefined" && displayName.getValues().size() > 0) {
arrayNames = displayName.getValues().split(" ");
textValue = "";
for (i = 0; i < arrayNames.length; i++) {
if (i > 0) { textValue += " "; }
textValue += arrayNames[i].charAt(0).toLocaleUpperCase();
textValue += arrayNames[i].substr(1).toLocaleLowerCase();
}
}
displayNameNormalized.addValue(new stringValueType(textValue));
logger.debug("displayNameNormalized: {} ", displayNameNormalized.getValues());
]]></Script>
</AttributeDefinition>
>
> Thank you.
>
>
> MP
Sincerely
Jan Marek
--
Ing. Jan Marek
University of South Bohemia
Academic Computer Centre
Phone: +420389032080
http://www.gnu.org/philosophy/no-word-attachments.cs.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6480 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/users/attachments/20240202/1f935920/attachment.p7s>
More information about the users
mailing list