The compile call is a no-op and makes no difference since the engine
evaluates the script. That looks like a bug in getAttribute(). I use
put and get from the engine directly and may have overlooked something
in the attr calls. I'll upload a fix in google code asap.

On Nov 13, 9:52 am, Francesco <francesco.m...@gmail.com> wrote:
> I was trying to write a simple script attribute definition for
> shibboleth as 
> in:https://wiki.shibboleth.net/confluence/display/SHIB2/ResolverScriptAt...
> 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.BasicAttribut e)
> (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.att 
> ributeDefinition.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.AttributeReso 
> lutionException:
> user/cljattr produced a null attributes
>         at
> edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attr 
> ibuteDefinition.ScriptedAttributeDefinition.doResolve(ScriptedAttributeDefi 
> nition.java:
> 130) ~[shibboleth-common-1.3.2.jar:na]
>         at
> edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attr 
> ibuteDefinition.BaseAttributeDefinition.resolve(BaseAttributeDefinition.jav a:
> 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 
> codehttp://svn.shibboleth.net/view/java-shib-common/tags/1.3.4/src/main/j...
> 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.att 
> ributeDefinition.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