Package org.apache.jetspeed.om.security

Examples of org.apache.jetspeed.om.security.Permission


     * @throws Exception
     */
    public void testRevokePermission() throws Exception
    {
        PermissionManagement service = getService();
        Permission permission = null;
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            service.revokePermission("user", "close");
View Full Code Here


     * @throws Exception
     */
    public void testHasPermission() throws Exception
    {
        PermissionManagement service = getService();
        Permission permission = null;
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            boolean has = service.hasPermission("user", "view");
View Full Code Here

            assertTrue(!service.hasRole(user.getUserName(), "user"));
            Role role3 = service.getRole(user.getUserName(),"user");
            assertTrue(null == role3);

            // add permission
            Permission perm1 = JetspeedSecurity.getPermission("info");
            assertTrue(null != perm1);
            service.addPermission("guest", perm1);
            Permission permission = service.getPermission("guest", "info");
            assertTrue(permission.getName().equals("info"));
            assertTrue(service.hasPermission("guest", "info"));

            // remove permission
            service.removePermission("guest", "info");
            assertTrue(!service.hasPermission( "guest", "info"));
            Permission perm2 = service.getPermission( "guest", "info");
            assertTrue(null == perm2);

        }
        catch (Exception e)
        {
View Full Code Here

     */

    public void testGetPermissions() throws Exception
    {
        PermissionManagement service = getService();
        Permission permission = null;
        HashMap map = new HashMap();
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            Iterator permissions = service.getPermissions();
            while (permissions.hasNext())
            {
                permission = (Permission)permissions.next();
                map.put(permission.getName(), permission);
                //System.out.println("permission = " + permission.getName());
                //System.out.println("id = " + permission.getId());
            }
            assertTrue(map.get("view") != null);
            assertTrue(map.get("customize") != null);
View Full Code Here

     */

    public void testGetPermissionsForUser() throws Exception
    {
        PermissionManagement service = getService();
        Permission permission = null;
        HashMap map = new HashMap();
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            Iterator permissions = service.getPermissions("user");
            while (permissions.hasNext())
            {
                permission = (Permission)permissions.next();
                map.put(permission.getName(), permission);
            }
            assertTrue(map.get("view") != null);
            assertTrue(map.get("customize") != null);
            assertTrue(map.get("close") == null);

            map.clear();
            permissions = service.getPermissions("admin");           
            while (permissions.hasNext())
            {
                permission = (Permission)permissions.next();
                map.put(permission.getName(), permission);
            }
            assertTrue(map.get("view") != null);
            assertTrue(map.get("customize") != null);
            assertTrue(map.get("close") != null);

View Full Code Here

     */

    public void testAddPermission() throws Exception
    {
        PermissionManagement service = getService();
        Permission permission = null;
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            permission = JetspeedPermissionFactory.getInstance();
            permission.setName("bogus");
            service.addPermission(permission);
            System.out.println("new permission id = " + permission.getId());
            assertTrue(permission.getId() != null);
        }
        catch(Exception e)
        {
            fail(StringUtils.stackTrace(e));
        }
        try
        {
            permission = JetspeedPermissionFactory.getInstance();
            permission.setName("bogus");
            service.addPermission(permission);
            fail("Should've thrown a dup key exception on permission");
        }
        catch(Exception e)
        {
View Full Code Here

     */

    public void testRemovePermission() throws Exception
    {
        PermissionManagement service = getService();
        Permission permission = null;
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            service.removePermission("bogus");
View Full Code Here

        PermissionManagement service = getService();
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            Permission permission = service.getPermission("view");
            System.out.println("*** permission id = " + permission.getId());
            assertTrue(permission.getName().equals("view"));
        }
        catch (Exception e)
        {
            fail(StringUtils.stackTrace(e));
        }
View Full Code Here

        PermissionManagement service = getService();
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            Permission permission = service.getPermission("customize");
            service.savePermission(permission);
        }
        catch(Exception e)
        {
            fail(StringUtils.stackTrace(e));
View Full Code Here

     * @throws Exception
     */
    public void testGrantPermission() throws Exception
    {
        PermissionManagement service = getService();
        Permission permission = null;
        JetspeedSecurityCache.loadRolePermissions();

        try
        {
            service.grantPermission("user", "close");
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.security.Permission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.