refactored to use values from the Constants class
authormaxcooper <maxcooper>
Mon, 9 Jun 2003 11:26:43 +0000 (11:26 +0000)
committermaxcooper <maxcooper>
Mon, 9 Jun 2003 11:26:43 +0000 (11:26 +0000)
src/example/org/securityfilter/example/realm/catalina/TrivialCatalinaRealm.java

index 9879e30..49ec44a 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $Header: /cvsroot/securityfilter/securityfilter/src/example/org/securityfilter/example/realm/catalina/TrivialCatalinaRealm.java,v 1.1 2003/06/09 11:14:18 maxcooper Exp $
- * $Revision: 1.1 $
- * $Date: 2003/06/09 11:14:18 $
+ * $Header: /cvsroot/securityfilter/securityfilter/src/example/org/securityfilter/example/realm/catalina/TrivialCatalinaRealm.java,v 1.2 2003/06/09 11:26:43 maxcooper Exp $
+ * $Revision: 1.2 $
+ * $Date: 2003/06/09 11:26:43 $
  *
  * ====================================================================
  * The SecurityFilter Software License, Version 1.1
@@ -57,6 +57,7 @@ package org.securityfilter.example.realm.catalina;
 
 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.realm.RealmBase;
+import org.securityfilter.example.Constants;
 
 import java.security.Principal;
 import java.util.ArrayList;
@@ -66,12 +67,9 @@ import java.util.ArrayList;
  * org.securityfilter.realm.catalina.CatalinaRealmAdapter adapter class.
  *
  * @author Max Cooper (max@maxcooper.com)
- * @version $Revision: 1.1 $ $Date: 2003/06/09 11:14:18 $
+ * @version $Revision: 1.2 $ $Date: 2003/06/09 11:26:43 $
  */
 public class TrivialCatalinaRealm extends RealmBase {
-   private static final String THE_USERNAME = "username";
-   private static final String THE_PASSWORD = "password";
-   private static final String THE_ROLE = "inthisrole";
 
    private String exampleProperty;
 
@@ -86,17 +84,17 @@ public class TrivialCatalinaRealm extends RealmBase {
     * Return the password associated with the given principal's user name.
     */
    protected String getPassword(String s) {
-      return (THE_USERNAME.equals(s) ? THE_PASSWORD : null);
+      return (Constants.VALID_USERNAME.equals(s) ? Constants.VALID_PASSWORD : null);
    }
 
    /**
     * Return the Principal associated with the given user name.
     */
    protected Principal getPrincipal(String s) {
-      if (THE_USERNAME.equals(s)) {
+      if (Constants.VALID_USERNAME.equals(s)) {
          ArrayList roleList = new ArrayList();
-         roleList.add(THE_ROLE);
-         return new GenericPrincipal(this, THE_USERNAME, THE_PASSWORD, roleList);
+         roleList.add(Constants.VALID_ROLE);
+         return new GenericPrincipal(this, Constants.VALID_USERNAME, Constants.VALID_PASSWORD, roleList);
       } else {
          return null;
       }