View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/resolver/src/java/org/astrogrid/community/resolver/ant/CommunityTokenResolverTask.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/06/18 13:45:20 $</cvs:date>
5    * <cvs:version>$Revision: 1.4 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: CommunityTokenResolverTask.java,v $
9    *   Revision 1.4  2004/06/18 13:45:20  dave
10   *   Merged development branch, dave-dev-200406081614, into HEAD
11   *
12   *   Revision 1.3.18.1  2004/06/17 13:38:59  dave
13   *   Tidied up old CVS log entries
14   *
15   * </cvs:log>
16   *
17   *
18   */
19  package org.astrogrid.community.resolver.ant ;
20  
21  import java.net.URL ;
22  
23  import org.apache.tools.ant.Task ;
24  import org.apache.tools.ant.BuildException ;
25  
26  import org.astrogrid.community.resolver.CommunityTokenResolver ;
27  
28  /***
29   * An Ant task to validate a Community toekn.
30   * 
31   */
32  public class CommunityTokenResolverTask
33      extends CommunityResolverTask
34      {
35      /***
36       * Our debug flag.
37       *
38       */
39      private static final boolean DEBUG_FLAG = true ;
40  
41      /***
42       * Public constructor.
43       *
44       */
45      public CommunityTokenResolverTask()
46          {
47          //
48          // Initialise our base class.
49          super() ;
50          }
51  
52      /***
53       * Public constructor.
54       *
55       */
56      public CommunityTokenResolverTask(Task parent)
57          {
58          //
59          // Initialise our base class.
60          super() ;
61          //
62          // Set our project.
63          setProject(parent.getProject()) ;
64          }
65  
66      /***
67       * Initialise our Task.
68       *
69       */
70      public void init()
71          throws BuildException
72          {
73          if (DEBUG_FLAG) System.out.println("----\"----");
74          if (DEBUG_FLAG) System.out.println("CommunityTokenResolverTask.init()");
75          }
76  
77      /***
78       * Execute our Task.
79       *
80       */
81      public void execute()
82          throws BuildException
83          {
84          if (DEBUG_FLAG) System.out.println("----\"----");
85          if (DEBUG_FLAG) System.out.println("CommunityTokenResolverTask.execute()");
86          if (DEBUG_FLAG) System.out.println("  Token : " + this.getToken());
87          //
88          // Load our config properties.
89          this.configure() ;
90          //
91          // Try login to the account.
92          try {
93              //
94              // Create our resolver.
95              CommunityTokenResolver resolver ;
96              //
97              // Use our registry endpoint, if we have one.
98              if (null != this.getRegistry())
99                  {
100                 resolver = new CommunityTokenResolver(
101                     new URL(
102                         this.getRegistry()
103                         )
104                     ) ;
105                 }
106             //
107             // Otherwise, just create a default resolver.
108             else {
109                 resolver = new CommunityTokenResolver() ;
110                 }
111             //
112             // Ask our resolver to check the token.
113             this.setToken(
114                 resolver.checkToken(
115                     this.getToken()
116                     )
117                 ) ;
118             }
119         catch (Exception ouch)
120             {
121             throw new BuildException(ouch) ;
122             }
123         if (DEBUG_FLAG) System.out.println("----");
124         if (DEBUG_FLAG) System.out.println("Token : " + this.getToken());
125         if (DEBUG_FLAG) System.out.println("----");
126         }
127     }
128