summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2013-08-01 10:53:22 -0400
committerEndi S. Dewata <edewata@redhat.com>2013-10-25 15:04:37 -0400
commit6dc062e5804023a0f08e23f9dc2d0a1c7a986006 (patch)
tree54e80d3b6ef3185857636684b461761e1623ddc9 /base
parentdcc0f115091c4276870c93097c40b0b00d045bdf (diff)
downloadpki-6dc062e5804023a0f08e23f9dc2d0a1c7a986006.tar.gz
pki-6dc062e5804023a0f08e23f9dc2d0a1c7a986006.tar.xz
pki-6dc062e5804023a0f08e23f9dc2d0a1c7a986006.zip
Refactored authentication managers.
The CertUserDBAuthentication and PasswdUserDBAuthentication are authentication managers in cmscore package but they are needed by PKIRealm that is now in cms package, so new interfaces have been refactored from these classes so they can be used without causing dependency issue.
Diffstat (limited to 'base')
-rw-r--r--base/common/src/com/netscape/certsrv/authentication/ICertUserDBAuthentication.java36
-rw-r--r--base/common/src/com/netscape/certsrv/authentication/IPasswdUserDBAuthentication.java33
-rw-r--r--base/common/src/com/netscape/cms/realm/PKIRealm.java12
-rw-r--r--base/common/src/com/netscape/cmscore/authentication/CertUserDBAuthentication.java10
-rw-r--r--base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java9
5 files changed, 79 insertions, 21 deletions
diff --git a/base/common/src/com/netscape/certsrv/authentication/ICertUserDBAuthentication.java b/base/common/src/com/netscape/certsrv/authentication/ICertUserDBAuthentication.java
new file mode 100644
index 000000000..5b905061c
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/authentication/ICertUserDBAuthentication.java
@@ -0,0 +1,36 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.authentication;
+
+
+/**
+ * @author lhsiao
+ * @author cfu
+ * @version $Revision$, $Date$
+ */
+public interface ICertUserDBAuthentication {
+
+ /* result auth token attributes */
+ public static final String TOKEN_USERDN = "user";
+ public static final String TOKEN_USER_DN = "userdn";
+ public static final String TOKEN_USERID = "userid";
+ public static final String TOKEN_UID = "uid";
+
+ /* required credentials */
+ public static final String CRED_CERT = IAuthManager.CRED_SSL_CLIENT_CERT;
+} \ No newline at end of file
diff --git a/base/common/src/com/netscape/certsrv/authentication/IPasswdUserDBAuthentication.java b/base/common/src/com/netscape/certsrv/authentication/IPasswdUserDBAuthentication.java
new file mode 100644
index 000000000..2921b6778
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/authentication/IPasswdUserDBAuthentication.java
@@ -0,0 +1,33 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.authentication;
+
+/**
+ * @author lhsiao, cfu
+ * @version $Revision$, $Date$
+ */
+public interface IPasswdUserDBAuthentication {
+
+ /* required credentials. uid, pwd are strings */
+ public static final String CRED_UID = "uid";
+ public static final String CRED_PWD = "pwd";
+
+ /* attribute in returned token */
+ public static final String TOKEN_USERDN = "userdn";
+ public static final String TOKEN_USERID = "userid";
+} \ No newline at end of file
diff --git a/base/common/src/com/netscape/cms/realm/PKIRealm.java b/base/common/src/com/netscape/cms/realm/PKIRealm.java
index f15234527..d6ac100f5 100644
--- a/base/common/src/com/netscape/cms/realm/PKIRealm.java
+++ b/base/common/src/com/netscape/cms/realm/PKIRealm.java
@@ -14,13 +14,13 @@ import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authentication.IAuthManager;
import com.netscape.certsrv.authentication.IAuthSubsystem;
import com.netscape.certsrv.authentication.IAuthToken;
+import com.netscape.certsrv.authentication.ICertUserDBAuthentication;
+import com.netscape.certsrv.authentication.IPasswdUserDBAuthentication;
import com.netscape.certsrv.usrgrp.EUsrGrpException;
import com.netscape.certsrv.usrgrp.IGroup;
import com.netscape.certsrv.usrgrp.IUGSubsystem;
import com.netscape.certsrv.usrgrp.IUser;
import com.netscape.cms.servlet.common.AuthCredentials;
-import com.netscape.cmscore.authentication.CertUserDBAuthentication;
-import com.netscape.cmscore.authentication.PasswdUserDBAuthentication;
import com.netscape.cmscore.realm.PKIPrincipal;
/**
@@ -47,8 +47,8 @@ public class PKIRealm extends RealmBase {
IAuthManager authMgr = authSub.getAuthManager(IAuthSubsystem.PASSWDUSERDB_AUTHMGR_ID);
AuthCredentials creds = new AuthCredentials();
- creds.set(PasswdUserDBAuthentication.CRED_UID, username);
- creds.set(PasswdUserDBAuthentication.CRED_PWD, password);
+ creds.set(IPasswdUserDBAuthentication.CRED_UID, username);
+ creds.set(IPasswdUserDBAuthentication.CRED_PWD, password);
IAuthToken authToken = authMgr.authenticate(creds); // throws exception if authentication fails
@@ -79,11 +79,11 @@ public class PKIRealm extends RealmBase {
IAuthManager authMgr = authSub.getAuthManager(IAuthSubsystem.CERTUSERDB_AUTHMGR_ID);
AuthCredentials creds = new AuthCredentials();
- creds.set(CertUserDBAuthentication.CRED_CERT, certImpls);
+ creds.set(ICertUserDBAuthentication.CRED_CERT, certImpls);
IAuthToken authToken = authMgr.authenticate(creds); // throws exception if authentication fails
- String username = authToken.getInString(CertUserDBAuthentication.TOKEN_USERID);
+ String username = authToken.getInString(ICertUserDBAuthentication.TOKEN_USERID);
logDebug("User ID: "+username);
return getPrincipal(username, authToken);
diff --git a/base/common/src/com/netscape/cmscore/authentication/CertUserDBAuthentication.java b/base/common/src/com/netscape/cmscore/authentication/CertUserDBAuthentication.java
index fab9c1812..573b736d4 100644
--- a/base/common/src/com/netscape/cmscore/authentication/CertUserDBAuthentication.java
+++ b/base/common/src/com/netscape/cmscore/authentication/CertUserDBAuthentication.java
@@ -28,6 +28,7 @@ import com.netscape.certsrv.authentication.EMissingCredential;
import com.netscape.certsrv.authentication.IAuthCredentials;
import com.netscape.certsrv.authentication.IAuthManager;
import com.netscape.certsrv.authentication.IAuthToken;
+import com.netscape.certsrv.authentication.ICertUserDBAuthentication;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.IConfigStore;
import com.netscape.certsrv.logging.ILogger;
@@ -47,16 +48,9 @@ import com.netscape.cmscore.usrgrp.User;
* @author cfu
* @version $Revision$, $Date$
*/
-public class CertUserDBAuthentication implements IAuthManager {
-
- /* result auth token attributes */
- public static final String TOKEN_USERDN = "user";
- public static final String TOKEN_USER_DN = "userdn";
- public static final String TOKEN_USERID = "userid";
- public static final String TOKEN_UID = "uid";
+public class CertUserDBAuthentication implements IAuthManager, ICertUserDBAuthentication {
/* required credentials */
- public static final String CRED_CERT = IAuthManager.CRED_SSL_CLIENT_CERT;
protected String[] mRequiredCreds = { CRED_CERT };
/* config parameters to pass to console (none) */
diff --git a/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java b/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
index 449a196d4..2905f3c75 100644
--- a/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
+++ b/base/common/src/com/netscape/cmscore/authentication/PasswdUserDBAuthentication.java
@@ -30,6 +30,7 @@ import com.netscape.certsrv.authentication.EMissingCredential;
import com.netscape.certsrv.authentication.IAuthCredentials;
import com.netscape.certsrv.authentication.IAuthManager;
import com.netscape.certsrv.authentication.IAuthToken;
+import com.netscape.certsrv.authentication.IPasswdUserDBAuthentication;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.IConfigStore;
import com.netscape.certsrv.ldap.ELdapException;
@@ -52,17 +53,11 @@ import com.netscape.cmscore.util.Debug;
* @author lhsiao, cfu
* @version $Revision$, $Date$
*/
-public class PasswdUserDBAuthentication implements IAuthManager {
+public class PasswdUserDBAuthentication implements IAuthManager, IPasswdUserDBAuthentication {
/* required credentials. uid, pwd are strings */
- public static final String CRED_UID = "uid";
- public static final String CRED_PWD = "pwd";
protected static String[] mRequiredCred = { CRED_UID, CRED_PWD };
- /* attribute in returned token */
- public static final String TOKEN_USERDN = "userdn";
- public static final String TOKEN_USERID = "userid";
-
/* configuration params to pass to console (none) */
protected static String[] mConfigParams = null;