On 16/02/2010, ma...@apache.org <ma...@apache.org> wrote:
> Author: markt
>  Date: Tue Feb 16 11:40:55 2010
>  New Revision: 910485
>
>  URL: http://svn.apache.org/viewvc?rev=910485&view=rev
>  Log:
>  Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48589
>  Make JNDIRealm easier to extend by making the User class protected
>  Based on a patch by Candid Dauth
>
>  Modified:
>     tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java
>
>  Modified: tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java
>  URL: 
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java?rev=910485&r1=910484&r2=910485&view=diff
>  
> ==============================================================================
>  --- tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java (original)
>  +++ tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java Tue Feb 16 
> 11:40:55 2010
>  @@ -24,6 +24,7 @@
>   import java.text.MessageFormat;
>   import java.util.ArrayList;
>   import java.util.Arrays;
>  +import java.util.Collections;
>   import java.util.HashMap;
>   import java.util.HashSet;
>   import java.util.Hashtable;
>  @@ -2214,26 +2215,41 @@
>      }
>
>
>  +     // ------------------------------------------------------ Private 
> Classes
>  +
>  +     /**
>  +      * A private class representing a User

s/private/protected/ ?

>  +      */
>  +     protected static class User {
>  +
>  +         private String username = null;
>  +         private String dn = null;
>  +         private String password = null;
>  +         private ArrayList<String> roles = null;

These could/should be final, as they don't appear to be updated once
constructed.

>  +         User(String username, String dn, String password,
>  +                 ArrayList<String> roles) {
>  +             this.username = username;
>  +             this.dn = dn;
>  +             this.password = password;
>  +             this.roles = roles;

The ArrayList should be copied for safety, otherwise the list can be
externally mutated.
In any case one can create it as unmodifiable.

>  +         }
>  +
>  +         public String getUserName() {
>  +             return username;
>  +         }
>  +
>  +         public String getDN() {
>  +             return dn;
>  +         }
>  +
>  +         public String getPassword() {
>  +             return password;
>  +         }
>  +
>  +         public List<String> getRoles() {
>  +             return Collections.unmodifiableList(roles);
>  +         }
>  +     }
>   }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to