Token task

The resolver toolkit provides an Ant task to validate an AstroGrid Community SecurityToken.

The task resolves the Community service that issued the original SecurityToken, calls the service to validate the token, and returns a new SecurityToken.

The following Ant script fragment registers the token resolver as an Ant task.

<taskdef name="validate.task" classname="org.astrogrid.community.resolver.ant.CommunityTokenResolverTask">
    <classpath refid="resolver.classpath"/>
</taskdef>

Live registry

The validate.live Ant task uses a live Registry service to resolve the endpoint of the Community service that issued the original token, and then calls the service to validate the token.

The following command will run the task, using a live Registry service to resolve the Community service.

ant -f resolver.xml validate.live

The command invokes the following Ant script to run the token resolver, using a live Registry service to resolve the Community service.

    <!--+
        | Validate a token, using a live registry service.
        +-->
    <target name="validate.live" depends="">
        <echo message=""/>
        <echo message="Token test ...."/>
        <!--+
            | Login to get our first token.
            +-->
        <login.task
            registry="${org.astrogrid.registry.url}"
            account="${org.astrogrid.community.account}"
            password="qwerty"
            />
        <!--+
            | Validate our token.
            +-->
        <validate.task
            registry="${org.astrogrid.registry.url}"
            />
    </target>

The validate task reads the original token from an Ant property called org.astrogrid.community.token.

In this example, script needs to invoke the login.task to get the first token before it can call the validate.task to check the token.

The validate task requires the following parameters :

  • registry - The endpoint URL for an AstroGrid Registry service

If the original token was valid, then the task will receive a new security token from the Community service. The task will automatically update the org.astrogrid.community.token Ant property with the new token.

Local registry

There are reported problems when using the local registry files on a Windows system.

The validate.local Ant task uses local Registry files to resolve the endpoint of the Community service that issued the original token, and then calls the service to validate the token.

The following command will run the token resolver task, using local Registry files to resolve the Community service.

ant -f resolver.xml token.local

The command invokes the following Ant script to run the token resolver, using local Registry properties to resolve the Community service.

<!--+
    | Validate a token, using the local registry config.
    +-->
<target name="validate.local" depends="">
    <echo message=""/>
    <echo message="Token test ...."/>
    <!--+
        | Login to get our first token.
        +-->
    <login.task
        properties="${basedir}/config/registry.properties"
        account="${org.astrogrid.community.account}"
        password="qwerty"
        />
    <!--+
        | Validate our token.
        +-->
    <validate.task
        properties="${basedir}/config/registry.properties"
        />
</target>

The validate task reads the original token from an Ant property called org.astrogrid.community.token.

In this example, script needs to invoke the login.task to get the first token before it can call the validate.task to check the token.

The validate task requires the following parameters :

  • properties - The location of the local Registry properties file

If the original token was valid, then the task will receive a new security token from the Community service. The task will automatically update the org.astrogrid.community.token Ant property with the new token.