1
2
3
4
5
6
7
8 package org.astrogrid.community.beans.v1;
9
10
11
12
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import org.exolab.castor.xml.MarshalException;
19 import org.exolab.castor.xml.Marshaller;
20 import org.exolab.castor.xml.Unmarshaller;
21 import org.exolab.castor.xml.ValidationException;
22 import org.xml.sax.ContentHandler;
23
24 /***
25 * The full authorization and authentication credentials.
26 *
27 * @version $Revision: 1.37 $ $Date: 2007/01/04 16:26:32 $
28 */
29 public class Credentials extends org.astrogrid.common.bean.BaseBean
30 implements java.io.Serializable
31 {
32
33
34
35
36
37
38 /***
39 * The user account.
40 */
41 private org.astrogrid.community.beans.v1.Account _account;
42
43 /***
44 * A security group used in authorization.
45 */
46 private org.astrogrid.community.beans.v1.Group _group;
47
48 /***
49 * The security token used in authentication.
50 */
51 private java.lang.String _securityToken;
52
53
54
55
56
57
58 public Credentials() {
59 super();
60 }
61
62
63
64
65
66
67 /***
68 * Note: hashCode() has not been overriden
69 *
70 * @param obj
71 */
72 public boolean equals(java.lang.Object obj)
73 {
74 if ( this == obj )
75 return true;
76
77 if (super.equals(obj)==false)
78 return false;
79
80 if (obj instanceof Credentials) {
81
82 Credentials temp = (Credentials)obj;
83 if (this._account != null) {
84 if (temp._account == null) return false;
85 else if (!(this._account.equals(temp._account)))
86 return false;
87 }
88 else if (temp._account != null)
89 return false;
90 if (this._group != null) {
91 if (temp._group == null) return false;
92 else if (!(this._group.equals(temp._group)))
93 return false;
94 }
95 else if (temp._group != null)
96 return false;
97 if (this._securityToken != null) {
98 if (temp._securityToken == null) return false;
99 else if (!(this._securityToken.equals(temp._securityToken)))
100 return false;
101 }
102 else if (temp._securityToken != null)
103 return false;
104 return true;
105 }
106 return false;
107 }
108
109 /***
110 * Returns the value of field 'account'. The field 'account'
111 * has the following description: The user account.
112 *
113 * @return the value of field 'account'.
114 */
115 public org.astrogrid.community.beans.v1.Account getAccount()
116 {
117 return this._account;
118 }
119
120 /***
121 * Returns the value of field 'group'. The field 'group' has
122 * the following description: A security group used in
123 * authorization.
124 *
125 * @return the value of field 'group'.
126 */
127 public org.astrogrid.community.beans.v1.Group getGroup()
128 {
129 return this._group;
130 }
131
132 /***
133 * Returns the value of field 'securityToken'. The field
134 * 'securityToken' has the following description: The security
135 * token used in authentication.
136 *
137 * @return the value of field 'securityToken'.
138 */
139 public java.lang.String getSecurityToken()
140 {
141 return this._securityToken;
142 }
143
144 /***
145 * Method isValid
146 */
147 public boolean isValid()
148 {
149 try {
150 validate();
151 }
152 catch (org.exolab.castor.xml.ValidationException vex) {
153 return false;
154 }
155 return true;
156 }
157
158 /***
159 * Method marshal
160 *
161 * @param out
162 */
163 public void marshal(java.io.Writer out)
164 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
165 {
166
167 Marshaller.marshal(this, out);
168 }
169
170 /***
171 * Method marshal
172 *
173 * @param handler
174 */
175 public void marshal(org.xml.sax.ContentHandler handler)
176 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
177 {
178
179 Marshaller.marshal(this, handler);
180 }
181
182 /***
183 * Sets the value of field 'account'. The field 'account' has
184 * the following description: The user account.
185 *
186 * @param account the value of field 'account'.
187 */
188 public void setAccount(org.astrogrid.community.beans.v1.Account account)
189 {
190 this._account = account;
191 }
192
193 /***
194 * Sets the value of field 'group'. The field 'group' has the
195 * following description: A security group used in
196 * authorization.
197 *
198 * @param group the value of field 'group'.
199 */
200 public void setGroup(org.astrogrid.community.beans.v1.Group group)
201 {
202 this._group = group;
203 }
204
205 /***
206 * Sets the value of field 'securityToken'. The field
207 * 'securityToken' has the following description: The security
208 * token used in authentication.
209 *
210 * @param securityToken the value of field 'securityToken'.
211 */
212 public void setSecurityToken(java.lang.String securityToken)
213 {
214 this._securityToken = securityToken;
215 }
216
217 /***
218 * Method unmarshalCredentials
219 *
220 * @param reader
221 */
222 public static org.astrogrid.community.beans.v1.Credentials unmarshalCredentials(java.io.Reader reader)
223 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
224 {
225 return (org.astrogrid.community.beans.v1.Credentials) Unmarshaller.unmarshal(org.astrogrid.community.beans.v1.Credentials.class, reader);
226 }
227
228 /***
229 * Method validate
230 */
231 public void validate()
232 throws org.exolab.castor.xml.ValidationException
233 {
234 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
235 validator.validate(this);
236 }
237
238 }