You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@locus.apache.org on 2000/05/31 20:33:36 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/realm RealmBase.java
remm 00/05/31 11:33:33
Modified: proposals/catalina/src/share/org/apache/tomcat/realm
RealmBase.java
Log:
Added a default implementation for the authenticate(username,
credentials) method.
Revision Changes Path
1.2 +36 -4 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/realm/RealmBase.java
Index: RealmBase.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/realm/RealmBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RealmBase.java 2000/05/31 01:33:31 1.1
+++ RealmBase.java 2000/05/31 18:33:29 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/realm/RealmBase.java,v 1.1 2000/05/31 01:33:31 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2000/05/31 01:33:31 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/realm/RealmBase.java,v 1.2 2000/05/31 18:33:29 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/05/31 18:33:29 $
*
* ====================================================================
*
@@ -96,7 +96,7 @@
* location) are identical to those currently supported by Tomcat 3.X.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2000/05/31 01:33:31 $
+ * @version $Revision: 1.2 $ $Date: 2000/05/31 18:33:29 $
*/
public abstract class RealmBase
@@ -246,6 +246,27 @@
* @param credentials Password or other credentials to use in
* authenticating this username
*/
+ public Principal authenticate(String username, String credentials) {
+
+ String serverCredentials = getPassword(username);
+
+ if ( (serverCredentials == null)
+ || (!serverCredentials.equals(credentials)) )
+ return null;
+
+ return getPrincipal(username);
+
+ }
+
+
+ /**
+ * Return the Principal associated with the specified username and
+ * credentials, if there is one; otherwise return <code>null</code>.
+ *
+ * @param username Username of the Principal to look up
+ * @param credentials Password or other credentials to use in
+ * authenticating this username
+ */
public Principal authenticate(String username, byte[] credentials) {
return (authenticate(username, credentials.toString()));
@@ -301,6 +322,17 @@
return null;
}
+
+
+ /**
+ * Return <code>true</code> if the specified Principal has the specified
+ * security role, within the context of this Realm; otherwise return
+ * <code>false</code>.
+ *
+ * @param principal Principal for whom the role is to be checked
+ * @param role Security role to be checked
+ */
+ public abstract boolean hasRole(Principal principal, String role);
/**