1 package jsdsi.ldap;
2
3 /***
4 * LDAP server parameters. Server name(default: "localhost"),
5 * server port(default: 389), login(default: "anonymous"),
6 * password(default: null), base dn
7 *
8 *
9 * @author Lu�s Pedro
10 * @version $Revision: 1.5 $ $Date: 2004/03/27 19:15:39 $
11 *
12 **/
13
14 public class LDAPParameters {
15
16 /***
17 * Default ldap port 389
18 */
19 private static final int LDAP_DEFAULT_PORT = 389;
20
21 /***
22 * LDAPport parameter
23 */
24 private int LDAPport;
25
26 /***
27 * LDAPserver parameter
28 */
29 private String LDAPserver;
30
31 /***
32 * LDAPlogin parameter
33 */
34 private String LDAPlogin;
35
36 /***
37 * LDAPbaseDN parameter
38 */
39 private String LDAPbaseDN;
40
41 /***
42 * LDAPpassword parameter
43 */
44 private String LDAPpassword;
45
46 /***
47 * Creates a new LDAPParameters instance with specified
48 * LDAPserver, LDAPport, LDAPbaseDN, LDAPlogin andLDAPpassword
49 *
50 * @param LDAPserver ldap server name
51 * @param LDAPport ldap server port
52 * @param LDAPbaseDN ldap server distinguish base name
53 * @param LDAPlogin user name
54 * @param LDAPpassword user password
55 */
56 public LDAPParameters(String LDAPserver,
57 int LDAPport,
58 String LDAPbaseDN,
59 String LDAPlogin, String LDAPpassword) {
60 assert(LDAPserver != null) : "A LDAP server is required";
61 assert(LDAPbaseDN != null) : "A LDAP base DN is required";
62
63 this.LDAPserver = LDAPserver;
64 this.LDAPport = LDAPport;
65 this.LDAPbaseDN = LDAPbaseDN;
66 this.LDAPlogin = LDAPlogin;
67 this.LDAPpassword = LDAPpassword;
68 }
69
70 /***
71 * Creates a new instance of LDAPParameters instance with specified
72 * LDAPserver, LDAPport and LDAPbaseDN
73 *
74 * @param LDAPserver ldap server name
75 * @param LDAPport ldap server port
76 * @param LDAPbaseDN ldap server distinguish base name
77 */
78 public LDAPParameters(String LDAPserver, int LDAPport, String LDAPbaseDN) {
79 this(LDAPserver, LDAPport, LDAPbaseDN, new String(), new String());
80 }
81
82 /***
83 * Creates a new instance of LDAPParameters instance with specified
84 * LDAPserver and LDAPbaseDN
85 *
86 * @param LDAPserver ldap server name
87 * @param LDAPbaseDN ldap server distinguish base name
88 */
89 public LDAPParameters(String LDAPserver, String LDAPbaseDN) {
90 this(LDAPserver,
91 LDAP_DEFAULT_PORT, LDAPbaseDN, new String(), new String());
92 }
93
94 /***
95 * Creates a new instance of LDAPParameters with specified
96 * LDAPbaseDN
97 *
98 * @param LDAPbaseDN ldap server distinguish base name
99 */
100 public LDAPParameters(String LDAPbaseDN) {
101 this("localhost",
102 LDAP_DEFAULT_PORT, LDAPbaseDN, new String(), new String());
103 }
104
105 /***
106 * Creates a new instance of LDAPParameters with specified
107 * LDAPserver, LDAPserverDN, LDAPlogin and LDAPpassword
108 *
109 * @param LDAPserver ldap server name
110 * @param LDAPbaseDN ldap server distinguish base name
111 * @param LDAPlogin user name
112 * @param LDAPpassword user password
113 */
114 public LDAPParameters(String LDAPserver,
115 String LDAPbaseDN,
116 String LDAPlogin, String LDAPpassword) {
117 this(LDAPserver,
118 LDAP_DEFAULT_PORT, LDAPbaseDN, LDAPlogin, LDAPpassword);
119 }
120
121 /***
122 * Creates a new instance of LDAPParameters with specified
123 * LDAPbaseDN, LDAPlogin and LDAPpassword
124 *
125 * @param LDAPbaseDN ldap server distinguish base name
126 * @param LDAPlogin user name
127 * @param LDAPpassword user password
128 */
129 public LDAPParameters(String LDAPbaseDN,
130 String LDAPlogin, String LDAPpassword) {
131 this("localhost",
132 LDAP_DEFAULT_PORT, LDAPbaseDN, LDAPlogin, LDAPpassword);
133 }
134
135 /***
136 * Ldap server name
137 *
138 * @return server name
139 */
140 public String getLDAPserver() {
141 return LDAPserver;
142 }
143
144 /***
145 * Ldap server port
146 *
147 * @return server port
148 */
149 public int getLDAPport() {
150 return LDAPport;
151 }
152
153 /***
154 * Ldap user name
155 *
156 * @return user name
157 */
158 public String getLDAPlogin() {
159 return LDAPlogin;
160 }
161
162 /***
163 * Ldap user password
164 *
165 * @return user password
166 */
167 public String getLDAPpassword() {
168 return LDAPpassword;
169 }
170
171 /***
172 * Ldap base dn
173 *
174 * @return ldap distinguish base name
175 */
176 public String getLDAPbaseDN() {
177 return LDAPbaseDN;
178 }
179
180 /***
181 * Copy of LDAPParameters
182 *
183 * @return LDAPParameters
184 */
185 public Object clone() {
186 try {
187 return super.clone();
188 } catch(CloneNotSupportedException e) {
189 /* If this happens something is very wrong */
190 throw new InternalError(e.toString());
191 }
192 }
193
194 /***
195 * String representation of LDAPParameters
196 *
197 * @return String representation of ldap parameters
198 */
199 public String toString() {
200 StringBuffer sb = new StringBuffer();
201 sb.append("LDAPParameters: [\n");
202 sb.append(" serverName: " + LDAPserver + "\n");
203 sb.append(" port: " + LDAPport + "\n");
204 sb.append(" login: " + LDAPlogin + "\n");
205 sb.append(" password: " + LDAPpassword + "\n");
206 sb.append(" baseDN: " + LDAPbaseDN + "\n");
207 sb.append("]");
208 return sb.toString();
209 }
210 }
This page was automatically generated by Maven