portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r695800 - in /portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets: entityeditor/ pam/ security/permissions/ security/users/ selector/
Date Tue, 16 Sep 2008 09:59:27 GMT
Author: ate
Date: Tue Sep 16 02:59:26 2008
New Revision: 695800

URL: http://svn.apache.org/viewvc?rev=695800&view=rev
Log:
More security api refactoring fixes

Modified:
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/entityeditor/PortletEntityEditorPortlet.java
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/permissions/SecurityPermissionsPortlet.java
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdmin.java
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/entityeditor/PortletEntityEditorPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/entityeditor/PortletEntityEditorPortlet.java?rev=695800&r1=695799&r2=695800&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/entityeditor/PortletEntityEditorPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/entityeditor/PortletEntityEditorPortlet.java
Tue Sep 16 02:59:26 2008
@@ -18,6 +18,7 @@
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.List;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -142,8 +143,10 @@
         String[] info = prefString.split("::");
         String prefName = info[1];
         int valueIndex = Integer.parseInt(info[2]);
-        PreferenceComposite pref = (PreferenceComposite) entity.getPreferenceSet().get(prefName);
-        pref.setValueAt(valueIndex, updatedValue);
+        PreferenceComposite pref = (PreferenceComposite) entity.getPreferenceSet().get(prefName);
+        List<String> values = pref.getValuesList();
+        values.set(valueIndex, updatedValue);
+        pref.setValues(values);
     }
     
     protected final void doRemoveValue(ActionRequest request, ActionResponse response) throws
PortletException
@@ -153,8 +156,10 @@
         String[] info = prefString.split("::");
         String prefName = info[1];
         int valueIndex = Integer.parseInt(info[2]);
-        PreferenceComposite pref = (PreferenceComposite) entity.getPreferenceSet().get(prefName);
-        pref.removeValueAt(valueIndex);
+        PreferenceComposite pref = (PreferenceComposite) entity.getPreferenceSet().get(prefName);
+        List<String> values = pref.getValuesList();
+        values.remove(valueIndex);
+        pref.setValues(values);
     }
 
     

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java?rev=695800&r1=695799&r2=695800&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
Tue Sep 16 02:59:26 2008
@@ -591,16 +591,22 @@
             {
                 String prefName = prefNames[i];
                 PreferenceComposite prefComp = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
-                String[] values = prefComp.getValueArray();
-                for (int j = 0; j < values.length; j++)
+                List<String> values = prefComp.getValuesList();
+                boolean update = false;
+                for (int j = 0; j < values.size(); j++)
                 {
-                    String value = values[j];
+                    String value = values.get(j);
                     String newValue = actionRequest.getParameter(prefName + ":" + j);
                     if(!value.equals(newValue))
                     {
-                        prefComp.setValueAt(j, newValue);
+                        values.set(j, newValue);
+                        update = true;
                     }
                 }
+                if (update)
+                {
+                    prefComp.setValues(values);
+                }
             }
         }
         else if(action.equals("remove_preference"))

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/permissions/SecurityPermissionsPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/permissions/SecurityPermissionsPortlet.java?rev=695800&r1=695799&r2=695800&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/permissions/SecurityPermissionsPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/permissions/SecurityPermissionsPortlet.java
Tue Sep 16 02:59:26 2008
@@ -35,10 +35,13 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.headerresource.HeaderResource;
+import org.apache.jetspeed.security.JetspeedPermission;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.PermissionFactory;
 import org.apache.jetspeed.security.PermissionManager;
+import org.apache.jetspeed.security.Role;
 import org.apache.jetspeed.security.RoleManager;
-import org.apache.jetspeed.security.om.InternalPermission;
-import org.apache.jetspeed.security.om.InternalPrincipal;
+import org.apache.jetspeed.security.SecurityException;
 import org.apache.portals.gems.dojo.AbstractDojoVelocityPortlet;
 import org.apache.velocity.context.Context;
 
@@ -115,25 +118,25 @@
         Iterator folderPermissions = (Iterator)session.getAttribute("folderPermissions",
PortletSession.PORTLET_SCOPE);
         Iterator pagePermissions = (Iterator)session.getAttribute("pagePermissions", PortletSession.PORTLET_SCOPE);
         Iterator portletPermissions = (Iterator)session.getAttribute("portletPermissions",
PortletSession.PORTLET_SCOPE);
-        Iterator roles = (Iterator)session.getAttribute("roles", PortletSession.PORTLET_SCOPE);
+        List<Role> roles = (List<Role>)session.getAttribute("roles", PortletSession.PORTLET_SCOPE);
         if (portletPermissions == null)
         {
             List folders = new LinkedList();
             List pages = new LinkedList();
             List portlets = new LinkedList();
-            Iterator all = pm.getPermissions().iterator();
+            Iterator<JetspeedPermission> all = pm.getPermissions().iterator();
             while (all.hasNext())
             {
-                InternalPermission permission = (InternalPermission)all.next();         
      
-                if (permission.getClassname().equals(CLASSNAMES[0]))
+                JetspeedPermission permission = all.next();                
+                if (permission.getType().equals(PermissionFactory.FOLDER_PERMISSION))
                 {
                     folders.add(new PermissionData(permission));                    
                 }
-                else if (permission.getClassname().equals(CLASSNAMES[1]))
+                else if (permission.getType().equals(PermissionFactory.PAGE_PERMISSION))
                 {
                     pages.add(new PermissionData(permission));
                 }
-                else if (permission.getClassname().equals(CLASSNAMES[2]))
+                else if (permission.getType().equals(PermissionFactory.PORTLET_PERMISSION))
                 {
                     portlets.add(new PermissionData(permission));
                 }                
@@ -153,15 +156,7 @@
         context.put("folderPermissions", folderPermissions);
         context.put("pagePermissions", pagePermissions);
         context.put("portletPermissions", portletPermissions);
-        ArrayList rolesList = new ArrayList();
-        if ( roles != null )
-        {
-            while( roles.hasNext() )
-            {
-                rolesList.add( roles.next() );
-            }
-        }
-        context.put("roles", rolesList);
+        context.put("roles", roles);
     }
     
     public void processAction(ActionRequest request,
@@ -171,24 +166,31 @@
 
     public class PermissionData
     {
-        public PermissionData(InternalPermission permission)
+        public PermissionData(JetspeedPermission permission)
         {
             this.permission = permission;
-            this.roles = ""; 
-            int size = permission.getPrincipals().size(); 
+            this.roles = "";
+            List<JetspeedPrincipal> principals = null;
+            try
+            {
+                principals = pm.getPrincipals(permission);
+            }
+            catch (SecurityException e)
+            {
+                logger.error(e);
+                return;
+            }
+            int size = principals.size();
             if (size == 0)
             {
                 return;
             }
-            Iterator principals = permission.getPrincipals().iterator();
             int count = 0;
             StringBuffer result = new StringBuffer();
-            while (principals.hasNext())
+            for (JetspeedPrincipal principal : principals)
             {
-                InternalPrincipal principal = (InternalPrincipal)principals.next();
-                int last = principal.getFullPath().lastIndexOf("/") + 1;
-                result.append(principal.getFullPath().substring(last));            
                 count++;
+                result.append(principal.getName());
                 if (count < size)
                 {
                     result.append(",");
@@ -197,15 +199,15 @@
             this.roles = result.toString();
         }
         
-        InternalPermission permission;
+        JetspeedPermission permission;
         String roles;
         
-        public InternalPermission getPermission()
+        public JetspeedPermission getPermission()
         {
             return permission;
         }
         
-        public void setPermission(InternalPermission permission)
+        public void setPermission(JetspeedPermission permission)
         {
             this.permission = permission;
         }

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdmin.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdmin.java?rev=695800&r1=695799&r2=695800&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdmin.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdmin.java
Tue Sep 16 02:59:26 2008
@@ -29,6 +29,7 @@
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.PasswordCredential;
 import org.apache.jetspeed.security.RoleManager;
+import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.wicket.RequestContext;
@@ -100,7 +101,7 @@
         return (PortalConfiguration) getPortletRequest().getAttribute(CommonPortletServices.CPS_PORTAL_CONFIGURATION);
     }
 
-    protected PasswordCredential getCredential(User user)
+    protected PasswordCredential getCredential(User user) throws SecurityException
     {        
     	return getUserManager().getPasswordCredential(user);
     	/*PasswordCredential credential = null;

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java?rev=695800&r1=695799&r2=695800&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
Tue Sep 16 02:59:26 2008
@@ -595,10 +595,11 @@
     private boolean modifyPref(String prefName, String keywords, PortletDefinitionComposite
portlet)
     {
         PreferenceComposite prefComp = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
-        String[] values = prefComp.getValueArray();
-        if(!values[0].equals(keywords))
+        List<String> values = prefComp.getValuesList();
+        if(!values.get(0).equals(keywords))
         {
-            prefComp.setValueAt(0, keywords);
+            values.set(0, keywords);
+            prefComp.setValues(values);
             return true;
         }
         return false;
@@ -636,10 +637,11 @@
             if (val > max)
                 return false;
             PreferenceComposite pref = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
-            String[] values = pref.getValueArray();
-            if(!values[0].equals(param))
+            List<String> values = pref.getValuesList();
+            if(!values.get(0).equals(param))
             {
-                pref.setValueAt(0, param);
+                values.set(0, param);
+                pref.setValues(values);
                 return true;
             }                           
         }



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


Mime
View raw message