You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by wo...@apache.org on 2008/09/08 16:03:29 UTC
svn commit: r693104 -
/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
Author: woonsan
Date: Mon Sep 8 07:03:27 2008
New Revision: 693104
URL: http://svn.apache.org/viewvc?rev=693104&view=rev
Log:
Flattening the Principal API.
Uses new constructor of UserImpl and RoleImpl which allow name argument.
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java?rev=693104&r1=693103&r2=693104&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java Mon Sep 8 07:03:27 2008
@@ -16,6 +16,7 @@
*/
package org.apache.jetspeed.profiler;
+import java.security.Principal;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -37,6 +38,9 @@
import org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule;
import org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule;
import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.AuthenticatedUser;
+import org.apache.jetspeed.security.AuthenticatedUserImpl;
+import org.apache.jetspeed.security.JetspeedSubjectFactory;
import org.apache.jetspeed.security.PrincipalsSet;
import org.apache.jetspeed.security.SecurityHelper;
import org.apache.jetspeed.security.impl.RoleImpl;
@@ -204,19 +208,10 @@
Set publicCredentials = new HashSet();
Set privateCredentials = new HashSet();
- UserImpl user = new UserImpl();
- user.setName("david");
- RoleImpl roleATP = new RoleImpl();
- roleATP.setName("ATP");
- RoleImpl roleNB = new RoleImpl();
- roleATP.setName("NB");
- RoleImpl roleATPNB = new RoleImpl();
- roleATPNB.setName("ATP-NB");
-
- principals.add(user);
- principals.add(roleATP);
- principals.add(roleNB);
- principals.add(roleATPNB);
+ principals.add(new UserImpl("david"));
+ principals.add(new RoleImpl("ATP"));
+ principals.add(new RoleImpl("NB"));
+ principals.add(new RoleImpl("ATP-NB"));
Subject subject = new Subject(true, principals, publicCredentials, privateCredentials);
return subject;
@@ -227,17 +222,10 @@
Set principals = new PrincipalsSet();
Set publicCredentials = new HashSet();
Set privateCredentials = new HashSet();
-
- UserImpl user = new UserImpl();
- user.setName("david");
- RoleImpl roleATP = new RoleImpl();
- roleATP.setName("ATP");
- RoleImpl roleNB = new RoleImpl();
- roleATP.setName("NB");
-
- principals.add(user);
- principals.add(roleATP);
- principals.add(roleNB);
+
+ principals.add(new UserImpl("david"));
+ principals.add(new RoleImpl("ATP"));
+ principals.add(new RoleImpl("NB"));
Subject subject = new Subject(true, principals, publicCredentials, privateCredentials);
return subject;
@@ -259,9 +247,7 @@
assertTrue("default rule class not mapped", rule instanceof StandardProfilingRule);
// Test anonymous principal-rule
- UserImpl user = new UserImpl();
- user.setName("anon");
- ProfilingRule anonRule = profiler.getRuleForPrincipal(user,
+ ProfilingRule anonRule = profiler.getRuleForPrincipal(new UserImpl("anon"),
ProfileLocator.PAGE_LOCATOR);
assertNotNull("anonymous rule is null", anonRule);
assertTrue("anonymous rule is j1", anonRule.getId().equals(DEFAULT_RULE));
@@ -393,8 +379,7 @@
assertNotNull("profiler service is null", profiler);
RequestContext request = new MockRequestContext("default-other");
-
- request.setSubject(SecurityHelper.createSubject("anon"));
+ request.setSubject(JetspeedSubjectFactory.createSubject(new UserImpl("anon"), null, null, null));
request.setLocale(new Locale("en", "US"));
request.setMediaType("HTML");
request.setMimeType("text/html");
@@ -479,7 +464,7 @@
RequestContext request = new MockRequestContext();
- request.setSubject(SecurityHelper.createSubject("anon"));
+ request.setSubject(JetspeedSubjectFactory.createSubject(new UserImpl("anon"), null, null, null));
request.setLocale(new Locale("en", "US"));
request.setMediaType("HTML");
request.setMimeType("text/html");
@@ -505,9 +490,7 @@
public void testGetLocatorNames() throws Exception
{
assertNotNull("profiler service is null", profiler);
- UserImpl user = new UserImpl();
- user.setName("guest");
- String[] result = profiler.getLocatorNamesForPrincipal(user);
+ String[] result = profiler.getLocatorNamesForPrincipal(new UserImpl("guest"));
for (int ix = 0; ix < result.length; ix++)
{
System.out.println("$$$ result = " + result[ix]);
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org