1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.vc;
20
21
22
23 /***
24 * @author D.A. Smedes
25 * @version $Id: Authenticator.java,v 1.9 2004/11/02 22:26:44 asmedes Exp $
26 */
27 public final class Authenticator {
28
29 private String workingContext = null;
30 private String id = null;
31 private String username = null;
32 private String password = null;
33
34 public Authenticator(String id) {
35 setId(id);
36 }
37
38 /***
39 * Empty constructor (generally only used by Digesters).
40 */
41 public Authenticator() {
42
43 }
44
45 public String getWorkingContext() {
46 return workingContext;
47 }
48
49 public void setWorkingContext(String workingContext) {
50
51 if ("".equals(workingContext) || workingContext == null) {
52 throw new IllegalArgumentException(
53 "The `working-context`-attribute for an authenticator cannot be null or an empty string.");
54 }
55 this.workingContext = workingContext;
56 }
57
58 public String getId() {
59
60 return id;
61 }
62
63 public void setId(String id) {
64
65 if ("".equals(id) || id == null) {
66 throw new IllegalArgumentException(
67 "The `id`-attribute for an authenticator cannot be null or an empty string.");
68 }
69 this.id = id;
70 }
71
72 public String getUsername() {
73 return username;
74 }
75
76 public void setUsername(String username) {
77 this.username = username;
78 }
79
80 /***
81 * Returns the password (encrypted) or an empty String if the password is null.
82 *
83 * @return
84 */
85 public String getPassword() {
86 return (password == null ? "" : password);
87 }
88
89 public void setPassword(String password) {
90 this.password = password;
91 }
92
93 public AuthenticatorKey getAuthenticatorKey() {
94 return new AuthenticatorKey(workingContext, id);
95 }
96 }