taylor 2002/07/15 14:40:59
Modified: build build.xml
src/java/org/apache/jetspeed/services/security
JetspeedSecurityCache.java SecurityCacheImpl.java
SecurityCacheService.java
webapp/WEB-INF/conf JetspeedSecurity.default
JetspeedSecurity.properties
JetspeedSecurity.template
webapp/WEB-INF/db jetspeed.properties jetspeed.script
Added: src/java/org/apache/jetspeed/services/security
CachedAcl.java CachedRole.java
TestSecurityCache.java
Log:
- Completed Security cache implementation.
- added unit test for security cache
Revision Changes Path
1.148 +2 -2 jakarta-jetspeed/build/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/build/build.xml,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- build.xml 5 Jul 2002 03:37:28 -0000 1.147
+++ build.xml 15 Jul 2002 21:40:58 -0000 1.148
@@ -951,10 +951,10 @@
<test
name="org.apache.jetspeed.services.security.TestPermissionManagement"/>
+ <test name="org.apache.jetspeed.services.security.TestSecurityCache"/>
+
</junit>
</target>
-
-
<!-- =================================================================== -->
<!-- Run the client JUnit test cases (non-cactus) -->
1.3 +21 -21
jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedSecurityCache.java
Index: JetspeedSecurityCache.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedSecurityCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JetspeedSecurityCache.java 28 Jun 2002 05:37:34 -0000 1.2
+++ JetspeedSecurityCache.java 15 Jul 2002 21:40:58 -0000 1.3
@@ -114,65 +114,65 @@
}
- public static Role getRole(String roleName)
+ public static Role getRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
- return getService().getRole(roleName);
+ return getService().getRole(user, roleName);
}
- public static void addRole(Role role)
+ public static void addRole(JetspeedUser user, Role role)
throws JetspeedSecurityException
{
- getService().addRole(role);
+ getService().addRole(user, role);
}
- public static boolean hasRole(String roleName)
+ public static boolean hasRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
- return getService().hasRole(roleName);
+ return getService().hasRole(user, roleName);
}
- public static void removeRole(String roleName)
+ public static void removeRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
- getService().removeRole(roleName);
+ getService().removeRole(user, roleName);
}
- public static Iterator getRoles()
+ public static Iterator getRoles(JetspeedUser user)
throws JetspeedSecurityException
{
- return getService().getRoles();
+ return getService().getRoles(user);
}
- public static Permission getPermission(String permissionName)
+ public static Permission getPermission(JetspeedUser user, String roleName,
String permissionName)
throws JetspeedSecurityException
{
- return getService().getPermission(permissionName);
+ return getService().getPermission(user, roleName, permissionName);
}
- public static void addPermission(Permission permission)
+ public static void addPermission(JetspeedUser user, String roleName, Permission
permission)
throws JetspeedSecurityException
{
- getService().addPermission(permission);
+ getService().addPermission(user, roleName, permission);
}
- public static boolean hasPermission(String permissionName)
+ public static boolean hasPermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException
{
- return getService().hasPermission(permissionName);
+ return getService().hasPermission(user, roleName, permissionName);
}
- public static void removePermission(String permissionName)
+ public static void removePermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException
{
- getService().removePermission(permissionName);
+ getService().removePermission(user, roleName, permissionName);
}
- public static Iterator getPermissions()
+ public static Iterator getPermissions(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
- return getService().getPermissions();
+ return getService().getPermissions(user, roleName);
}
}
1.3 +96 -33
jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/SecurityCacheImpl.java
Index: SecurityCacheImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/SecurityCacheImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SecurityCacheImpl.java 28 Jun 2002 05:37:34 -0000 1.2
+++ SecurityCacheImpl.java 15 Jul 2002 21:40:58 -0000 1.3
@@ -84,7 +84,7 @@
public class SecurityCacheImpl extends TurbineBaseService
implements SecurityCacheService
{
- protected Map roleMap = new HashMap();
+ protected Map acls = new HashMap();
/*
@@ -106,83 +106,146 @@
*/
public void load(JetspeedUser user)
throws JetspeedSecurityException
- {
- roleMap.clear();
-
- Iterator roles = JetspeedSecurity.getRoles(user.getUserName());
- while (roles.hasNext())
- {
- Role role = (Role)roles.next();
- Vector perms = new Vector();
- Iterator permissions = JetspeedSecurity.getPermissions(role.getName());
- while (permissions.hasNext())
- {
- Permission permission = (Permission)permissions.next();
- perms.add(permission);
- }
- roleMap.put(role.getName(), perms);
- }
+ {
+ CachedAcl acl = new CachedAcl(user.getUserName());
+ acl.setRoles(JetspeedSecurity.getRoles(user.getUserName()));
+ acls.put(user.getUserName(), acl);
}
-
public void unload(JetspeedUser user)
throws JetspeedSecurityException
{
+ acls.remove(user.getUserName());
}
- public Role getRole(String roleName)
+ public Role getRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (acl == null)
+ {
+ return null;
+ }
+ CachedRole crole = (CachedRole)acl.getRole(roleName);
+ if (null != crole)
+ {
+ return crole.getRole();
+ }
return null;
}
- public void addRole(Role role)
+ public void addRole(JetspeedUser user, Role role)
throws JetspeedSecurityException
{
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ acl.addRole(new CachedRole(role));
+ }
}
- public boolean hasRole(String roleName)
+ public boolean hasRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
- return roleMap.containsKey(roleName);
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ return acl.hasRole(roleName);
+ }
+ return false;
}
- public void removeRole(String roleName)
+ public void removeRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ acl.removeRole(roleName);
+ }
}
- public Iterator getRoles()
+ public Iterator getRoles(JetspeedUser user)
throws JetspeedSecurityException
{
- return null;
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ return acl.getRoles();
+ }
+ return null;
}
- public Permission getPermission(String permissionName)
+ public Permission getPermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException
- {
- return null;
+ {
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ CachedRole crole = (CachedRole)acl.getRole(roleName);
+ if (null != crole)
+ {
+ return crole.getPermission(permissionName);
+ }
+ }
+ return null;
}
- public void addPermission(Permission permission)
+ public void addPermission(JetspeedUser user, String roleName, Permission
permission)
throws JetspeedSecurityException
{
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ CachedRole crole = (CachedRole)acl.getRole(roleName);
+ if (null != crole)
+ {
+ crole.addPermission(permission);
+ }
+ }
}
- public boolean hasPermission(String permissionName)
+ public boolean hasPermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException
{
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ CachedRole crole = (CachedRole)acl.getRole(roleName);
+ if (null != crole)
+ {
+ return crole.hasPermission(permissionName);
+ }
+ }
return false;
}
- public void removePermission(String permissionName)
+ public void removePermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException
{
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ CachedRole crole = (CachedRole)acl.getRole(roleName);
+ if (null != crole)
+ {
+ crole.removePermission(permissionName);
+ }
+ }
}
- public Iterator getPermissions()
+ public Iterator getPermissions(JetspeedUser user, String roleName)
throws JetspeedSecurityException
{
+ CachedAcl acl = (CachedAcl)acls.get(user.getUserName());
+ if (null != acl)
+ {
+ CachedRole crole = (CachedRole)acl.getRole(roleName);
+ if (null != crole)
+ {
+ return crole.getPermissions();
+ }
+ }
return null;
}
1.3 +11 -11
jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/SecurityCacheService.java
Index: SecurityCacheService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/SecurityCacheService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SecurityCacheService.java 28 Jun 2002 05:37:34 -0000 1.2
+++ SecurityCacheService.java 15 Jul 2002 21:40:58 -0000 1.3
@@ -94,35 +94,35 @@
- public Role getRole(String roleName)
+ public Role getRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException;
- public void addRole(Role role)
+ public void addRole(JetspeedUser user, Role role)
throws JetspeedSecurityException;
- public boolean hasRole(String roleName)
+ public boolean hasRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException;
- public void removeRole(String roleName)
+ public void removeRole(JetspeedUser user, String roleName)
throws JetspeedSecurityException;
- public Iterator getRoles()
+ public Iterator getRoles(JetspeedUser user)
throws JetspeedSecurityException;
- public Permission getPermission(String permissionName)
+ public Permission getPermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException;
- public void addPermission(Permission role)
+ public void addPermission(JetspeedUser user, String roleName, Permission
permission)
throws JetspeedSecurityException;
- public boolean hasPermission(String permissionName)
+ public boolean hasPermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException;
- public void removePermission(String permissionName)
+ public void removePermission(JetspeedUser user, String roleName, String
permissionName)
throws JetspeedSecurityException;
- public Iterator getPermissions()
+ public Iterator getPermissions(JetspeedUser user, String roleName)
throws JetspeedSecurityException;
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/CachedAcl.java
Index: CachedAcl.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.security;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.turbine.util.Log;
import org.apache.jetspeed.om.security.Role;
import org.apache.jetspeed.om.security.Permission;
import org.apache.jetspeed.om.security.JetspeedUser;
import org.apache.jetspeed.services.JetspeedSecurity;
import org.apache.jetspeed.services.security.JetspeedSecurityException;
/**
* Cached ACL - default implementation cached ACL containing role/permission.
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id: CachedAcl.java,v 1.1 2002/07/15 21:40:58 taylor Exp $
*/
public class CachedAcl
{
protected String userName;
protected HashMap roles = new HashMap();
public CachedAcl(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return this.userName;
}
public Iterator getRoles()
{
return roles.values().iterator();
}
public void setRoles(Iterator roles)
{
try
{
while (roles.hasNext())
{
Role role = (Role)roles.next();
CachedRole acl = new CachedRole(role);
acl.setPermissions(JetspeedSecurity.getPermissions(role.getName()));
this.roles.put(acl.getRole().getName(), acl);
}
}
catch (JetspeedSecurityException e)
{
Log.error(e);
}
}
public CachedRole getRole(String roleName)
{
CachedRole role = (CachedRole)roles.get(roleName);
return role;
}
public void addRole(CachedRole role)
{
roles.put(role.getRole().getName(), role);
}
public boolean hasRole(String roleName)
{
return roles.containsKey(roleName);
}
public void removeRole(String roleName)
{
roles.remove(roleName);
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/CachedRole.java
Index: CachedRole.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.security;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.jetspeed.om.security.Role;
import org.apache.jetspeed.om.security.Permission;
/**
* Cached Role - default implementation cached Role.
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id: CachedRole.java,v 1.1 2002/07/15 21:40:58 taylor Exp $
*/
public class CachedRole
{
protected Role role;
protected HashMap permissions = new HashMap();
public CachedRole(Role role)
{
this.role = role;
}
public Role getRole()
{
return this.role;
}
public Iterator getPermissions()
{
return permissions.values().iterator();
}
public void setPermissions(Iterator perms)
{
while (perms.hasNext())
{
Permission permission = (Permission)perms.next();
this.permissions.put(permission.getName(), permission);
}
}
public Permission getPermission(String permissionName)
{
return (Permission)permissions.get(permissionName);
}
public void addPermission(Permission permission)
{
permissions.put(permission.getName(), permission);
}
public boolean hasPermission(String permissionName)
{
return this.permissions.containsKey(permissionName);
}
public void removePermission(String permissionName)
{
permissions.remove(permissionName);
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/TestSecurityCache.java
Index: TestSecurityCache.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.security;
import java.util.Iterator;
import java.util.HashMap;
// Junit imports
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.framework.TestCase;
import org.apache.turbine.services.TurbineServices;
import org.apache.stratum.configuration.Configuration;
import org.apache.turbine.util.TurbineConfig;
import org.apache.turbine.util.StringUtils;
import org.apache.jetspeed.services.JetspeedSecurity;
import org.apache.jetspeed.om.security.Role;
import org.apache.jetspeed.om.security.Permission;
import org.apache.jetspeed.om.security.JetspeedUser;
import org.apache.jetspeed.om.security.JetspeedRoleFactory;
/**
* Unit test for SecurityCacheService
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id: TestSecurityCache.java,v 1.1 2002/07/15 21:40:58 taylor Exp $
*/
public class TestSecurityCache extends TestCase {
/**
* Defines the testcase name for JUnit.
*
* @param name the testcase's name.
*/
public TestSecurityCache( String name ) {
super( name );
}
/**
* Start the tests.
*
* @param args the arguments. Not used
*/
public static void main(String args[])
{
junit.awtui.TestRunner.main( new String[] {
TestSecurityCache.class.getName() } );
}
public void setup()
{
//System.out.println("Setup: Testing Turbine Role Management");
}
/**
* Creates the test suite.
*
* @return a test suite (<code>TestSuite</code>) that includes all methods
* starting with "test"
*/
public static Test suite()
{
// All methods starting with "test" will be executed in the test suite.
return new TestSuite( TestSecurityCache.class );
}
/**
* Tests getRoles method
* @throws Exception
*/
public void testLoadCache() throws Exception
{
SecurityCacheService service = getService();
try
{
JetspeedUser user = JetspeedSecurity.getUser("turbine");
service.load(user);
Role role = service.getRole(user, "user");
assertTrue(role.getName().equals("user"));
assertTrue(service.hasRole(user, "user"));
assertTrue(service.hasPermission(user, "user", "view"));
assertTrue(service.hasPermission(user, "user", "customize"));
assertTrue(service.hasPermission(user, "user", "maximize"));
assertTrue(!service.hasPermission(user, "user", "failure"));
}
catch (Exception e)
{
fail(StringUtils.stackTrace(e));
}
System.out.println("Completed loadCache Test OK ");
}
public void testAddRemoveFromCache() throws Exception
{
SecurityCacheService service = getService();
try
{
JetspeedUser user = JetspeedSecurity.getUser("anon");
service.load(user);
Role role1 = service.getRole(user, "guest");
assertTrue(role1.getName().equals("guest"));
assertTrue(service.hasPermission(user, "guest", "view"));
// add role
Role role2 = JetspeedSecurity.getRole("user");
service.addRole(user, role2);
assertTrue(service.hasRole(user, "user"));
assertTrue(service.getRole(user,"user").getName().equals("user"));
// remove role
service.removeRole(user, "user");
assertTrue(!service.hasRole(user, "user"));
Role role3 = service.getRole(user,"user");
assertTrue(null == role3);
// add permission
Permission perm1 = JetspeedSecurity.getPermission("detach");
assertTrue(null != perm1);
service.addPermission(user, "guest", perm1);
Permission permission = service.getPermission(user, "guest", "detach");
assertTrue(permission.getName().equals("detach"));
assertTrue(service.hasPermission(user, "guest", "detach"));
// remove permission
service.removePermission(user, "guest", "detach");
assertTrue(!service.hasPermission(user, "guest", "detach"));
Permission perm2 = service.getPermission(user, "guest", "detach");
assertTrue(null == perm2);
}
catch (Exception e)
{
fail(StringUtils.stackTrace(e));
}
System.out.println("Completed addRemoveFromCache Test OK ");
}
/*
Configuration object to run Turbine outside a servlet container
( uses turbine.properties )
*/
private static TurbineConfig config = null;
/**
Sets up TurbineConfig using the system property:
<pre>turbine.properties</pre>
*/
static
{
try
{
config = new TurbineConfig( "../webapp",
"/WEB-INF/conf/TurbineResources.properties");
config.init();
}
catch (Exception e)
{
fail(StringUtils.stackTrace(e));
}
}
private static SecurityCacheService getService()
{
return (SecurityCacheService)TurbineServices
.getInstance()
.getService(SecurityCacheService.SERVICE_NAME);
}
}
1.3 +7 -1 jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.default
Index: JetspeedSecurity.default
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.default,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JetspeedSecurity.default 28 Jun 2002 05:37:37 -0000 1.2
+++ JetspeedSecurity.default 15 Jul 2002 21:40:58 -0000 1.3
@@ -40,3 +40,9 @@
services.GroupManagement.classname=org.apache.jetspeed.services.security.turbine.TurbineGroupManagement
+#########################################
+# Security Cache Service #
+#########################################
+
+services.SecurityCache.classname=org.apache.jetspeed.services.security.SecurityCacheImpl
+
1.6 +6 -0 jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.properties
Index: JetspeedSecurity.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JetspeedSecurity.properties 5 Jul 2002 03:38:03 -0000 1.5
+++ JetspeedSecurity.properties 15 Jul 2002 21:40:58 -0000 1.6
@@ -55,6 +55,12 @@
services.PermissionManagement.classname=org.apache.jetspeed.services.security.turbine.TurbinePermissionManagement
services.JetspeedSecurity.permission.class=org.apache.jetspeed.om.security.BaseJetspeedPermission
+#########################################
+# Security Cache Service #
+#########################################
+
+services.SecurityCache.classname=org.apache.jetspeed.services.security.SecurityCacheImpl
+
# -------------------------------------------------------------------
#
# UserManagement Services
1.3 +7 -1 jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.template
Index: JetspeedSecurity.template
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.template,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JetspeedSecurity.template 28 Jun 2002 05:37:37 -0000 1.2
+++ JetspeedSecurity.template 15 Jul 2002 21:40:58 -0000 1.3
@@ -55,6 +55,12 @@
services.PermissionManagement.classname=org.apache.jetspeed.services.security.turbine.TurbinePermissionManagement
services.JetspeedSecurity.permission.class=org.apache.jetspeed.om.security.BaseJetspeedPermission
+#########################################
+# Security Cache Service #
+#########################################
+
+services.SecurityCache.classname=org.apache.jetspeed.services.security.SecurityCacheImpl
+
# -------------------------------------------------------------------
#
# UserManagement Services
1.13 +1 -1 jakarta-jetspeed/webapp/WEB-INF/db/jetspeed.properties
Index: jetspeed.properties
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/db/jetspeed.properties,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- jetspeed.properties 28 Jun 2002 05:37:37 -0000 1.12
+++ jetspeed.properties 15 Jul 2002 21:40:58 -0000 1.13
@@ -1,4 +1,4 @@
#Hypersonic SQL database
-#Thu Jun 27 22:29:37 PDT 2002
+#Mon Jul 15 14:21:50 PDT 2002
version=1.4
modified=yes
1.16 +6 -5 jakarta-jetspeed/webapp/WEB-INF/db/jetspeed.script
Index: jetspeed.script
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/db/jetspeed.script,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- jetspeed.script 28 Jun 2002 05:37:37 -0000 1.15
+++ jetspeed.script 15 Jul 2002 21:40:58 -0000 1.16
@@ -130,10 +130,11 @@
INSERT INTO TURBINE_USER_GROUP_ROLE VALUES(380,1,1)
INSERT INTO TURBINE_USER_GROUP_ROLE VALUES(390,1,1)
INSERT INTO TURBINE_USER_GROUP_ROLE VALUES(400,1,1)
-INSERT INTO ID_TABLE VALUES(1,'TURBINE_PERMISSION',280,10)
-INSERT INTO ID_TABLE VALUES(2,'TURBINE_ROLE',360,10)
-INSERT INTO ID_TABLE VALUES(3,'TURBINE_GROUP',290,10)
-INSERT INTO ID_TABLE VALUES(4,'TURBINE_USER',410,10)
+INSERT INTO TURBINE_USER_GROUP_ROLE VALUES(410,1,1)
+INSERT INTO ID_TABLE VALUES(1,'TURBINE_PERMISSION',290,10)
+INSERT INTO ID_TABLE VALUES(2,'TURBINE_ROLE',370,10)
+INSERT INTO ID_TABLE VALUES(3,'TURBINE_GROUP',300,10)
+INSERT INTO ID_TABLE VALUES(4,'TURBINE_USER',420,10)
INSERT INTO ID_TABLE VALUES(5,'TURBINE_SCHEDULED_JOB',100,10)
INSERT INTO ID_TABLE VALUES(6,'TURBINE_ROLE_PERMISSION',100,10)
INSERT INTO ID_TABLE VALUES(7,'TURBINE_USER_GROUP_ROLE',100,10)
@@ -152,4 +153,4 @@
INSERT INTO COFFEES VALUES('KenyanGrade',2,7.99,1,2)
INSERT INTO COFFEES VALUES('JoeGrade',3,7.99,1,2)
INSERT INTO COFFEES VALUES('CantThinkOfAnymoreGrade',4,7.99,1,2)
-/*C2*/CONNECT USER sa PASSWORD ""
+/*C1*/CONNECT USER sa PASSWORD ""
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>