ResolverScriptAttributeDefinition problem with clojure
Francesco Malvezzi
francesco.malvezzi at unimore.it
Mon Nov 21 15:31:57 GMT 2011
I've a problem using clojure as a jsr223 scripting language.
clojure places all variables in a namespace, for instance 'user' (which
is the default namespace). A variable named 'cljattr' in a jsr223 script
is read by java as 'user/cljattr'.
The matter is that, while ScriptedAttributeDefinition actually receives
'user/cljattr', some step later ShibbolethAttributeResolver tries
cleanResolvedAttributes on 'cljattr' (the part before the slash has been
stripped). cljattr of course does not exist and I have a
Exception in thread "main" java.lang.NullPointerException
at
edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.ShibbolethAttributeResolver.cleanResolvedAttributes(ShibbolethAttributeResolver.java:442)
in aacli.sh.
wiki at
https://wiki.shibboleth.net/confluence/display/SHIB2/ResolverScriptAttributeDefinition
already covers what is (in my opinion) the same problem, in a symmetric way:
Attribute IDs may contain illegal characters
Some scripting languages place certain restrictions on variable names
(e.g. may not contain a "-"). Ensure that any attribute you wish to use
does not contain such an illegal character in its ID. If it does use a
Simple Attribute Definition to create a new attribute, with a different
ID, whose source attribute is the attribute with the problematic ID.
What am I doing wrong? Is there a work-around?
Thank you,
Francesco
PS: follows the source of the test script:
<resolver:AttributeDefinition id="user/cljattr" xsi:type="Script"
language="Clojure" xmlns="urn:mace:shibboleth:2.0:resolver:ad">
<resolver:Dependency ref="ldap1" />
<resolver:AttributeEncoder xsi:type="SAML1String"
xmlns="urn:mace:shibboleth:2.0:attribute:encoder"
name="urn:mace:dir:attribute-def:cljattr" />
<resolver:AttributeEncoder xsi:type="SAML2String"
xmlns="urn:mace:shibboleth:2.0:attribute:encoder"
name="urn:mace:unimore.it:attribute-def:cljattr"
friendlyName="cljattr" />
<Script>
<![CDATA[
(ns user)
(import org.slf4j.LoggerFactory)
(import
edu.internet2.middleware.shibboleth.common.attribute.provider.BasicAttribute)
(import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute)
(def logger (. org.slf4j.LoggerFactory getLogger
"edu.internet2.middleware.shibboleth.resolver.Script.cljattr"))
(def cljattr (BasicAttribute. "cljattr"))
(.add (.getValues cljattr) "CLOJURE")
(.info logger (str "cljattr class: " (.getClass cljattr)))
(.info logger (str "cljattr: " (.getValues cljattr)))
]]>
</Script>
</resolver:AttributeDefinition>
More information about the users
mailing list