shibboleth.Conditions.RelyingPartyId regex?

Cantor, Scott cantor.2 at osu.edu
Fri Jul 17 16:55:44 EDT 2015


On 7/17/15, 4:29 PM, "users on behalf of Liam Hoekenga" <users-bounces at shibboleth.net on behalf of liamr at umich.edu> wrote:

>Do scripted predicates have access to the same information as scripted attributes?  (The same contexts exist and they contain the same info?)

They have a scripting context, it's not the same context, no. There are no attribute-centric context objects injected into the script. I think there's the profileContext and that's it. Nothing else is assumed.

The class in question is net.shibboleth.idp.profile.logic.ScriptedPredicate

You have to walk the context tree manually for the most part to pick up information, and we don't have good docs on the tree, which is why Brent's code that prints out the tree is fairly nice. He posted something about that to the dev list, it's probably something a script could leverage as a debugging/authoring help.

There are shortcuts that aren't real pretty like creating instances of the functions we use internally to default how we get access to things, but that's one way to make the scripts slightly less ugly.

For example, the bean in question is doing its magic by invoking a Functor:

net.shibboleth.idp.profile.context.navigate.RelyingPartyIdLookupFunction

The code inside that function class is the kind of thing a script would have to do to get access to the RP ID, unless it just instantiated that same functor class and ran it instead, which is doable.

Mostly, scripts have a lot of error handling needs that are done for you with the bean versions since all the null checks and the like are already coded. That's probably the most annoying part of writing them.

A non-checked, simplest possible example of how to access the RP ID from a script in the common places a condition would be installed to look at one would be something like:

var id = profileRequestContext.getSubcontext(
	"net.shibboleth.idp.profile.context.RelyingPartyContext").getRelyingPartyId()

That specific case isn't much code, as it happens. Sometimes it's more work than that, or deeper in the tree.

-- Scott



More information about the users mailing list