accessing user principal in scripted attributes
Liam Hoekenga
liamr at umich.edu
Fri Jun 12 13:40:37 EDT 2015
On Fri, Jun 12, 2015 at 12:37 PM, Rod Widdowson <rdw at steadingsoftware.com>
wrote:
> In that case I'm stumped and await the logs...
>
I'm not sure that they'll be that helpful, but here goes.
2015-06-12 13:37:53,120 - DEBUG
[net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedAttributeDefinition:193]
- Attribute Definition 'umichPersonUniqueId': adding to-be-populated
attribute to script context
2015-06-12 13:37:53,120 - DEBUG
[net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedAttributeDefinition:199]
- Attribute Definition 'umichPersonUniqueId': adding contexts to script
context
2015-06-12 13:37:53,121 - DEBUG
[net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedAttributeDefinition:205]
- Attribute Definition 'umichPersonUniqueId': adding emulated V2 request
context to script context
2015-06-12 13:37:53,121 - DEBUG
[net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedAttributeDefinition:210]
- Attribute Definition 'umichPersonUniqueId': adding dependent attribute
'umichPersonPrincipalName' with the following values to the script context:
[StringAttributeValue{value=liamr at comcast.net}]
2015-06-12 13:37:53,257 - ERROR
[net.shibboleth.idp.profile.impl.ResolveAttributes:256] - Profile Action
ResolveAttributes: Error resolving attributes
net.shibboleth.idp.attribute.resolver.ResolutionException: Attribute
Definition 'umichPersonUniqueId': unable to execute script
at
net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedAttributeDefinition.doAttributeDefinitionResolve(ScriptedAttributeDefinition.java:152)
Caused by: javax.script.ScriptException: TypeError: Cannot get property
"principalName" of null in <eval> at line number 7
at
jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:455)
Caused by: jdk.nashorn.internal.runtime.ECMAException: TypeError: Cannot
get property "principalName" of null
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
The script isn't terribly complicated either...
// set up the logger
logger =
Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute");
if (typeof(umichDirectoryID) == 'undefined') {
with( new JavaImporter( Packages.org.apache.commons.codec.digest )) {
salt = "some#salt#value#12345679";
uniqueValue = requestContext.principalName + salt;
// Create md5 value
localpart = DigestUtils.shaHex(uniqueValue);
// Prepend unique and pseudo-random localpart to domain name
umichPersonUniqueId.addValue(localpart);
}
} else {
umichPersonUniqueId.addValue(umichDirectoryID.getValues().get(0));
}
logger.debug("***** umichPersonUniqueId: " +
umichPersonUniqueId.getValues());
Liam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20150612/670d7267/attachment.html>
More information about the users
mailing list