Fix compiler warnings in o.a.c.realm
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 2 Jun 2007 01:37:08 +0000 (01:37 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 2 Jun 2007 01:37:08 +0000 (01:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@543691 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/realm/DataSourceRealm.java
java/org/apache/catalina/realm/GenericPrincipal.java
java/org/apache/catalina/realm/JAASCallbackHandler.java
java/org/apache/catalina/realm/JAASMemoryLoginModule.java
java/org/apache/catalina/realm/JAASRealm.java
java/org/apache/catalina/realm/JDBCRealm.java
java/org/apache/catalina/realm/JNDIRealm.java
java/org/apache/catalina/realm/MemoryRealm.java
java/org/apache/catalina/realm/UserDatabaseRealm.java

index b2f0c4a..5bc660b 100644 (file)
@@ -345,7 +345,7 @@ public class DataSourceRealm
             return (null);
         }
 
-        ArrayList list = getRoles(dbConnection, username);
+        ArrayList<String> list = getRoles(dbConnection, username);
 
         // Create and return a suitable Principal for this user
         return (new GenericPrincipal(this, username, credentials, list));
@@ -527,17 +527,17 @@ public class DataSourceRealm
      * @param dbConnection The database connection to be used
      * @param username Username for which roles should be retrieved
      */
-    protected ArrayList getRoles(Connection dbConnection,
+    protected ArrayList<String> getRoles(Connection dbConnection,
                                      String username) {
        
         ResultSet rs = null;
         PreparedStatement stmt = null;
-        ArrayList list = null;
+        ArrayList<String> list = null;
        
         try {
                stmt = roles(dbConnection, username);
                rs = stmt.executeQuery();
-               list = new ArrayList();
+               list = new ArrayList<String>();
                
                while (rs.next()) {
                        String role = rs.getString(1);
index f66c082..ea64e36 100644 (file)
@@ -65,7 +65,7 @@ public class GenericPrincipal implements Principal {
      * @param roles List of roles (must be Strings) possessed by this user
      */
     public GenericPrincipal(Realm realm, String name, String password,
-                            List roles) {
+                            List<String> roles) {
         this(realm, name, password, roles, null);
     }
 
@@ -82,7 +82,7 @@ public class GenericPrincipal implements Principal {
      *        getUserPrincipal call if not null; if null, this will be returned
      */
     public GenericPrincipal(Realm realm, String name, String password,
-                            List roles, Principal userPrincipal) {
+                            List<String> roles, Principal userPrincipal) {
 
         super();
         this.realm = realm;
index 0a7c434..6c494b1 100644 (file)
@@ -27,8 +27,6 @@ import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
 
 import org.apache.catalina.util.StringManager;
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
 
 /**
  * <p>Implementation of the JAAS <code>CallbackHandler</code> interface,
@@ -49,7 +47,6 @@ import org.apache.juli.logging.LogFactory;
  */
 
 public class JAASCallbackHandler implements CallbackHandler {
-    private static Log log = LogFactory.getLog(JAASCallbackHandler.class);
 
     // ------------------------------------------------------------ Constructor
 
index c4255f9..acab513 100644 (file)
@@ -212,7 +212,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule, R
      */
     public SecurityConstraint [] findSecurityConstraints(Request request,
                                                      Context context) {
-        ArrayList results = null;
+        ArrayList<SecurityConstraint> results = null;
         // Are there any defined security constraints?
         SecurityConstraint constraints[] = context.findConstraints();
         if ((constraints == null) || (constraints.length == 0)) {
@@ -235,7 +235,7 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule, R
                     constraints[i].included(uri, method));
             if (constraints[i].included(uri, method)) {
                 if(results == null) {
-                    results = new ArrayList();
+                    results = new ArrayList<SecurityConstraint>();
                 }
                 results.add(constraints[i]);
             }
index 95d67de..c1cd421 100644 (file)
@@ -457,7 +457,6 @@ public class JAASRealm
      */
     protected Principal createPrincipal(String username, Subject subject) {
         // Prepare to scan the Principals for this Subject
-        String password = null; // Will not be carried forward
 
         List<String> roles = new ArrayList<String>();
         Principal userPrincipal = null;
index e53bddc..1b7e1a2 100644 (file)
@@ -420,7 +420,7 @@ public class JDBCRealm
             return (null);
         }
 
-        ArrayList roles = getRoles(username);
+        ArrayList<String> roles = getRoles(username);
         
         // Create and return a suitable Principal for this user
         return (new GenericPrincipal(this, username, credentials, roles));
@@ -604,7 +604,7 @@ public class JDBCRealm
     /**
      * Return the roles associated with the gven user name.
      */
-    protected ArrayList getRoles(String username) {
+    protected ArrayList<String> getRoles(String username) {
         
         PreparedStatement stmt = null;
         ResultSet rs = null;
@@ -626,7 +626,7 @@ public class JDBCRealm
                 
                 try {
                     // Accumulate the user's roles
-                    ArrayList roleList = new ArrayList();
+                    ArrayList<String> roleList = new ArrayList<String>();
                     stmt = roles(dbConnection, username);
                     rs = stmt.executeQuery();
                     while (rs.next()) {
index 6b99df5..e9ec25b 100644 (file)
@@ -903,7 +903,7 @@ public class JNDIRealm extends RealmBase {
                         // Check the user's credentials
                         if (checkCredentials(context, user, credentials)) {
                             // Search for additional roles
-                            List roles = getRoles(context, user);
+                            List<String> roles = getRoles(context, user);
                             return (new GenericPrincipal(this,
                                                          username,
                                                          credentials,
@@ -931,7 +931,7 @@ public class JNDIRealm extends RealmBase {
                 return (null);
 
             // Search for additional roles
-            List roles = getRoles(context, user);
+            List<String> roles = getRoles(context, user);
 
             // Create and return a suitable Principal for this user
             return (new GenericPrincipal(this, username, credentials, roles));
@@ -961,7 +961,7 @@ public class JNDIRealm extends RealmBase {
         User user = null;
 
         // Get attributes to retrieve from user entry
-        ArrayList list = new ArrayList();
+        ArrayList<String> list = new ArrayList<String>();
         if (userPassword != null)
             list.add(userPassword);
         if (userRoleName != null)
@@ -1020,7 +1020,7 @@ public class JNDIRealm extends RealmBase {
             password = getAttributeValue(userPassword, attrs);
 
         // Retrieve values of userRoleName attribute
-        ArrayList roles = null;
+        ArrayList<String> roles = null;
         if (userRoleName != null)
             roles = addAttributeValues(userRoleName, attrs, roles);
 
@@ -1110,7 +1110,7 @@ public class JNDIRealm extends RealmBase {
             password = getAttributeValue(userPassword, attrs);
 
         // Retrieve values of userRoleName attribute
-        ArrayList roles = null;
+        ArrayList<String> roles = null;
         if (userRoleName != null)
             roles = addAttributeValues(userRoleName, attrs, roles);
 
@@ -1264,7 +1264,6 @@ public class JNDIRealm extends RealmBase {
                                   User user,
                                   String credentials)
          throws NamingException {
-         Attributes attr;
 
          if (credentials == null || user == null)
              return (false);
@@ -1288,7 +1287,7 @@ public class JNDIRealm extends RealmBase {
             if (containerLog.isTraceEnabled()) {
                 containerLog.trace("  binding as "  + dn);
             }
-            attr = context.getAttributes("", null);
+            context.getAttributes("", null);
             validated = true;
         }
         catch (AuthenticationException e) {
@@ -1328,7 +1327,7 @@ public class JNDIRealm extends RealmBase {
      *
      * @exception NamingException if a directory server error occurs
      */
-    protected List getRoles(DirContext context, User user)
+    protected List<String> getRoles(DirContext context, User user)
         throws NamingException {
 
         if (user == null)
@@ -1344,9 +1343,9 @@ public class JNDIRealm extends RealmBase {
             containerLog.trace("  getRoles(" + dn + ")");
 
         // Start with roles retrieved from the user entry
-        ArrayList list = user.roles;
+        ArrayList<String> list = user.roles;
         if (list == null) {
-            list = new ArrayList();
+            list = new ArrayList<String>();
         }
 
         // Are we configured to do role searches?
@@ -1433,9 +1432,9 @@ public class JNDIRealm extends RealmBase {
      *
      * @exception NamingException if a directory server error occurs
      */
-    private ArrayList addAttributeValues(String attrId,
+    private ArrayList<String> addAttributeValues(String attrId,
                                          Attributes attrs,
-                                         ArrayList values)
+                                         ArrayList<String> values)
         throws NamingException{
 
         if (containerLog.isTraceEnabled())
@@ -1443,7 +1442,7 @@ public class JNDIRealm extends RealmBase {
         if (attrId == null || attrs == null)
             return values;
         if (values == null)
-            values = new ArrayList();
+            values = new ArrayList<String>();
         Attribute attr = attrs.get(attrId);
         if (attr == null)
             return (values);
@@ -1620,7 +1619,7 @@ public class JNDIRealm extends RealmBase {
      */
     protected Hashtable getDirectoryContextEnvironment() {
 
-        Hashtable env = new Hashtable();
+        Hashtable<String,String> env = new Hashtable<String,String>();
 
         // Configure our directory context environment.
         if (containerLog.isDebugEnabled() && connectionAttempt == 0)
@@ -1714,7 +1713,7 @@ public class JNDIRealm extends RealmBase {
     protected String[] parseUserPatternString(String userPatternString) {
 
         if (userPatternString != null) {
-            ArrayList pathList = new ArrayList();
+            ArrayList<String> pathList = new ArrayList<String>();
             int startParenLoc = userPatternString.indexOf('(');
             if (startParenLoc == -1) {
                 // no parens here; return whole thing
@@ -1802,10 +1801,11 @@ class User {
     String username = null;
     String dn = null;
     String password = null;
-    ArrayList roles = null;
+    ArrayList<String> roles = null;
 
 
-    User(String username, String dn, String password, ArrayList roles) {
+    User(String username, String dn, String password,
+            ArrayList<String> roles) {
         this.username = username;
         this.dn = dn;
         this.password = password;
index 09b6730..6974c4a 100644 (file)
@@ -82,7 +82,8 @@ public class MemoryRealm  extends RealmBase {
     /**
      * The set of valid Principals for this Realm, keyed by user name.
      */
-    private Map principals = new HashMap();
+    private Map<String,GenericPrincipal> principals =
+        new HashMap<String,GenericPrincipal>();
 
 
     /**
@@ -184,7 +185,7 @@ public class MemoryRealm  extends RealmBase {
     void addUser(String username, String password, String roles) {
 
         // Accumulate the list of roles for this user
-        ArrayList list = new ArrayList();
+        ArrayList<String> list = new ArrayList<String>();
         roles += ",";
         while (true) {
             int comma = roles.indexOf(',');
index ef202d6..347a3df 100644 (file)
@@ -214,7 +214,7 @@ public class UserDatabaseRealm
             return null;
         }
 
-        List roles = new ArrayList();
+        List<String> roles = new ArrayList<String>();
         Iterator uroles = user.getRoles();
         while(uroles.hasNext()) {
             Role role = (Role)uroles.next();