tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r797162 - in /tomcat/trunk: java/org/apache/catalina/ha/session/ java/org/apache/catalina/realm/ java/org/apache/catalina/startup/ test/org/apache/catalina/ha/session/
Date Thu, 23 Jul 2009 17:39:51 GMT
Author: markt
Date: Thu Jul 23 17:39:51 2009
New Revision: 797162

URL: http://svn.apache.org/viewvc?rev=797162&view=rev
Log:
Preparatory work for https://issues.apache.org/bugzilla/show_bug.cgi?id=40881
As proposed on the dev list, remove the Realm from GenericPrincipal

Modified:
    tomcat/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java
    tomcat/trunk/java/org/apache/catalina/ha/session/DeltaSession.java
    tomcat/trunk/java/org/apache/catalina/ha/session/SerializablePrincipal.java
    tomcat/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
    tomcat/trunk/java/org/apache/catalina/realm/DataSourceRealm.java
    tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java
    tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java
    tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java
    tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java
    tomcat/trunk/java/org/apache/catalina/realm/MemoryRealm.java
    tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java
    tomcat/trunk/java/org/apache/catalina/realm/UserDatabaseRealm.java
    tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
    tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java

Modified: tomcat/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java Thu Jul 23 17:39:51
2009
@@ -184,7 +184,7 @@
                     Principal p = null;
                     if ( info.getAction() == ACTION_SET ) {
                         SerializablePrincipal sp = (SerializablePrincipal)info.getValue();
-                        p = sp.getPrincipal(session.getManager().getContainer().getRealm());
+                        p = sp.getPrincipal();
                     }
                     session.setPrincipal(p,false);
                     break;

Modified: tomcat/trunk/java/org/apache/catalina/ha/session/DeltaSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/DeltaSession.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/DeltaSession.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/DeltaSession.java Thu Jul 23 17:39:51
2009
@@ -598,7 +598,7 @@
         boolean hasPrincipal = stream.readBoolean();
         principal = null;
         if (hasPrincipal) {
-            principal = SerializablePrincipal.readPrincipal(stream,getManager().getContainer().getRealm());
+            principal = SerializablePrincipal.readPrincipal(stream);
         }
 
         //        setId((String) stream.readObject());

Modified: tomcat/trunk/java/org/apache/catalina/ha/session/SerializablePrincipal.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/SerializablePrincipal.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/SerializablePrincipal.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/SerializablePrincipal.java Thu Jul 23
17:39:51 2009
@@ -64,13 +64,12 @@
      * Construct a new Principal, associated with the specified Realm, for the
      * specified username and password.
      *
-     * @param realm The Realm that owns this Principal
      * @param name The username of the user represented by this Principal
      * @param password Credentials used to authenticate this user
      */
-    public SerializablePrincipal(Realm realm, String name, String password) {
+    public SerializablePrincipal(String name, String password) {
 
-        this(realm, name, password, null);
+        this(name, password, null);
 
     }
 
@@ -80,14 +79,13 @@
      * specified username and password, with the specified role names
      * (as Strings).
      *
-     * @param realm The Realm that owns this principal
      * @param name The username of the user represented by this Principal
      * @param password Credentials used to authenticate this user
      * @param roles List of roles (must be Strings) possessed by this user
      */
-    public SerializablePrincipal(Realm realm, String name, String password,
+    public SerializablePrincipal(String name, String password,
                             List<String> roles) {
-        this(realm, name, password, roles, null);
+        this(name, password, roles, null);
     }
 
     
@@ -96,17 +94,15 @@
      * specified username and password, with the specified role names
      * (as Strings).
      *
-     * @param realm The Realm that owns this principal
      * @param name The username of the user represented by this Principal
      * @param password Credentials used to authenticate this user
      * @param roles List of roles (must be Strings) possessed by this user
      * @param userPrincipal The user principal to be exposed to applications
      */
-    public SerializablePrincipal(Realm realm, String name, String password,
+    public SerializablePrincipal(String name, String password,
                             List<String> roles, Principal userPrincipal) {
 
         super();
-        this.realm = realm;
         this.name = name;
         this.password = password;
         if (roles != null) {
@@ -197,21 +193,20 @@
     public static SerializablePrincipal createPrincipal(GenericPrincipal principal)
     {
         if ( principal==null) return null;
-        return new SerializablePrincipal(principal.getRealm(),
-                                         principal.getName(),
+        return new SerializablePrincipal(principal.getName(),
                                          principal.getPassword(),
                                          principal.getRoles()!=null?Arrays.asList(principal.getRoles()):null,
                                          principal.getUserPrincipal()!=principal?principal.getUserPrincipal():null);
     }
 
-    public GenericPrincipal getPrincipal( Realm realm )
+    public GenericPrincipal getPrincipal()
     {
-        return new GenericPrincipal(realm, name, password,
+        return new GenericPrincipal(name, password,
                 getRoles()!=null?Arrays.asList(getRoles()):null,
                 userPrincipal);
     }
     
-    public static GenericPrincipal readPrincipal(ObjectInput in, Realm realm)
+    public static GenericPrincipal readPrincipal(ObjectInput in)
             throws IOException, ClassNotFoundException {
         String name = in.readUTF();
         boolean hasPwd = in.readBoolean();
@@ -231,7 +226,7 @@
                 throw e;
             }
         }
-        return new GenericPrincipal(realm,name,pwd,Arrays.asList(roles),
+        return new GenericPrincipal(name,pwd,Arrays.asList(roles),
                 userPrincipal);
     }
     

Modified: tomcat/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java Thu
Jul 23 17:39:51 2009
@@ -434,7 +434,7 @@
                 p = (SerializablePrincipal)session_in.readObject();
             ((ReplicatedSession)session).readObjectData(session_in);
             if ( hasPrincipal )
-                session.setPrincipal(p.getPrincipal(getContainer().getRealm()));
+                session.setPrincipal(p.getPrincipal());
             ((ReplicatedSession)session).setId(sessionId,isNew);
             ReplicatedSession rsession = (ReplicatedSession)session; 
             rsession.setAccessCount(1);

Modified: tomcat/trunk/java/org/apache/catalina/realm/DataSourceRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/DataSourceRealm.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/DataSourceRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/DataSourceRealm.java Thu Jul 23 17:39:51 2009
@@ -338,7 +338,7 @@
         ArrayList<String> list = getRoles(dbConnection, username);
 
         // Create and return a suitable Principal for this user
-        return (new GenericPrincipal(this, username, credentials, list));
+        return (new GenericPrincipal(username, credentials, list));
 
     }
 
@@ -477,11 +477,10 @@
     protected Principal getPrincipal(String username) {
     	Connection dbConnection = open();
         if (dbConnection == null) {
-            return new GenericPrincipal(this,username, null, null);
+            return new GenericPrincipal(username, null, null);
         }
         try {
-        	return (new GenericPrincipal(this,
-        			username,
+        	return (new GenericPrincipal(username,
 					getPassword(dbConnection, username),
 					getRoles(dbConnection, username)));
         } finally {

Modified: tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java Thu Jul 23 17:39:51
2009
@@ -25,8 +25,6 @@
 
 import javax.security.auth.login.LoginContext;
 
-import org.apache.catalina.Realm;
-
 
 /**
  * Generic implementation of <strong>java.security.Principal</strong> that
@@ -46,13 +44,12 @@
      * Construct a new Principal, associated with the specified Realm, for the
      * specified username and password.
      *
-     * @param realm The Realm that owns this Principal
      * @param name The username of the user represented by this Principal
      * @param password Credentials used to authenticate this user
      */
-    public GenericPrincipal(Realm realm, String name, String password) {
+    public GenericPrincipal(String name, String password) {
 
-        this(realm, name, password, null);
+        this(name, password, null);
 
     }
 
@@ -62,14 +59,12 @@
      * specified username and password, with the specified role names
      * (as Strings).
      *
-     * @param realm The Realm that owns this principal
      * @param name The username of the user represented by this Principal
      * @param password Credentials used to authenticate this user
      * @param roles List of roles (must be Strings) possessed by this user
      */
-    public GenericPrincipal(Realm realm, String name, String password,
-                            List<String> roles) {
-        this(realm, name, password, roles, null);
+    public GenericPrincipal(String name, String password, List<String> roles) {
+        this(name, password, roles, null);
     }
 
     /**
@@ -77,16 +72,15 @@
      * specified username and password, with the specified role names
      * (as Strings).
      *
-     * @param realm The Realm that owns this principal
      * @param name The username of the user represented by this Principal
      * @param password Credentials used to authenticate this user
      * @param roles List of roles (must be Strings) possessed by this user
      * @param userPrincipal - the principal to be returned from the request 
      *        getUserPrincipal call if not null; if null, this will be returned
      */
-    public GenericPrincipal(Realm realm, String name, String password,
-                            List<String> roles, Principal userPrincipal) {
-        this(realm, name, password, roles, userPrincipal, null);
+    public GenericPrincipal(String name, String password, List<String> roles,
+            Principal userPrincipal) {
+        this(name, password, roles, userPrincipal, null);
     }
     
     /**
@@ -94,7 +88,6 @@
      * specified username and password, with the specified role names
      * (as Strings).
      *
-     * @param realm The Realm that owns this principal
      * @param name The username of the user represented by this Principal
      * @param password Credentials used to authenticate this user
      * @param roles List of roles (must be Strings) possessed by this user
@@ -103,11 +96,9 @@
      * @param loginContext  - If provided, this will be used to log out the user
      *        at the appropriate time
      */
-    public GenericPrincipal(Realm realm, String name, String password,
-                            List<String> roles, Principal userPrincipal,
-                            LoginContext loginContext) {
+    public GenericPrincipal(String name, String password, List<String> roles,
+            Principal userPrincipal, LoginContext loginContext) {
         super();
-        this.realm = realm;
         this.name = name;
         this.password = password;
         this.userPrincipal = userPrincipal;
@@ -146,20 +137,6 @@
 
 
     /**
-     * The Realm with which this Principal is associated.
-     */
-    protected Realm realm = null;
-
-    public Realm getRealm() {
-        return (this.realm);
-    }
-
-    void setRealm( Realm realm ) {
-        this.realm=realm;
-    }
-
-
-    /**
      * The set of roles associated with this user.
      */
     protected String roles[] = new String[0];

Modified: tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/JAASRealm.java Thu Jul 23 17:39:51 2009
@@ -539,7 +539,7 @@
         }
 
         // Return the resulting Principal for our authenticated user
-        return new GenericPrincipal(this, username, null, roles, userPrincipal,
+        return new GenericPrincipal(username, null, roles, userPrincipal,
                 loginContext);
     }
 

Modified: tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java Thu Jul 23 17:39:51 2009
@@ -425,7 +425,7 @@
         ArrayList<String> roles = getRoles(username);
         
         // Create and return a suitable Principal for this user
-        return (new GenericPrincipal(this, username, credentials, roles));
+        return (new GenericPrincipal(username, credentials, roles));
 
     }
 
@@ -595,8 +595,7 @@
      */
     protected synchronized Principal getPrincipal(String username) {
 
-        return (new GenericPrincipal(this,
-                                     username,
+        return (new GenericPrincipal(username,
                                      getPassword(username),
                                      getRoles(username)));
 

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=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/JNDIRealm.java Thu Jul 23 17:39:51 2009
@@ -1025,8 +1025,7 @@
                                     containerLog.debug("Found role: " + it.next());
                                 }
                             }
-                            return (new GenericPrincipal(this,
-                                                         username,
+                            return (new GenericPrincipal(username,
                                                          credentials,
                                                          roles));
                         }
@@ -1061,7 +1060,7 @@
             }
 
             // Create and return a suitable Principal for this user
-            return (new GenericPrincipal(this, username, credentials, roles));
+            return (new GenericPrincipal(username, credentials, roles));
         }
     }
 
@@ -1883,7 +1882,7 @@
 
         User user = getUser(context, username);
 
-        return new GenericPrincipal(this, user.username, user.password ,
+        return new GenericPrincipal(user.username, user.password ,
                 getRoles(context, user));
     }
 

Modified: tomcat/trunk/java/org/apache/catalina/realm/MemoryRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/MemoryRealm.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/MemoryRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/MemoryRealm.java Thu Jul 23 17:39:51 2009
@@ -197,7 +197,7 @@
 
         // Construct and cache the Principal for this user
         GenericPrincipal principal =
-            new GenericPrincipal(this, username, password, list);
+            new GenericPrincipal(username, password, list);
         principals.put(username, principal);
 
     }

Modified: tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/RealmBase.java Thu Jul 23 17:39:51 2009
@@ -870,10 +870,6 @@
             return (false);
 
         GenericPrincipal gp = (GenericPrincipal) principal;
-        if (!(gp.getRealm() == this)) {
-            if(log.isDebugEnabled())
-                log.debug("Different realm " + this + " " + gp.getRealm());//    return (false);
-        }
         boolean result = gp.hasRole(role);
         if (log.isDebugEnabled()) {
             String name = principal.getName();

Modified: tomcat/trunk/java/org/apache/catalina/realm/UserDatabaseRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/UserDatabaseRealm.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/UserDatabaseRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/UserDatabaseRealm.java Thu Jul 23 17:39:51
2009
@@ -228,7 +228,7 @@
                 roles.add(role.getName());
             }
         }
-        return new GenericPrincipal(this, username, user.getPassword(), roles, user);
+        return new GenericPrincipal(username, user.getPassword(), roles, user);
     }
 
 

Modified: tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java Thu Jul 23 17:39:51 2009
@@ -462,7 +462,7 @@
                 if (p == null) {
                     String pass = userPass.get(username);
                     if (pass != null) {
-                        p = new GenericPrincipal(this, username, pass, 
+                        p = new GenericPrincipal(username, pass,
                                 userRoles.get(username));
                         userPrincipals.put(username, p);
                     }

Modified: tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java?rev=797162&r1=797161&r2=797162&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java (original)
+++ tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java Thu Jul
23 17:39:51 2009
@@ -53,7 +53,7 @@
         roles.add("RoleB");
         TesterPrincipal tpOriginal = new TesterPrincipal("inner");
         GenericPrincipal gpOriginal =
-            new GenericPrincipal(null, "usr", "pwd", roles, tpOriginal);
+            new GenericPrincipal("usr", "pwd", roles, tpOriginal);
         
         // Do the serialization
         try {
@@ -75,7 +75,7 @@
         try {
             FileInputStream fis = new FileInputStream(file);
             ObjectInputStream ois = new ObjectInputStream(fis);
-            gpNew = SerializablePrincipal.readPrincipal(ois, null);
+            gpNew = SerializablePrincipal.readPrincipal(ois);
         } catch (FileNotFoundException e) {
             e.printStackTrace();
             fail("fnfe reading object output stream");



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


Mime
View raw message