tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r945841 - /tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java
Date Tue, 18 May 2010 19:42:07 GMT
Author: markt
Date: Tue May 18 19:42:06 2010
New Revision: 945841

URL: http://svn.apache.org/viewvc?rev=945841&view=rev
Log:
Make list of user roles immutable
Modify a copy in getRoles()

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=945841&r1=945840&r2=945841&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java Tue May 18 19:42:06 2010
@@ -24,6 +24,7 @@ import java.security.Principal;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -1618,9 +1619,10 @@ public class JNDIRealm extends RealmBase
             containerLog.trace("  getRoles(" + dn + ")");
 
         // Start with roles retrieved from the user entry
-        List<String> list = user.getRoles();
-        if (list == null) {
-            list = new ArrayList<String>();
+        List<String> list = new ArrayList<String>(); 
+        List<String> userRoles = user.getRoles();
+        if (userRoles != null) {
+            list.addAll(userRoles); 
         }
         if (commonRole != null)
             list.add(commonRole);
@@ -2228,15 +2230,17 @@ public class JNDIRealm extends RealmBase
          final private String username;
          final private String dn;
          final private String password;
-         final private List<String> roles = new ArrayList<String>();
+         final private List<String> roles;
 
          public User(String username, String dn, String password,
                  List<String> roles) {
              this.username = username;
              this.dn = dn;
              this.password = password;
-             if (roles != null) {
-                 this.roles.addAll(roles);
+             if (roles == null) {
+                 this.roles = Collections.emptyList();
+             } else {
+                 this.roles = Collections.unmodifiableList(roles);
              }
          }
     



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


Mime
View raw message