portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base BaseSecurityAccess.java BaseSecurityEntry.java
Date Mon, 03 May 2004 22:25:05 GMT
taylor      2004/05/03 15:25:05

  Modified:    src/java/org/apache/jetspeed/om/registry/base
                        BaseSecurityAccess.java BaseSecurityEntry.java
  Log:
  Bug fix for AccessController Security Cache synchronization issues
  I dare say if this finds all bugs, but it does now pass for all grant and revoke APIs
  
  http://nagoya.apache.org/jira/browse/JS1-466
  
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.12      +5 -5      jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityAccess.java
  
  Index: BaseSecurityAccess.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityAccess.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BaseSecurityAccess.java	23 Feb 2004 03:08:26 -0000	1.11
  +++ BaseSecurityAccess.java	3 May 2004 22:25:05 -0000	1.12
  @@ -209,12 +209,12 @@
       public Vector getAllAllows()
       {
           int elementCount = 0;
  -        if (this.allAllows == null)
  -        {
  +//        if (this.allAllows == null)
  +//        {
               allAllows = new Vector();
  -        }
  +//        }
   
  -        if (allAllows.isEmpty() == true)
  +    //    if (allAllows.isEmpty() == true)
           {
               if (this.allows != null)
               {
  
  
  
  1.16      +90 -44    jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityEntry.java
  
  Index: BaseSecurityEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityEntry.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- BaseSecurityEntry.java	23 Mar 2004 21:15:24 -0000	1.15
  +++ BaseSecurityEntry.java	3 May 2004 22:25:05 -0000	1.16
  @@ -319,15 +319,19 @@
       public boolean allowsSpecificRole( String action, String role)
       {
           SecurityAccess access = (SecurityAccess) getAccess(action);
  -        if (access.getAllAllows() != null)
  +        if (access != null)            
           {
  -            Iterator allAllows = access.getAllows().iterator();
  -            while (allAllows.hasNext())
  -            {
  -                SecurityAllow allow = (SecurityAllow) allAllows.next();
  -                if (allow.getRole() != null && allow.getRole().equals(role))
  +            List allows = access.getAllows();
  +            if (allows != null)
  +            {            
  +                Iterator allAllows = allows.iterator();
  +                while (allAllows.hasNext())
                   {
  -                    return true;
  +                    SecurityAllow allow = (SecurityAllow) allAllows.next();
  +                    if (allow.getRole() != null && allow.getRole().equals(role))
  +                    {
  +                        return true;
  +                    }
                   }
               }
           }
  @@ -341,16 +345,20 @@
   	public boolean allowsSpecificGroup(String action, String group)
   	{
   		SecurityAccess access = (SecurityAccess) getAccess(action);
  -		if (access.getAllAllows() != null)
  +		if (access != null)
   		{
  -			Iterator allAllows = access.getAllows().iterator();
  -			while (allAllows.hasNext())
  -			{
  -				SecurityAllow allow = (SecurityAllow) allAllows.next();
  -				if (allow.getGroup() != null && allow.getGroup().equals(group))
  -				{
  -					return true;
  -				}
  +            List allows = access.getAllows();
  +            if (allows != null)
  +            {
  +                Iterator allAllows = allows.iterator();
  +                while (allAllows.hasNext())
  +                {
  +                    SecurityAllow allow = (SecurityAllow) allAllows.next();
  +                    if (allow.getGroup() != null && allow.getGroup().equals(group))
  +                    {
  +                        return true;
  +                    }
  +                }
   			}
   		}
   		return false;
  @@ -363,20 +371,24 @@
   	public boolean allowsSpecificGroupRole(String action, String group, String role)
   	{
   		SecurityAccess access = (SecurityAccess) getAccess(action);
  -		if (access.getAllAllows() != null)
  -		{
  -			Iterator allAllows = access.getAllows().iterator();
  -			while (allAllows.hasNext())
  -			{
  -				SecurityAllow allow = (SecurityAllow) allAllows.next();
  -				if (allow.getGroup() != null && 
  -					allow.getGroup().equals(group) &&
  -					allow.getRole() != null &&
  -					allow.getRole().equals(role))
  -				{
  -					return true;
  -				}
  -			}
  +		if (access != null)
  +		{            
  +            List allows = access.getAllows();        
  +            if (allows != null)
  +            {
  +    			Iterator allAllows = allows.iterator();
  +    			while (allAllows.hasNext())
  +    			{
  +    				SecurityAllow allow = (SecurityAllow) allAllows.next();
  +    				if (allow.getGroup() != null && 
  +    					allow.getGroup().equals(group) &&
  +    					allow.getRole() != null &&
  +    					allow.getRole().equals(role))
  +    				{
  +    					return true;
  +    				}
  +    			}
  +            }
   		}
   		return false;
   	}
  @@ -392,15 +404,19 @@
       public boolean allowsSpecificUser(String action, String user)
       {
           BaseSecurityAccess access = (BaseSecurityAccess) getAccess(action);
  -        if (access.getAllAllows() != null)
  +        if (access != null)
           {
  -            Iterator allAllows = access.getAllows().iterator();
  -            while (allAllows.hasNext())
  +            List allows = access.getAllows();        
  +            if (allows != null)
               {
  -                BaseSecurityAllow allow = (BaseSecurityAllow) allAllows.next();
  -                if (allow.getUser() != null && allow.getUser().equals(user))
  +                Iterator allAllows = access.getAllows().iterator();
  +                while (allAllows.hasNext())
                   {
  -                    return true;
  +                    BaseSecurityAllow allow = (BaseSecurityAllow) allAllows.next();
  +                    if (allow.getUser() != null && allow.getUser().equals(user))
  +                    {
  +                        return true;
  +                    }
                   }
               }
           }
  @@ -449,6 +465,12 @@
           if (!allowsSpecificRole(action, role))
           {
               SecurityAccess access = getAccess(action);
  +            if (access == null)
  +            {
  +                access = new BaseSecurityAccess();
  +                access.setAction(action);
  +                this.getAccesses().add(access);                
  +            }            
               List allows = access.getAllows();
               if (allows == null)
               {
  @@ -481,10 +503,17 @@
   		if (!allowsSpecificGroup(action, role))
   		{
   			SecurityAccess access = getAccess(action);
  -			List allows = access.getAllows();
  +            if (access == null)
  +            {
  +                access = new BaseSecurityAccess();
  +                access.setAction(action);
  +                this.getAccesses().add(access);
  +            }
  +			Vector allows = access.getAllows();
   			if (allows == null)
   			{
   				allows = new Vector();
  +                access.setAllows(allows);
   			}
   
   			BaseSecurityAllow allow = new BaseSecurityAllow();
  @@ -514,6 +543,12 @@
   		if (!allowsSpecificGroupRole(action, group, role))
   		{
   			SecurityAccess access = getAccess(action);
  +            if (access == null)
  +            {
  +                access = new BaseSecurityAccess();
  +                access.setAction(action);      
  +                this.getAccesses().add(access);                
  +            }            
   			List allows = access.getAllows();
   			if (allows == null)
   			{
  @@ -547,6 +582,12 @@
           if (!allowsSpecificUser(action, user))
           {
               SecurityAccess access = getAccess(action);
  +            if (access == null)
  +            {
  +                access = new BaseSecurityAccess();
  +                access.setAction(action);      
  +                this.getAccesses().add(access);                
  +            }            
               List allows = access.getAllows();
               if (allows == null)
               {
  @@ -582,6 +623,7 @@
               if (allows == null || allows.isEmpty())
               {
                   revokeAccess(action);
  +                buildAccessMap();                
                   return false;
               }
   
  @@ -595,7 +637,7 @@
                       {
                           revokeAccess(action);
                       }
  -
  +                    buildAccessMap();                        
                       return true;
                   }
               }
  @@ -619,6 +661,7 @@
   			if (allows == null || allows.isEmpty())
   			{
   				revokeAccess(action);
  +                buildAccessMap();                
   				return false;
   			}
   
  @@ -632,7 +675,7 @@
   					{
   						revokeAccess(action);
   					}
  -
  +                    buildAccessMap();                        
   					return true;
   				}
   			}
  @@ -657,6 +700,7 @@
   			if (allows == null || allows.isEmpty())
   			{
   				revokeAccess(action);
  +                buildAccessMap();                
   				return false;
   			}
   
  @@ -673,7 +717,7 @@
   					{
   						revokeAccess(action);
   					}
  -
  +                    buildAccessMap();                        
   					return true;
   				}
   			}
  @@ -697,6 +741,7 @@
               if (allows == null || allows.isEmpty())
               {
                   revokeAccess(action);
  +                buildAccessMap();                
                   return false;
               }
   
  @@ -710,7 +755,7 @@
                       {
                           revokeAccess(action);
                       }
  -
  +                    buildAccessMap();
                       return true;
                   }
               }
  @@ -799,13 +844,14 @@
           Map userMap = null;  // Map of users allowed
           String userName = null;
   
  -        if (accessElement.getAllAllows() == null)
  +        List all = accessElement.getAllAllows();
  +        if (all == null)
           {
               return;
           }
   
           // Add allows to the action Map
  -        for (Iterator allowIterator = accessElement.getAllAllows().iterator(); allowIterator.hasNext();)
  +        for (Iterator allowIterator = all.iterator(); allowIterator.hasNext();)
           {
               allowElement = (SecurityAllow) allowIterator.next();
               role = null;
  
  
  

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


Mime
View raw message