1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.usrgrp;
import java.util.*;
import java.security.*;
import java.security.cert.*;
import netscape.security.x509.*;
import com.netscape.certsrv.base.*;
import com.netscape.certsrv.common.*;
import com.netscape.certsrv.usrgrp.*;
import com.netscape.certsrv.apps.*;
/**
* A class represents a user.
*
* @author cfu
* @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
*/
public class User implements IUser {
public static final String ATTR_X509_CERTIFICATES = "userCertificates";
private IUsrGrp mBase = null;
private String mUserid = null;
private String mUserDN = null;
private String mFullName = null;
private String mPassword = null;
private String mEmail = null;
private String mPhone = null;
private String mState = null;
private String mCertDN = null;
private String mUserType = null;
private X509Certificate mx509Certs[] = null;
private static final Vector mNames = new Vector();
static {
mNames.addElement(ATTR_NAME);
mNames.addElement(ATTR_ID);
mNames.addElement(ATTR_FULLNAME);
mNames.addElement(ATTR_PASSWORD);
mNames.addElement(ATTR_STATE);
mNames.addElement(ATTR_EMAIL);
// mNames.addElement(ATTR_PHONENUMBER);
mNames.addElement(ATTR_X509_CERTIFICATES);
mNames.addElement(ATTR_USERTYPE);
}
/**
* Constructs a user.
*/
public User(IUsrGrp base, String userid) {
mBase = base;
mUserid = userid;
}
/**
* Retrieves the name of this identity.
*/
public String getName() {
// return mScope.getId() + "://" + mUserid;
return mUserid;
}
/**
* Retrieves user identifier.
*/
public String getUserID() {
return mUserid;
}
/**
* Retrieves user full name.
*/
public String getFullName() {
return mFullName;
}
public void setFullName(String name) {
mFullName = name;
}
/**
* Retrieves user ldap dn
*/
public String getUserDN() {
return mUserDN;
}
public void setUserDN(String userdn) {
mUserDN = userdn;
}
public String getUserType() {
return mUserType;
}
public void setUserType(String userType) {
mUserType = userType;
}
/**
* Retrieves user password.
*/
public String getPassword() {
return mPassword;
}
public void setPassword(String password) {
mPassword = password;
}
public String getEmail() {
return mEmail;
}
public void setEmail(String email) {
mEmail = email;
}
public String getPhone() {
return mPhone;
}
public String getState() {
return mState;
}
public void setPhone(String phone) {
mPhone = phone;
}
public void setState(String state) {
mState = state;
}
public X509Certificate[] getX509Certificates() {
return mx509Certs;
}
public void setX509Certificates(X509Certificate certs[]) {
mx509Certs = certs;
}
public String getCertDN() {
return mCertDN;
}
public void setCertDN(String dn) {
mCertDN = dn;
}
public void set(String name, Object object) throws EBaseException {
if (name.equals(ATTR_NAME)) {
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", name));
} else if (name.equals(ATTR_ID)) {
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", name));
} else if (name.equals(ATTR_FULLNAME)) {
setFullName((String) object);
} else if (name.equals(ATTR_STATE)) {
setState((String) object);
} else if (name.equals(ATTR_PASSWORD)) {
setPassword((String) object);
} else if (name.equals(ATTR_X509_CERTIFICATES)) {
setX509Certificates((X509Certificate[]) object);
} else if (name.equals(ATTR_USERTYPE)) {
setUserType((String) object);
} else {
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", name));
}
}
public Object get(String name) throws EBaseException {
if (name.equals(ATTR_NAME)) {
return getName();
} else if (name.equals(ATTR_ID)) {
return getUserID();
} else if (name.equals(ATTR_STATE)) {
return getState();
} else if (name.equals(ATTR_FULLNAME)) {
return getFullName();
} else if (name.equals(ATTR_PASSWORD)) {
return getPassword();
} else if (name.equals(ATTR_X509_CERTIFICATES)) {
return getX509Certificates();
} else if (name.equals(ATTR_USERTYPE)) {
return getUserType();
} else {
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", name));
}
}
public void delete(String name) throws EBaseException {
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", name));
}
public Enumeration getElements() {
return mNames.elements();
}
}
|