portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r691314 - in /portals/jetspeed-2/portal/branches/security-refactoring: components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/ components/je...
Date Tue, 02 Sep 2008 16:42:43 GMT
Author: woonsan
Date: Tue Sep  2 09:42:42 2008
New Revision: 691314

URL: http://svn.apache.org/viewvc?rev=691314&view=rev
Log:
Flattening the Principal API.
Modified the existing classes to implement new interfaces.
Build is still broken. Manager components and some serialization tools need to be refined
more.

Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserManagerUserAttributeSourceImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/User.java

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java
Tue Sep  2 09:42:42 2008
@@ -30,12 +30,15 @@
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.PageManagerUtils;
 import org.apache.jetspeed.page.document.NodeException;
+import org.apache.jetspeed.security.AttributeAlreadyExistsException;
+import org.apache.jetspeed.security.AttributeTypeNotFoundException;
+import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.JSSubject;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
-import org.apache.jetspeed.security.attributes.SecurityAttribute;
-import org.apache.jetspeed.security.attributes.SecurityAttributes;
+import org.apache.jetspeed.security.SecurityAttribute;
+import org.apache.jetspeed.security.SecurityAttributes;
 import org.apache.jetspeed.serializer.objects.JSSnapshot;
 import org.apache.jetspeed.serializer.objects.JSUser;
 
@@ -149,9 +152,12 @@
                 {
                     if (innerSubsite != null)
                     {
-                        User innerUser = userManager.getUser(innerUserName);            
      
-                        Map<String, SecurityAttribute> attributes = innerUser.getAttributes().getAttributes(SecurityAttributes.USER_INFORMATION);
-                        attributes.put(User.USER_INFO_SUBSITE, innerUser.getAttributes().createAttribute(User.USER_INFO_SUBSITE,
innerSubsite));
+                        User innerUser = userManager.getUser(innerUserName);
+                        SecurityAttributes userAttrs = innerUser.getSecurityAttributes();
+                        Map<String, SecurityAttribute> attributes = userAttrs.getInfoAttributeMap();
+                        SecurityAttribute userAttr = userAttrs.addAttribute(User.USER_INFO_SUBSITE);
+                        userAttr.setStringValue(innerSubsite);
+                        attributes.put(User.USER_INFO_SUBSITE, userAttr);
                         userManager.updateUser(innerUser);
                     }
                     Folder source = innerPageManager.getFolder(innerFolderTemplate);
@@ -178,6 +184,18 @@
                 {
                     se.printStackTrace();
                     return se;                    
+                } 
+                catch (AttributesReadOnlyException ae)
+                {
+                    return ae;
+                } 
+                catch (AttributeTypeNotFoundException ae)
+                {
+                    return ae;
+                } 
+                catch (AttributeAlreadyExistsException ae)
+                {
+                    return ae;
                 }
             }
         }, null);

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
Tue Sep  2 09:42:42 2008
@@ -44,6 +44,9 @@
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
 import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.AttributeAlreadyExistsException;
+import org.apache.jetspeed.security.AttributeTypeNotFoundException;
+import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.JSSubject;
 import org.apache.jetspeed.security.RoleManager;
@@ -52,9 +55,8 @@
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.UserPrincipal;
-import org.apache.jetspeed.security.attributes.SecurityAttribute;
-import org.apache.jetspeed.security.attributes.SecurityAttributes;
-import org.apache.jetspeed.security.attributes.SecurityAttributesProvider;
+import org.apache.jetspeed.security.SecurityAttribute;
+import org.apache.jetspeed.security.SecurityAttributes;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
 import org.springframework.mail.MailException;
@@ -219,11 +221,13 @@
             // assign user attributes to user
             if (userInfo != null)
             {
+                SecurityAttributes userAttrs = user.getSecurityAttributes();
                 Iterator info = userInfo.entrySet().iterator();
                 while (info.hasNext())
                 {           
                     Map.Entry entry = (Map.Entry)info.next();
-                    user.getUserAttributes().put((String)entry.getKey(), (String)entry.getValue());
+                    SecurityAttribute userAttr = userAttrs.addAttribute((String)entry.getKey());
+                    userAttr.setStringValue((String) entry.getValue());
                 }
             }
             
@@ -275,12 +279,13 @@
                 {
                     public Object run() 
                     {
-                         try
+                        try
                         {
                              if (innerSubsite != null)
                              {
-                                 Map<String, SecurityAttribute> attributes = innerUser.getAttributes().getAttributes(SecurityAttributes.USER_INFORMATION);
-                                 attributes.put(User.USER_INFO_SUBSITE, innerUser.getAttributes().createAttribute(User.USER_INFO_SUBSITE,
innerSubsite));
+                                 SecurityAttributes userAttrs = innerUser.getSecurityAttributes();
+                                 SecurityAttribute userAttr = userAttrs.addAttribute(User.USER_INFO_SUBSITE);
+                                 userAttr.setStringValue(innerSubsite);
                                  userManager.updateUser(innerUser);
                              }                                         
                              // create user's home folder                        
@@ -296,20 +301,34 @@
                              
                             return null;
                         }
-                         catch (SecurityException s1)
-                         {
-                             return s1;
-                         }
-                         catch (FolderNotFoundException e1) 
-                         {
-                             return e1;
-                         } catch (InvalidFolderException e1)
-                         {
-                             return e1;
-                         } catch (NodeException e1)
-                         {
-                             return e1;
-                         }
+                        catch (SecurityException s1)
+                        {
+                            return s1;
+                        }
+                        catch (FolderNotFoundException e1) 
+                        {
+                            return e1;
+                        }
+                        catch (InvalidFolderException e1)
+                        {
+                            return e1;
+                        }
+                        catch (NodeException e1)
+                        {
+                            return e1;
+                        } 
+                        catch (AttributesReadOnlyException e1)
+                        {
+                            return e1;
+                        } 
+                        catch (AttributeTypeNotFoundException e1)
+                        {
+                            return e1;
+                        } 
+                        catch (AttributeAlreadyExistsException e1)
+                        {
+                            return e1;
+                        }
                     }
                 }, null);
                 

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
Tue Sep  2 09:42:42 2008
@@ -19,6 +19,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.security.Permission;
+import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -793,7 +794,7 @@
                     if (!permissionManager.permissionExists(permission))
                     {
                         permissionManager.addPermission(permission);
-                        permissionManager.grantPermission(userRole.getPrincipal(), permission);
+                        permissionManager.grantPermission((Principal) userRole, permission);
                     }                    
                 }
             }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
Tue Sep  2 09:42:42 2008
@@ -212,7 +212,7 @@
                     if (userMgr.userExists(userPrincipal.getName()))
                     {
                         User user = userMgr.getUser(userPrincipal.getName());
-                        userInfo = user.getUserAttributes();
+                        userInfo = user.getUserInfo();
                     }
                 }
                 catch (SecurityException sex)

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserManagerUserAttributeSourceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserManagerUserAttributeSourceImpl.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserManagerUserAttributeSourceImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/userinfo/impl/UserManagerUserAttributeSourceImpl.java
Tue Sep  2 09:42:42 2008
@@ -79,7 +79,7 @@
                 if (userManager.userExists(userPrincipal.getName()))
                 {
                     User user = userManager.getUser(userPrincipal.getName());
-                    Map<String, String> userInfo = user.getUserAttributes();
+                    Map<String, String> userInfo = user.getUserInfo();
                     for (UserAttributeRef currentAttributeRef : userAttributeRefs)
                     {
                         String value = userInfo.get(currentAttributeRef.getName());

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/test/java/org/apache/jetspeed/userinfo/TestUserInfoManager.java
Tue Sep  2 09:42:42 2008
@@ -33,11 +33,11 @@
 import org.apache.jetspeed.mockobjects.request.MockRequestContext;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
 import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.SecurityAttribute;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.SecurityHelper;
 import org.apache.jetspeed.security.User;
-import org.apache.jetspeed.security.attributes.SecurityAttributes;
-import org.apache.jetspeed.security.attributes.SecurityAttributesProvider;
+import org.apache.jetspeed.security.SecurityAttributes;
 import org.apache.jetspeed.security.util.test.AbstractSecurityTestcase;
 import org.apache.jetspeed.util.descriptor.ExtendedPortletMetadata;
 import org.apache.jetspeed.util.descriptor.PortletApplicationDescriptor;
@@ -178,9 +178,13 @@
         {
             assertTrue("user exists. should not have thrown an exception.", false);
         }
-        SecurityAttributes attributes = user.getAttributes();
-        attributes.getAttributes(SecurityAttributes.USER_INFORMATION).put("user.name.given",
attributes.createAttribute("user.name.given", "Test Dude"));
-        attributes.getAttributes(SecurityAttributes.USER_INFORMATION).put("user.name.given",
attributes.createAttribute("user.name.family", "Dudley"));
+        SecurityAttributes attributes = user.getSecurityAttributes();
+        SecurityAttribute userAttr = attributes.addAttribute("user.name.given");
+        userAttr.setStringValue("Test Dude");
+        attributes.getInfoAttributeMap().put("user.name.given", userAttr);
+        userAttr = attributes.addAttribute("user.name.family");
+        userAttr.setStringValue("Dudley");
+        attributes.getInfoAttributeMap().put("user.name.family", userAttr);
         ums.updateUser(user);
     }
 

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserImpl.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserImpl.java
Tue Sep  2 09:42:42 2008
@@ -58,9 +58,9 @@
         Map<String, String> userInfo = new HashMap<String, String>();
         Map<String, SecurityAttribute> infoAttrMap = super.getSecurityAttributes().getInfoAttributeMap();
         
-        for (SecurityAttribute attr : infoAttrMap.values())
+        for (Map.Entry entry : infoAttrMap.entrySet())
         {
-            userInfo.put(attr.getName(), attr.getStringValue());
+            userInfo.put((String) entry.getKey(), ((SecurityAttribute) entry.getValue()).getStringValue());
         }
             
         return userInfo;

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/User.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/User.java?rev=691314&r1=691313&r2=691314&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/User.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/User.java
Tue Sep  2 09:42:42 2008
@@ -28,6 +28,11 @@
 {
     
     /**
+     * the subsite path for a given user stored as a user attribute
+     */
+    final static String USER_INFO_SUBSITE = "subsite";
+    
+    /**
      * <p>Getter for the user {@link Subject} populated with the 
      * application principals.</p>
      * @return The {@link Subject}.



---------------------------------------------------------------------
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