Author: woonsan
Date: Tue Sep 2 08:20:02 2008
New Revision: 691274
URL: http://svn.apache.org/viewvc?rev=691274&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-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserListAction.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.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/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestGroupManager.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestRoleManager.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestUserManager.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/attributes/TestSecurityAttributes.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-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java
Tue Sep 2 08:20:02 2008
@@ -80,7 +80,7 @@
User user = userManager.getUser(principal.getName());
if(user != null)
{
- Map<String, String> userInfo = user.getUserAttributes();
+ Map<String, String> userInfo = user.getUserInfo();
resultMap.put(USERINFO, userInfo);
List roles = new ArrayList();
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserListAction.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserListAction.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserListAction.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserListAction.java
Tue Sep 2 08:20:02 2008
@@ -300,7 +300,7 @@
User user = userManager.getUser(username);
if(user != null)
{
- return user.getUserAttributes();
+ return user.getUserInfo();
}
return new HashMap<String, String>();
}
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
Tue Sep 2 08:20:02 2008
@@ -38,8 +38,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.SecurityAttribute;
+import org.apache.jetspeed.security.SecurityAttributes;
import org.apache.jetspeed.util.JetspeedLocale;
/**
@@ -118,11 +118,11 @@
&& userMgr.userExists(userPrincipal.getName()))
{
User user =
userMgr.getUser(userPrincipal.getName());
- Map<String, SecurityAttribute> sa =
user.getAttributes().getAttributes(SecurityAttributes.SECURITY_ATTRIBUTE);
+ Map<String, SecurityAttribute> sa =
user.getSecurityAttributes().getInfoAttributeMap();
SecurityAttribute attrib =
sa.get(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);
if (attrib != null)
{
- String localeString = attrib.getValue();
+ String localeString = attrib.getStringValue();
if (localeString != null)
{
locale =
JetspeedLocale.convertStringToLocale(localeString);
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
Tue Sep 2 08:20:02 2008
@@ -191,7 +191,7 @@
try
{
User user = userManager.getUser(_user.getName());
- Principal principal = user.getUserPrincipal();
+
if (jsRules != null)
{
Iterator _itRoles = jsRules.iterator();
@@ -205,7 +205,7 @@
PrincipalRule p1 = pm.createPrincipalRule();
p1.setLocatorName(pr.getLocator());
p1.setProfilingRule(pRule);
- p1.setPrincipalName(principal.getName());
+ p1.setPrincipalName(user.getName());
pm.storePrincipalRule(p1);
}
catch (Exception eRole)
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=691274&r1=691273&r2=691274&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 08:20:02 2008
@@ -16,16 +16,21 @@
*/
package org.apache.jetspeed.security.impl;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+
import javax.security.auth.Subject;
+import org.apache.jetspeed.security.SecurityAttribute;
+import org.apache.jetspeed.security.SecurityAttributes;
import org.apache.jetspeed.security.User;
-import org.apache.jetspeed.security.UserSubjectPrincipal;
/**
* <p>Represents a security 'user' extending BaseJetspeedPrincipal.</p>
* @version $Id$
*/
-public class UserImpl extends BaseJetspeedPrincipal implements User,
UserSubjectPrincipal
+public class UserImpl extends BaseJetspeedPrincipal implements User
{
private static final long serialVersionUID = 5484179899807809619L;
@@ -47,5 +52,18 @@
{
this.subject = subject;
}
+
+ public Map<String, String> getUserInfo()
+ {
+ Map<String, String> userInfo = new HashMap<String, String>();
+ Map<String, SecurityAttribute> infoAttrMap =
super.getSecurityAttributes().getInfoAttributeMap();
+
+ for (SecurityAttribute attr : infoAttrMap.values())
+ {
+ userInfo.put(attr.getName(), attr.getStringValue());
+ }
+
+ return userInfo;
+ }
}
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
Tue Sep 2 08:20:02 2008
@@ -46,8 +46,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.SecurityAttribute;
+import org.apache.jetspeed.security.SecurityAttributes;
import org.apache.jetspeed.security.om.InternalGroupPrincipal;
import org.apache.jetspeed.security.om.InternalPermission;
import org.apache.jetspeed.security.om.InternalPrincipal;
@@ -318,7 +318,7 @@
JSUserAttributes attributes = jsuser.getUserInfo();
if (attributes != null)
{
- Map <String, SecurityAttribute> userInfo =
user.getAttributes().getAttributes(SecurityAttributes.USER_INFORMATION);
+ Map <String, SecurityAttribute> userInfo =
user.getSecurityAttributes().getInfoAttributeMap();
List<JSNVPElement> values = attributes.getValues();
if (values != null)
{
@@ -341,7 +341,7 @@
}
}
}
- refs.userMap.put(jsuser.getName(),
user.getUserPrincipal());
+ refs.userMap.put(jsuser.getName(), (Principal) user);
userManager.updateUser(user);
}
}
@@ -530,7 +530,7 @@
try
{
JSRole _tempRole = (JSRole)
getObjectBehindPrinicpal(refs.roleMap,
- (BasePrincipal) (role.getPrincipal()));
+ (BasePrincipal) role);
if (_tempRole == null)
{
_tempRole = createJSRole(role);
@@ -550,8 +550,7 @@
try
{
- JSGroup _tempGroup = (JSGroup)
getObjectBehindPrinicpal(refs.groupMap, (BasePrincipal) (group
- .getPrincipal()));
+ JSGroup _tempGroup = (JSGroup)
getObjectBehindPrinicpal(refs.groupMap, (BasePrincipal) group);
if (_tempGroup == null)
{
_tempGroup = createJSGroup(group);
@@ -686,7 +685,7 @@
private JSRole createJSRole(Role role)
{
JSRole _role = new JSRole();
- _role.setName(role.getPrincipal().getName());
+ _role.setName(role.getName());
return _role;
}
@@ -696,7 +695,7 @@
private JSGroup createJSGroup(Group group)
{
JSGroup _group = new JSGroup();
- _group.setName(group.getPrincipal().getName());
+ _group.setName(group.getName());
return _group;
}
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestGroupManager.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestGroupManager.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestGroupManager.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestGroupManager.java
Tue Sep 2 08:20:02 2008
@@ -262,10 +262,7 @@
assertTrue("group exists. should not have thrown an exception.",
false);
}
assertNotNull("group is null", group);
- // Test the Principal.
- Principal groupPrincipal = group.getPrincipal();
- assertNotNull("group principal is null", groupPrincipal);
- assertEquals("expected group principal full path == testgetgroup",
"testgetgroup", groupPrincipal.getName());
+ assertEquals("expected group principal full path == testgetgroup",
"testgetgroup", group.getName());
// Cleanup test.
try
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestRoleManager.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestRoleManager.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestRoleManager.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestRoleManager.java
Tue Sep 2 08:20:02 2008
@@ -262,10 +262,7 @@
assertTrue("role exists. should not have thrown an exception.",
false);
}
assertNotNull("role is null", role);
- // Test the Principal.
- Principal rolePrincipal = role.getPrincipal();
- assertNotNull("role principal is null", rolePrincipal);
- assertEquals("expected role principal full path name == testgetrole",
"testgetrole", rolePrincipal.getName());
+ assertEquals("expected role principal full path name == testgetrole",
"testgetrole", role.getName());
// Cleanup test.
try
@@ -552,7 +549,7 @@
Collection<Role> roles = rms.getRoles("");
for (Role role : roles)
{
- System.out.println("Role = " + role.getPrincipal().getName());
+ System.out.println("Role = " + role.getName());
roleCount++;
}
ums.addUser("notme", "one-pw");
@@ -567,7 +564,7 @@
roles = rms.getRoles("");
for (Role role : roles)
{
- System.out.println("* Role = " + role.getPrincipal().getName());
+ System.out.println("* Role = " + role.getName());
count++;
}
ums.removeUser("notme");
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestUserManager.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestUserManager.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestUserManager.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestUserManager.java
Tue Sep 2 08:20:02 2008
@@ -172,7 +172,7 @@
Collection<Role> roles = rms.getRolesForUser("inheritedUser");
for (Role role : roles)
{
- userRoleNames.add(role.getPrincipal().getName());
+ userRoleNames.add(role.getName());
}
assertFalse("role 'assignedRole' is not expected to be retrieved
because the role 'assignedRole' is not directly assigned to user
'inheritedUser'.", userRoleNames.contains("assignedRole"));
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/attributes/TestSecurityAttributes.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/attributes/TestSecurityAttributes.java?rev=691274&r1=691273&r2=691274&view=diff
==============================================================================
---
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/attributes/TestSecurityAttributes.java
(original)
+++
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/attributes/TestSecurityAttributes.java
Tue Sep 2 08:20:02 2008
@@ -29,10 +29,9 @@
{
ums.addUser("david", "secret");
}
- User david = ums.getUser("david");
+ User user = ums.getUser("david");
SecurityAttributesProvider sap =
(SecurityAttributesProvider)scm.getComponent("SecurityAttributesProvider");
assertNotNull(sap);
- UserPrincipal user = david.getUserPrincipal();
// create 3 attributes
SecurityAttributes sa = sap.createSecurityAttributes(user);
Map<String,SecurityAttribute> attributes = sa.getAttributes();
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=691274&r1=691273&r2=691274&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 08:20:02 2008
@@ -16,10 +16,35 @@
*/
package org.apache.jetspeed.security;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+
/**
* <p>User simply extending JetspeedPrincipal interface.</p>
* @version $Id
*/
public interface User extends JetspeedPrincipal
{
+
+ /**
+ * <p>Getter for the user [EMAIL PROTECTED] Subject} populated with the
+ * application principals.</p>
+ * @return The [EMAIL PROTECTED] Subject}.
+ */
+ Subject getSubject();
+
+ /**
+ * <p>Setter for the user [EMAIL PROTECTED] Subject} populated with the
+ * application principals.</p>
+ * @param subject The [EMAIL PROTECTED] Subject}.
+ */
+ void setSubject(Subject subject);
+
+ /**
+ * Get the Portlet API User Attributes for a given user
+ * @return a READ ONLY set of user attributes for a given user
+ */
+ Map<String, String> getUserInfo();
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]