I was trying to write a simple script attribute definition for
shibboleth as in:
https://wiki.shibboleth.net/confluence/display/SHIB2/ResolverScriptAttributeDefinition
with the help of clojure-jsr223.

I included both clojure.jar and clojure-jsr223.jar in classpath and
voila my script in attribute-resolver.xml:

<resolver:AttributeDefinition id="user/cljattr" xsi:type="Script"
language="Clojure" xmlns="urn:mace:shibboleth:2.0:resolver:ad">
        <resolver:Dependency ref="ldap" />
        <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: " (.getValues cljattr)))
          ]]>
        </Script>
    </resolver:AttributeDefinition>

But shibboleth returns:

18:44:18.771 - INFO
[edu.internet2.middleware.shibboleth.resolver.Script.cljattr:-2] -
cljattr: [CLOJURE]
18:44:18.772 - ERROR
[edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.ScriptedAttributeDefinition:
129] - user/cljattr produced a null attribute
18:44:18.778 - ERROR
[edu.internet2.middleware.shibboleth.common.attribute.AttributeAuthorityCLI:
392] - Error encountered during attribute resolution and filtering
edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolutionException:
user/cljattr produced a null attributes
        at
edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.ScriptedAttributeDefinition.doResolve(ScriptedAttributeDefinition.java:
130) ~[shibboleth-common-1.3.2.jar:na]
        at
edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.BaseAttributeDefinition.resolve(BaseAttributeDefinition.java:
108) ~[shibboleth-common-1.3.2.jar:na]

This means script is logging ok and attribute has a value but fails to
export value to attribute resolver.

Shibboleth source code
http://svn.shibboleth.net/view/java-shib-common/tags/1.3.4/src/main/java/edu/internet2/middleware/shibboleth/common/attribute/resolver/provider/attributeDefinition/ScriptedAttributeDefinition.java?view=markup
seems to use the getAttribute method of class
javax.script.SimpleScriptContext, which I could not find in clojure-
jsr223 source.

Am I missing something?

Can you spot obvious mistakes? Please note changing attribute id from
'user/cljattr' to 'cljattr' does not change anything.

thank you for your attention,

Francesco

PS:
shibboleth claims it is able to compile script:
18:44:12.237 - WARN
[edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.ScriptedAttributeDefinition:
153] - user/cljattr unable to compile even though the scripting engine
supports this functionality.
actually it is only a warn. Can be important?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to