summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/usrgrp/User.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/usrgrp/User.java')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/usrgrp/User.java216
1 files changed, 216 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/usrgrp/User.java b/pki/base/common/src/com/netscape/cmscore/usrgrp/User.java
new file mode 100644
index 000000000..5ecb4f169
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/usrgrp/User.java
@@ -0,0 +1,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$, $Date$
+ */
+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();
+ }
+}