1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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.CommunityPasswordResolver ;
27
28 /***
29 * An Ant task to login to a Community service.
30 *
31 */
32 public class CommunityPasswordResolverTask
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 CommunityPasswordResolverTask()
46 {
47
48
49 super() ;
50 }
51
52 /***
53 * Public constructor.
54 *
55 */
56 public CommunityPasswordResolverTask(Task parent)
57 {
58
59
60 super() ;
61
62
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("CommunityPasswordResolverTask.init()");
75 }
76
77 /***
78 * Our account identifier.
79 *
80 */
81 private String account ;
82
83 /***
84 * Get our account identifier.
85 *
86 */
87 public String getAccount()
88 {
89 return this.account ;
90 }
91
92 /***
93 * Set our account identifier.
94 *
95 */
96 public void setAccount(String value)
97 {
98 this.account = value ;
99 }
100
101 /***
102 * Our account password.
103 *
104 */
105 private String password ;
106
107 /***
108 * Get our account password.
109 *
110 */
111 public String getPassword()
112 {
113 return this.password ;
114 }
115
116 /***
117 * Set our account password.
118 *
119 */
120 public void setPassword(String value)
121 {
122 this.password = value ;
123 }
124
125 /***
126 * Execute our Task.
127 *
128 */
129 public void execute()
130 throws BuildException
131 {
132 if (DEBUG_FLAG) System.out.println("----\"----");
133 if (DEBUG_FLAG) System.out.println("CommunityPasswordResolverTask.execute()");
134 if (DEBUG_FLAG) System.out.println(" Account : " + this.account);
135 if (DEBUG_FLAG) System.out.println(" Password : " + this.password);
136
137
138 this.configure() ;
139
140
141 try {
142
143
144 CommunityPasswordResolver resolver ;
145
146
147 if (null != this.getRegistry())
148 {
149 resolver = new CommunityPasswordResolver(
150 new URL(
151 this.getRegistry()
152 )
153 ) ;
154 }
155
156
157 else {
158 resolver = new CommunityPasswordResolver() ;
159 }
160
161
162 this.setToken(
163 resolver.checkPassword(
164 this.account,
165 this.password
166 )
167 ) ;
168 }
169 catch (Exception ouch)
170 {
171 throw new BuildException(ouch) ;
172 }
173 if (DEBUG_FLAG) System.out.println("----");
174 if (DEBUG_FLAG) System.out.println("Token : " + this.getToken());
175 if (DEBUG_FLAG) System.out.println("----");
176 }
177 }
178