craigmcc 01/10/27 13:29:03
Modified: catalina/src/share/org/apache/catalina/realm
GenericPrincipal.java
Log:
Make it possible to create and use GenericPrincipal objects from pacakges
other than org.apache.catalina.realm.
Submitted by: Jeff Drost <[EMAIL PROTECTED]>
Revision Changes Path
1.4 +26 -30
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/GenericPrincipal.java
Index: GenericPrincipal.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/GenericPrincipal.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GenericPrincipal.java 2001/07/22 20:25:11 1.3
+++ GenericPrincipal.java 2001/10/27 20:29:03 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/GenericPrincipal.java,v
1.3 2001/07/22 20:25:11 pier Exp $
- * $Revision: 1.3 $
- * $Date: 2001/07/22 20:25:11 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/GenericPrincipal.java,v
1.4 2001/10/27 20:29:03 craigmcc Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/10/27 20:29:03 $
*
* ====================================================================
*
@@ -73,15 +73,13 @@
/**
* Generic implementation of <strong>java.security.Principal</strong> that
- * is available for use by <code>Realm</code> implementations. The class
- * and all of its methods (except for <code>getName()</code>) are package
- * private to avoid interference from applications.
+ * is available for use by <code>Realm</code> implementations.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2001/07/22 20:25:11 $
+ * @version $Revision: 1.4 $ $Date: 2001/10/27 20:29:03 $
*/
-class GenericPrincipal implements Principal {
+public class GenericPrincipal implements Principal {
// ----------------------------------------------------------- Constructors
@@ -95,7 +93,7 @@
* @param name The username of the user represented by this Principal
* @param password Credentials used to authenticate this user
*/
- GenericPrincipal(Realm realm, String name, String password) {
+ public GenericPrincipal(Realm realm, String name, String password) {
this(realm, name, password, null);
@@ -112,7 +110,8 @@
* @param password Credentials used to authenticate this user
* @param roles List of roles (must be Strings) possessed by this user
*/
- GenericPrincipal(Realm realm, String name, String password, List roles) {
+ public GenericPrincipal(Realm realm, String name, String password,
+ List roles) {
super();
this.realm = realm;
@@ -147,7 +146,7 @@
*/
protected String password = null;
- String getPassword() {
+ public String getPassword() {
return (this.password);
}
@@ -157,7 +156,7 @@
*/
protected Realm realm = null;
- Realm getRealm() {
+ public Realm getRealm() {
return (this.realm);
}
@@ -167,7 +166,7 @@
*/
protected String roles[] = new String[0];
- String[] getRoles() {
+ public String[] getRoles() {
return (this.roles);
}
@@ -176,32 +175,29 @@
/**
- * Return a String representation of this object, which exposes only
- * information that should be public.
+ * Does the user represented by this Principal possess the specified role?
+ *
+ * @param role Role to be tested
*/
- public String toString() {
+ public boolean hasRole(String role) {
- StringBuffer sb = new StringBuffer("GenericPrincipal[");
- sb.append(this.name);
- sb.append("]");
- return (sb.toString());
+ if (role == null)
+ return (false);
+ return (Arrays.binarySearch(roles, role) >= 0);
}
- // -------------------------------------------------------- Package Methods
-
-
/**
- * Does the user represented by this Principal possess the specified role?
- *
- * @param role Role to be tested
+ * Return a String representation of this object, which exposes only
+ * information that should be public.
*/
- boolean hasRole(String role) {
+ public String toString() {
- if (role == null)
- return (false);
- return (Arrays.binarySearch(roles, role) >= 0);
+ StringBuffer sb = new StringBuffer("GenericPrincipal[");
+ sb.append(this.name);
+ sb.append("]");
+ return (sb.toString());
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>