jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r659404 - in /incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth: acl/ authorize/ login/ permissions/
Date Fri, 23 May 2008 04:02:16 GMT
Author: ajaquith
Date: Thu May 22 21:02:13 2008
New Revision: 659404

URL: http://svn.apache.org/viewvc?rev=659404&view=rev
Log:
Miscellaneous and varied Java 5 enhancements (such as for-loops).

Modified:
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Group.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/GroupManager.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/JDBCGroupDatabase.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/WebContainerAuthorizer.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/XMLGroupDatabase.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/login/AbstractLoginModule.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/AllPermissionCollection.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/GroupPermission.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PagePermission.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PermissionFactory.java

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java Thu May 22 21:02:13
2008
@@ -70,7 +70,7 @@
                 }
             }
         }
-        return (Principal[])principals.toArray( new Principal[principals.size()] );
+        return principals.toArray( new Principal[principals.size()] );
     }
   
     private boolean hasEntry( AclEntry entry )

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java Thu May
22 21:02:13 2008
@@ -247,7 +247,7 @@
     protected static String printAcl( Acl acl )
     {
         // Extract the ACL entries into a Map with keys == permissions, values == principals
-        Map permissionPrincipals = new TreeMap();
+        Map<String, List<Principal>> permissionPrincipals = new TreeMap<String,
List<Principal>>();
         Enumeration entries = acl.entries();
         while ( entries.hasMoreElements() )
         {
@@ -257,10 +257,10 @@
             while ( permissions.hasMoreElements() )
             {
                 Permission permission = (Permission)permissions.nextElement();
-                List principals = (List)permissionPrincipals.get( permission.getActions()
);
+                List<Principal> principals = permissionPrincipals.get( permission.getActions()
);
                 if ( principals == null )
                 {
-                    principals = new ArrayList();
+                    principals = new ArrayList<Principal>();
                     String action = permission.getActions();
                     if ( action.indexOf(',') != -1 )
                     {
@@ -275,18 +275,17 @@
         // Now, iterate through each permission in the map and generate an ACL string
 
         StringBuffer s = new StringBuffer();
-        for ( Iterator it = permissionPrincipals.entrySet().iterator(); it.hasNext(); )
+        for ( Map.Entry<String,List<Principal>>entry : permissionPrincipals.entrySet()
)
         {
-            Map.Entry entry = (Map.Entry)it.next();
-            String action = (String)entry.getKey();
-            List principals = (List)entry.getValue();
+            String action = entry.getKey();
+            List<Principal> principals = entry.getValue();
             Collections.sort( principals, new PrincipalComparator() );
             s.append( "[{ALLOW ");
             s.append( action );
             s.append( " ");
             for ( int i = 0; i < principals.size(); i++ )
             {
-                Principal principal = (Principal)principals.get( i );
+                Principal principal = principals.get( i );
                 s.append( principal.getName() );
                 if ( i < ( principals.size() - 1 ) )
                 {

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Group.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Group.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Group.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Group.java Thu May 22 21:02:13
2008
@@ -22,7 +22,6 @@
 
 import java.security.Principal;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.Vector;
 
 import com.ecyrd.jspwiki.auth.GroupPrincipal;
@@ -67,7 +66,7 @@
     static final String[]  RESTRICTED_GROUPNAMES = new String[]
                                                   { "Anonymous", "All", "Asserted", "Authenticated"
};
 
-    private final Vector    m_members             = new Vector();
+    private final Vector<Principal>    m_members             = new Vector<Principal>();
 
     private String          m_creator             = null;
 
@@ -149,9 +148,9 @@
             return false;
         }
 
-        for( Iterator i = m_members.iterator(); i.hasNext(); )
+        for( Principal principal : m_members )
         {
-            if ( !( g.isMember( (Principal) i.next() ) ) )
+            if ( !g.isMember( principal ) )
             {
                 return false;
             }
@@ -168,9 +167,9 @@
     public int hashCode()
     {
         int hc = 0;
-        for( Iterator i = m_members.iterator(); i.hasNext(); )
+        for( Principal member : m_members )
         {
-            hc ^= i.next().hashCode();
+            hc ^= member.hashCode();
         }
         return hc;
     }
@@ -257,7 +256,7 @@
      */
     public Principal[] members()
     {
-        return (Principal[]) m_members.toArray( new Principal[m_members.size()] );
+        return m_members.toArray( new Principal[m_members.size()] );
     }
 
     /**
@@ -328,10 +327,8 @@
 
     private Principal findMember( String name )
     {
-        for( Iterator i = m_members.iterator(); i.hasNext(); )
+        for( Principal member : m_members )
         {
-            Principal member = (Principal) i.next();
-
             if ( member.getName().equals( name ) )
             {
                 return member;

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/GroupManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/GroupManager.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/GroupManager.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/GroupManager.java Thu May
22 21:02:13 2008
@@ -79,7 +79,7 @@
     private GroupDatabase       m_groupDatabase    = null;
 
     /** Map with GroupPrincipals as keys, and Groups as values */
-    private final Map           m_groups           = new HashMap();
+    private final Map<Principal, Group>           m_groups           = new HashMap<Principal,
Group>();
 
     /**
      * <p>
@@ -111,7 +111,7 @@
      */
     public final Group getGroup( String name ) throws NoSuchPrincipalException
     {
-        Group group = (Group) m_groups.get( new GroupPrincipal( name ) );
+        Group group = m_groups.get( new GroupPrincipal( name ) );
         if ( group != null )
         {
             return group;
@@ -149,7 +149,7 @@
                 dbClassName = XMLGroupDatabase.class.getName();
             }
             log.info( "Attempting to load group database class " + dbClassName );
-            Class dbClass = ClassUtil.findClass( "com.ecyrd.jspwiki.auth.authorize", dbClassName
);
+            Class<?> dbClass = ClassUtil.findClass( "com.ecyrd.jspwiki.auth.authorize",
dbClassName );
             m_groupDatabase = (GroupDatabase) dbClass.newInstance();
             m_groupDatabase.initialize( m_engine, m_engine.getWikiProperties() );
             log.info( "Group database initialized." );
@@ -196,7 +196,7 @@
      */
     public final Principal[] getRoles()
     {
-        return (Principal[]) m_groups.keySet().toArray( new Principal[m_groups.size()] );
+        return m_groups.keySet().toArray( new Principal[m_groups.size()] );
     }
 
     /**
@@ -226,9 +226,8 @@
         Group[] groups = m_groupDatabase.groups();
         synchronized( m_groups )
         {
-            for( int i = 0; i < groups.length; i++ )
+            for( Group group : groups )
             {
-                Group group = groups[i];
                 // Add new group to cache; fire GROUP_ADD event
                 m_groups.put( group.getPrincipal(), group );
                 fireEvent( WikiSecurityEvent.GROUP_ADD, group );
@@ -274,17 +273,16 @@
         }
 
         // Get the group we're examining
-        Group group = (Group) m_groups.get( role );
+        Group group = m_groups.get( role );
         if ( group == null )
         {
             return false;
         }
 
         // Check each user principal to see if it belongs to the group
-        Principal[] principals = session.getPrincipals();
-        for ( int i = 0; i < principals.length; i++ )
+        for ( Principal principal : session.getPrincipals() )
         {
-            if ( AuthenticationManager.isUserPrincipal( principals[i] ) && group.isMember(
principals[i] ) )
+            if ( AuthenticationManager.isUserPrincipal( principal ) && group.isMember(
principal ) )
             {
                 return true;
             }
@@ -361,10 +359,9 @@
             group.setCreated( existingGroup.getCreated() );
             group.setModifier( existingGroup.getModifier() );
             group.setLastModified( existingGroup.getLastModified() );
-            Principal[] existingMembers = existingGroup.members();
-            for( int i = 0; i < existingMembers.length; i++ )
+            for( Principal existingMember : existingGroup.members() )
             {
-                group.add( existingMembers[i] );
+                group.add( existingMember );
             }
         }
         catch( NoSuchPrincipalException e )
@@ -381,9 +378,9 @@
         if ( members.length > 0 )
         {
             group.clear();
-            for( int i = 0; i < members.length; i++ )
+            for( String member : members )
             {
-                group.add( new WikiPrincipal( members[i] ) );
+                group.add( new WikiPrincipal( member ) );
             }
         }
 
@@ -458,7 +455,7 @@
             throw new IllegalArgumentException( "Group cannot be null." );
         }
 
-        Group group = (Group) m_groups.get( new GroupPrincipal( index ) );
+        Group group = m_groups.get( new GroupPrincipal( index ) );
         if ( group == null )
         {
             throw new NoSuchPrincipalException( "Group " + index + " not found" );
@@ -519,7 +516,7 @@
         // TODO: check for appropriate permissions
 
         // If group already exists, delete it; fire GROUP_REMOVE event
-        Group oldGroup = (Group) m_groups.get( group.getPrincipal() );
+        Group oldGroup = m_groups.get( group.getPrincipal() );
         if ( oldGroup != null )
         {
             fireEvent( WikiSecurityEvent.GROUP_REMOVE, oldGroup );
@@ -609,7 +606,7 @@
      */
     protected final String[] extractMembers( String memberLine )
     {
-        Set members = new HashSet();
+        Set<String> members = new HashSet<String>();
         if ( memberLine != null )
         {
             StringTokenizer tok = new StringTokenizer( memberLine, "\n" );
@@ -622,7 +619,7 @@
                 }
             }
         }
-        return (String[]) members.toArray( new String[members.size()] );
+        return members.toArray( new String[members.size()] );
     }
 
     /**
@@ -723,16 +720,14 @@
             int groupsChanged = 0;
             try
             {
-                Group[] groups = m_groupDatabase.groups();
-                for ( int i = 0; i < groups.length; i++ )
+                for ( Group group : m_groupDatabase.groups() )
                 {
                     boolean groupChanged = false;
-                    Group group = groups[i];
-                    for ( int j = 0; j < oldPrincipals.length; j++ )
+                    for ( Principal oldPrincipal : oldPrincipals )
                     {
-                        if ( group.isMember( oldPrincipals[j] ) )
+                        if ( group.isMember( oldPrincipal ) )
                         {
-                            group.remove( oldPrincipals[j] );
+                            group.remove( oldPrincipal );
                             group.add( newPrincipal );
                             groupChanged = true;
                         }

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/JDBCGroupDatabase.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/JDBCGroupDatabase.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/JDBCGroupDatabase.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/JDBCGroupDatabase.java Thu
May 22 21:02:13 2008
@@ -320,7 +320,7 @@
      */
     public Group[] groups() throws WikiSecurityException
     {
-        Set groups = new HashSet();
+        Set<Group> groups = new HashSet<Group>();
         Connection conn = null;
         try
         {
@@ -364,7 +364,7 @@
             }
         }
 
-        return (Group[]) groups.toArray( new Group[groups.size()] );
+        return groups.toArray( new Group[groups.size()] );
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/WebContainerAuthorizer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/WebContainerAuthorizer.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/WebContainerAuthorizer.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/WebContainerAuthorizer.java
Thu May 22 21:02:13 2008
@@ -135,9 +135,9 @@
         if ( m_containerRoles.length > 0 )
         {
             String roles = "";
-            for( int i = 0; i < m_containerRoles.length; i++ )
+            for( Role containerRole : m_containerRoles )
             {
-                roles = roles + m_containerRoles[i] + " ";
+                roles = roles + containerRole + " ";
             }
             log.info( " JSPWiki determined the web container manages these roles: " + roles
);
         }
@@ -201,11 +201,11 @@
      */
     public Principal findRole( String role )
     {
-        for( int i = 0; i < m_containerRoles.length; i++ )
+        for( Role containerRole : m_containerRoles )
         {
-            if ( m_containerRoles[i].getName().equals( role ) )
+            if ( containerRole.getName().equals( role ) )
             {
-                return m_containerRoles[i];
+                return containerRole;
             }
         }
         return null;
@@ -244,13 +244,13 @@
         selector = "//j:web-app/j:security-constraint[j:web-resource-collection/j:url-pattern=\""
+ url + "\"]";
         xpath = XPath.newInstance( selector );
         xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
-        List constraints = xpath.selectNodes( root );
+        List<?> constraints = xpath.selectNodes( root );
 
         // Get all constraints that match our Role pattern
         selector = "//j:web-app/j:security-constraint[j:auth-constraint/j:role-name=\"" +
role.getName() + "\"]";
         xpath = XPath.newInstance( selector );
         xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
-        List roles = xpath.selectNodes( root );
+        List<?> roles = xpath.selectNodes( root );
 
         // If we can't find either one, we must not be constrained
         if ( constraints.size() == 0 )
@@ -271,10 +271,10 @@
         }
 
         // If a constraint is contained in both lists, we must be constrained
-        for ( Iterator c = constraints.iterator(); c.hasNext(); )
+        for ( Iterator<?> c = constraints.iterator(); c.hasNext(); )
         {
             Element constraint = (Element)c.next();
-            for ( Iterator r = roles.iterator(); r.hasNext(); )
+            for ( Iterator<?> r = roles.iterator(); r.hasNext(); )
             {
                 Element roleConstraint = (Element)r.next();
                 if ( constraint.equals( roleConstraint ) )
@@ -316,7 +316,7 @@
      */
     public Principal[] getRoles()
     {
-        return (Principal[])m_containerRoles.clone();
+        return m_containerRoles.clone();
     }
 
     /**
@@ -330,15 +330,15 @@
      */
     protected Role[] getRoles( Document webxml ) throws JDOMException
     {
-        Set roles = new HashSet();
+        Set<Role> roles = new HashSet<Role>();
         Element root = webxml.getRootElement();
 
         // Get roles referred to by constraints
         String selector = "//j:web-app/j:security-constraint/j:auth-constraint/j:role-name";
         XPath xpath = XPath.newInstance( selector );
         xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
-        List nodes = xpath.selectNodes( root );
-        for( Iterator it = nodes.iterator(); it.hasNext(); )
+        List<?> nodes = xpath.selectNodes( root );
+        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
         {
             String role = ( (Element) it.next() ).getTextTrim();
             roles.add( new Role( role ) );
@@ -349,13 +349,13 @@
         xpath = XPath.newInstance( selector );
         xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
         nodes = xpath.selectNodes( root );
-        for( Iterator it = nodes.iterator(); it.hasNext(); )
+        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
         {
             String role = ( (Element) it.next() ).getTextTrim();
             roles.add( new Role( role ) );
         }
 
-        return (Role[]) roles.toArray( new Role[roles.size()] );
+        return roles.toArray( new Role[roles.size()] );
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/XMLGroupDatabase.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/XMLGroupDatabase.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/XMLGroupDatabase.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/XMLGroupDatabase.java Thu
May 22 21:02:13 2008
@@ -33,7 +33,6 @@
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
@@ -114,7 +113,7 @@
 
     private WikiEngine            m_engine         = null;
 
-    private Map                   m_groups         = new HashMap();
+    private Map<String, Group>                   m_groups         = new HashMap<String,
Group>();
 
     /**
      * No-op method that in previous versions of JSPWiki was intended to
@@ -166,8 +165,8 @@
     public Group[] groups() throws WikiSecurityException
     {
         buildDOM();
-        Collection groups = m_groups.values();
-        return (Group[])groups.toArray( new Group[groups.size()] );
+        Collection<Group> groups = m_groups.values();
+        return groups.toArray( new Group[groups.size()] );
     }
 
     /**
@@ -417,10 +416,8 @@
             io.write( "<groups>\n" );
 
             // Write each profile as a <group> node
-            Collection groups = m_groups.values();
-            for( Iterator it = groups.iterator(); it.hasNext(); )
+            for( Group group : m_groups.values() )
             {
-                Group group = (Group) it.next();
                 io.write( "  <" + GROUP_TAG + " " );
                 io.write( GROUP_NAME );
                 io.write( "=\"" + StringEscapeUtils.escapeXml( group.getName() )+ "\" " );
@@ -435,10 +432,8 @@
                 io.write( ">\n" );
 
                 // Write each member as a <member> node
-                Principal[] members = group.members();
-                for( int j = 0; j < members.length; j++ )
+                for( Principal member : group.members() )
                 {
-                    Principal member = members[j];
                     io.write( "    <" + MEMBER_TAG + " " );
                     io.write( PRINCIPAL );
                     io.write( "=\"" + StringEscapeUtils.escapeXml(member.getName()) + "\"
" );

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/login/AbstractLoginModule.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/login/AbstractLoginModule.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/login/AbstractLoginModule.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/login/AbstractLoginModule.java Thu
May 22 21:02:13 2008
@@ -23,7 +23,6 @@
 import java.security.Principal;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.security.auth.Subject;
@@ -51,7 +50,7 @@
 
     protected CallbackHandler m_handler;
 
-    protected Map             m_options;
+    protected Map<String,?>             m_options;
 
     /**
      * Collection of Principals set during login module initialization.
@@ -62,7 +61,7 @@
      * if login succeeds.
      * @deprecated
      */
-    protected Collection      m_previousWikiPrincipals;
+    protected Collection<Principal>      m_previousWikiPrincipals;
 
     /**
      * Implementing classes should add Principals to this collection; these
@@ -80,7 +79,7 @@
      * {@link com.ecyrd.jspwiki.auth.authorize.Role}.
      * @deprecated
      */
-    protected Collection      m_principalsToRemove;
+    protected Collection<Principal>      m_principalsToRemove;
 
     /**
      * Implementing classes should add Principals to this collection to specify
@@ -95,9 +94,9 @@
      * should over-write {@link com.ecyrd.jspwiki.auth.authorize.Role#ANONYMOUS}.
      * @deprecated
      */
-    protected Collection      m_principalsToOverwrite;
+    protected Collection<Principal>      m_principalsToOverwrite;
 
-    protected Map             m_state;
+    protected Map<String,?>             m_state;
 
     protected Subject         m_subject;
 
@@ -148,9 +147,8 @@
         if ( succeeded() )
         {
             removePrincipals( m_previousWikiPrincipals );
-            for ( Iterator it = m_principals.iterator(); it.hasNext(); )
+            for ( Principal principal : m_principals )
             {
-                Principal principal = (Principal)it.next();
                 m_subject.getPrincipals().add( principal );
                 if ( log.isDebugEnabled() )
                 {
@@ -185,12 +183,12 @@
      * @param sharedState {@inheritDoc}
      * @param options {@inheritDoc}
      */
-    public final void initialize( Subject subject, CallbackHandler callbackHandler, Map sharedState,
Map options )
+    public final void initialize( Subject subject, CallbackHandler callbackHandler, Map<String,?>
sharedState, Map<String,?> options )
     {
-        m_previousWikiPrincipals = new HashSet();
+        m_previousWikiPrincipals = new HashSet<Principal>();
         m_principals = new HashSet<Principal>();
-        m_principalsToRemove = new HashSet();
-        m_principalsToOverwrite = new HashSet();
+        m_principalsToRemove = new HashSet<Principal>();
+        m_principalsToOverwrite = new HashSet<Principal>();
         m_subject = subject;
         m_handler = callbackHandler;
         m_state = sharedState;
@@ -254,11 +252,10 @@
      * Principal set.
      * @param principals the principals to remove
      */
-    private final void removePrincipals( Collection principals )
+    private final void removePrincipals( Collection<Principal> principals )
     {
-        for ( Iterator it = principals.iterator(); it.hasNext(); )
+        for ( Principal principal : principals )
         {
-            Principal principal = (Principal)it.next();
             if ( m_subject.getPrincipals().contains( principal ) )
             {
                 m_subject.getPrincipals().remove( principal );

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/AllPermissionCollection.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/AllPermissionCollection.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/AllPermissionCollection.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/AllPermissionCollection.java
Thu May 22 21:02:13 2008
@@ -38,7 +38,7 @@
 
     private boolean           m_readOnly      = false;
 
-    protected final Hashtable m_permissions    = new Hashtable();
+    protected final Hashtable<Permission, Permission> m_permissions    = new Hashtable<Permission,
Permission>();
 
     /**
      * Adds an AllPermission object to this AllPermissionCollection. If this
@@ -72,7 +72,7 @@
      * collection.
      * @see java.security.PermissionCollection#elements()
      */
-    public Enumeration elements()
+    public Enumeration<Permission> elements()
     {
         return m_permissions.elements();
     }
@@ -106,10 +106,10 @@
         }
 
         // Step through each AllPermission
-        Enumeration permEnum = m_permissions.elements();
+        Enumeration<Permission> permEnum = m_permissions.elements();
         while( permEnum.hasMoreElements() )
         {
-            Permission storedPermission = (Permission) permEnum.nextElement();
+            Permission storedPermission = permEnum.nextElement();
             if ( storedPermission.implies( permission ) )
             {
                 return true;

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/GroupPermission.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/GroupPermission.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/GroupPermission.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/GroupPermission.java Thu
May 22 21:02:13 2008
@@ -27,7 +27,6 @@
 import java.security.Permission;
 import java.security.Principal;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.Set;
 
 import javax.security.auth.Subject;
@@ -357,9 +356,8 @@
         }
         int mask = 0;
         String[] actionList = actions.split( ACTION_SEPARATOR );
-        for( int i = 0; i < actionList.length; i++ )
+        for( String action : actionList )
         {
-            String action = actionList[i];
             if ( action.equalsIgnoreCase( VIEW_ACTION ) )
             {
                 mask |= VIEW_MASK;
@@ -489,10 +487,9 @@
             // <member> implies permission if subject possesses
             // GroupPrincipal with same name as target
             Subject subject = ( (SubjectDomainCombiner) dc ).getSubject();
-            Set principals = subject.getPrincipals( GroupPrincipal.class );
-            for( Iterator it = principals.iterator(); it.hasNext(); )
+            Set<GroupPrincipal> principals = subject.getPrincipals( GroupPrincipal.class
);
+            for( Principal principal : principals )
             {
-                Principal principal = (Principal) it.next();
                 if ( principal.getName().equals( gp.m_group ) )
                 {
                     return true;

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PagePermission.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PagePermission.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PagePermission.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PagePermission.java Thu
May 22 21:02:13 2008
@@ -421,9 +421,8 @@
         }
         int mask = 0;
         String[] actionList = StringUtils.split( actions, ACTION_SEPARATOR );
-        for( int i = 0; i < actionList.length; i++ )
+        for( String action : actionList )
         {
-            String action = actionList[i];
             if ( action.equalsIgnoreCase( VIEW_ACTION ) )
             {
                 mask |= VIEW_MASK;

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PermissionFactory.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PermissionFactory.java?rev=659404&r1=659403&r2=659404&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PermissionFactory.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/permissions/PermissionFactory.java
Thu May 22 21:02:13 2008
@@ -38,7 +38,7 @@
      *  This is a WeakHashMap<Integer,PagePermission>, which stores the
      *  cached page permissions.
      */
-    private static WeakHashMap c_cache = new WeakHashMap();
+    private static WeakHashMap<Integer, PagePermission> c_cache = new WeakHashMap<Integer,
PagePermission>();
     
     /**
      *  Get a permission object for a WikiPage and a set of actions.
@@ -92,7 +92,7 @@
         //
         synchronized( c_cache )
         {
-            perm = (PagePermission)c_cache.get( key );
+            perm = c_cache.get( key );
         }
         
         if( perm == null )



Mime
View raw message