Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.FolderPermission

This class represents access to a portal content/folder or document. A FolderPermission consists of a pathname and a set of actions valid for that pathname.

Pathname is the pathname of the folder or document granted the specified actions. A pathname that ends in "/*" (where "/" is the separator character) indicates all the folders and documents contained in that folder. A pathname that ends with "/-" indicates (recursively) all documents and subfolders contained in that directory. A pathname consisting of the special token "<<ALL FILES>>" matches any folder or document.

@author David Sean Taylor @author Christophe Lombart @version $Id: FolderPermission.java 516448 2007-03-09 16:25:47Z ate $


        {
        }
       
        UserPrincipal user = new UserPrincipalImpl("anon");

        FolderPermission perm1 = new FolderPermission("/files/test.xml", "edit");
        FolderPermission perm2 = new FolderPermission("/files/subfolder1/*", "view");
        FolderPermission perm3 = new FolderPermission("/files/subfolder2/-", "view");
        try
        {
            pms.addPermission(perm1);
            pms.addPermission(perm2);
            pms.addPermission(perm3);
View Full Code Here


     */
    protected void destroyUser() throws Exception
    {
        ums.removeUser("anon");

        FolderPermission perm1 = new FolderPermission("/files/test.xml", "edit");
        FolderPermission perm2 = new FolderPermission("/files/subfolder1/*", "view");
        FolderPermission perm3 = new FolderPermission("/files/subfolder2/-", "view");
        pms.removePermission(perm1);
        pms.removePermission(perm2);
        pms.removePermission(perm3);
    }
View Full Code Here

            {
                permissionPath += PATH_SEPARATOR + FOLDER_PERMISSION_WILD_CHAR;
            }
            try
            {
                FolderPermission permission = new FolderPermission(permissionPath, actions);
                AccessController.checkPermission(permission);
            }
            catch (SecurityException physicalSE)
            {
                // fallback check using logical path if available and different
                String logicalPermissionPath = getLogicalPermissionPath();
                if ((logicalPermissionPath != null) && !logicalPermissionPath.equals(physicalPermissionPath))
                {
                    permissionPath = logicalPermissionPath;
                    if (permissionPath.endsWith(PATH_SEPARATOR))
                    {
                        permissionPath += FOLDER_PERMISSION_WILD_CHAR;
                    }
                    else
                    {
                        permissionPath += PATH_SEPARATOR + FOLDER_PERMISSION_WILD_CHAR;
                    }
                    FolderPermission permission = new FolderPermission(permissionPath, actions);
                    AccessController.checkPermission(permission);
                }
                else
                {
                    throw physicalSE;
View Full Code Here

                    PagePermission permission = new PagePermission(permissionPath, actions);
                    AccessController.checkPermission(permission);
                }
                catch (SecurityException se)
                {
                    FolderPermission permission = new FolderPermission(permissionPath, actions);
                    AccessController.checkPermission(permission);
                }
            }
            catch (SecurityException physicalSE)
            {
                // fallback check using logical path if available and different
                String logicalPermissionPath = getLogicalPermissionPath();
                if ((logicalPermissionPath != null) && !logicalPermissionPath.equals(physicalPermissionPath))
                {
                    permissionPath = logicalPermissionPath;
                    try
                    {
                        PagePermission permission = new PagePermission(permissionPath, actions);
                        AccessController.checkPermission(permission);
                    }
                    catch (SecurityException se)
                    {
                        FolderPermission permission = new FolderPermission(permissionPath, actions);
                        AccessController.checkPermission(permission);
                    }
                }
                else
                {
View Full Code Here

            AccessController.checkPermission(permission);
        }
        catch (SecurityException se)
        {
            // fallback check for granted folder permissions
            FolderPermission permission = new FolderPermission(path, actions);
            AccessController.checkPermission(permission);
        }
    }
View Full Code Here

    {
        // check granted folder permissions unless the check is
        // to be skipped due to explicity granted access
        if (!checkParentsOnly)
        {
            FolderPermission permission = new FolderPermission(path, actions);
            AccessController.checkPermission(permission);
        }

        // if not checking node only, recursively check
        // all parent permissions in hierarchy
View Full Code Here

            AccessController.checkPermission(permission);
        }
        catch (SecurityException se)
        {
            // fallback check for granted folder permissions
            FolderPermission permission = new FolderPermission(path, actions);
            AccessController.checkPermission(permission);
        }
    }
View Full Code Here

        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm1 = new FolderPermission("/files/test.xml", "edit");
                    AccessController.checkPermission(perm1);
                    return null;
                }
            });
        }
        catch (AccessControlException ace)
        {
            assertTrue("did not authorize view permission on the Folder.", false);
        }

        // Should be denied.
        try
        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm2 = new FolderPermission("/files/test.xml", "secure");
                    AccessController.checkPermission(perm2);
                    return null;
                }
            });
            assertTrue("did not deny update permission on the folder.", false);
View Full Code Here

        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm1 = new FolderPermission("/files/subfolder1/test.xml", "view");
                    AccessController.checkPermission(perm1);
                    return null;
                }
            });
        }
        catch (AccessControlException ace)
        {
            fail("did not authorize view permission on the Folder.");
        }

       
        try
        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm1 = new FolderPermission("/files/subfolder1/foo", "view");
                    AccessController.checkPermission(perm1);
                    return null;
                }
            });
        }
        catch (AccessControlException ace)
        {
            fail("did not authorize view permission on the Folder.");
       
       
        try
        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm1 = new FolderPermission("/files/subfolder1/foo/anotherdoc.xml", "view");
                    AccessController.checkPermission(perm1);
                    return null;
                }
            });
            fail("Permission error - should not view the document ");
        }
        catch (AccessControlException ace)
        {
            // Correct behavior - not authorise to view the document
        }        
       
        try
        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm1 = new FolderPermission("/files/subfolder2/test.xml", "view");
                    AccessController.checkPermission(perm1);
                    return null;
                }
            });
        }
        catch (AccessControlException ace)
        {
            fail("did not authorize view permission on the Folder.");
        }

       
        try
        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm1 = new FolderPermission("/files/subfolder2/foo", "view");
                    AccessController.checkPermission(perm1);
                    return null;
                }
            });
        }
        catch (AccessControlException ace)
        {
            fail("did not authorize view permission on the Folder.");
        }
       
        try
        {
            Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
            {
                public Object run()
                {
                    FolderPermission perm1 = new FolderPermission("/files/subfolder2/foo/anotherdoc.xml", "view");
                    AccessController.checkPermission(perm1);
                    return null;
                }
            });
        }
View Full Code Here

        {
        }
       
        UserPrincipal user = new UserPrincipalImpl("anon");

        FolderPermission perm1 = new FolderPermission("/files/test.xml", "edit");
        FolderPermission perm2 = new FolderPermission("/files/subfolder1/*", "view");
        FolderPermission perm3 = new FolderPermission("/files/subfolder2/-", "view");
        try
        {
            pms.addPermission(perm1);
            pms.addPermission(perm2);
            pms.addPermission(perm3);
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.FolderPermission

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.