Package org.apache.jetspeed.om.page

Examples of org.apache.jetspeed.om.page.SecurityConstraintsDef


        assertNotNull(pageManager.getLinks(folder));
        assertEquals(1, pageManager.getLinks(folder).size());

        PageSecurity pageSecurity = pageManager.newPageSecurity();
        List constraintsDefs = new ArrayList(2);
        SecurityConstraintsDef constraintsDef = pageManager.newSecurityConstraintsDef();
        constraintsDef.setName("public-view");
        List defConstraints = new ArrayList(1);
        SecurityConstraint defConstraint = pageSecurity.newSecurityConstraint();
        defConstraint.setUsers(Shared.makeListFromCSV("*"));
        defConstraint.setPermissions(Shared.makeListFromCSV("view"));
        defConstraints.add(defConstraint);
        constraintsDef.setSecurityConstraints(defConstraints);
        constraintsDefs.add(constraintsDef);
        constraintsDef = pageSecurity.newSecurityConstraintsDef();
        constraintsDef.setName("admin-all");
        defConstraints = new ArrayList(2);
        defConstraint = pageSecurity.newSecurityConstraint();
        defConstraint.setRoles(Shared.makeListFromCSV("admin"));
        defConstraint.setPermissions(Shared.makeListFromCSV("view,edit"));
        defConstraints.add(defConstraint);
        defConstraint = pageSecurity.newSecurityConstraint();
        defConstraint.setRoles(Shared.makeListFromCSV("nobody"));
        defConstraints.add(defConstraint);
        constraintsDef.setSecurityConstraints(defConstraints);
        constraintsDefs.add(constraintsDef);
        pageSecurity.setSecurityConstraintsDefs(constraintsDefs);
        List globalConstraintsRefs = new ArrayList(2);
        globalConstraintsRefs.add("admin-all");
        globalConstraintsRefs.add("public-view");
View Full Code Here


                            folder.setSecurityConstraints(constraints);
                            pageManager.updateFolder(folder);
                       
                            PageSecurity pageSecurity = pageManager.newPageSecurity();
                            List constraintsDefs = new ArrayList(2);
                            SecurityConstraintsDef constraintsDef = pageManager.newSecurityConstraintsDef();
                            constraintsDef.setName("public-view");
                            List defConstraints = new ArrayList(1);
                            SecurityConstraint defConstraint = pageManager.newPageSecuritySecurityConstraint();
                            defConstraint.setUsers(Shared.makeListFromCSV("*"));
                            defConstraint.setPermissions(Shared.makeListFromCSV("view"));
                            defConstraints.add(defConstraint);
                            constraintsDef.setSecurityConstraints(defConstraints);
                            constraintsDefs.add(constraintsDef);
                            constraintsDef = pageManager.newSecurityConstraintsDef();
                            constraintsDef.setName("admin-all");
                            defConstraints = new ArrayList(1);
                            defConstraint = pageManager.newPageSecuritySecurityConstraint();
                            defConstraint.setRoles(Shared.makeListFromCSV("admin"));
                            defConstraint.setPermissions(Shared.makeListFromCSV("view,edit"));
                            defConstraints.add(defConstraint);
                            constraintsDef.setSecurityConstraints(defConstraints);
                            constraintsDefs.add(constraintsDef);
                            pageSecurity.setSecurityConstraintsDefs(constraintsDefs);
                            List globalConstraintsRefs = new ArrayList(1);
                            globalConstraintsRefs.add("admin-all");
                            pageSecurity.setGlobalSecurityConstraintsRefs(globalConstraintsRefs);
View Full Code Here

    public boolean checkConstraint(String securityConstraintName, String actions)
    {
        try
        {
            PageSecurity security = this.getPageSecurity();
            SecurityConstraintsDef def = security.getSecurityConstraintsDef(securityConstraintName);
            if (def != null)
            {
                return PageManagerSecurityUtils.checkConstraint(def, actions);
            }           
        }
View Full Code Here

        // copy security constraint defintions
        copy.setSecurityConstraintsDefs(DatabasePageManagerUtils.createList());               
        Iterator defs = source.getSecurityConstraintsDefs().iterator();
        while (defs.hasNext())
        {
            SecurityConstraintsDef def = (SecurityConstraintsDef)defs.next();
            SecurityConstraintsDef defCopy = this.newSecurityConstraintsDef();           
            defCopy.setName(def.getName());
            List copiedConstraints = DatabasePageManagerUtils.createList();
            Iterator constraints = def.getSecurityConstraints().iterator();
            while (constraints.hasNext())
            {
                SecurityConstraint srcConstraint = (SecurityConstraint)constraints.next();
                SecurityConstraint dstConstraint = newPageSecuritySecurityConstraint();
                copyConstraint(srcConstraint, dstConstraint);
                copiedConstraints.add(dstConstraint);
            }                                           
            defCopy.setSecurityConstraints(copiedConstraints);
            copy.getSecurityConstraintsDefs().add(defCopy);
        }
       
        // copy global security constraint references
        copy.setGlobalSecurityConstraintsRefs(DatabasePageManagerUtils.createList());
View Full Code Here

            "<security-constraints-def name=\"" +
                  defName +
                  "\"><security-constraint><roles>user, manager</roles><permissions>view,edit</permissions></security-constraint></security-constraints-def>";
        runTest(xml, defName, method);
        PageSecurity pageSecurity = pageManager.getPageSecurity();
        SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(defName);
        assertNotNull("definition " + defName + " not found ", def);
        assertNotNull("first constraint for " + defName + " not found ", def);
        List constraints = def.getSecurityConstraints();
        assertFalse("constraint list is empty.", constraints.isEmpty());
        SecurityConstraint constraint =  (SecurityConstraint) constraints.get(0);
        assertEquals("update failed for constraints " + constraint.getPermissions().toString(), constraint.getPermissions().toString(), "[view, edit]");
    }
View Full Code Here

            "<security-constraints-def name=\"" +
                  defName +
                  "\"><security-constraint><roles>user, manager</roles><permissions>view,edit</permissions></security-constraint></security-constraints-def>";
        runTest(xml, defName, method);
        PageSecurity pageSecurity = pageManager.getPageSecurity();
        SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(defName);
        assertNotNull("definition " + defName + " not found ", def);
        SecurityConstraint constraint =  (SecurityConstraint)def.getSecurityConstraints().get(0);
        assertNotNull("first constraint for " + defName + " not found ", def);
        assertEquals("update failed for constraints " + constraint.getPermissions().toString(), constraint.getPermissions().toString(), "[view, edit]");
    }
View Full Code Here

                  "<security-constraint><users>manager,admin</users><permissions>view,help</permissions></security-constraint>" +
                  "</security-constraints-def>";
                 
        runTest(xml, defName, method);
        PageSecurity pageSecurity = pageManager.getPageSecurity();
        SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(defName);
        assertNotNull("definition " + defName + " not found ", def);
        SecurityConstraint constraint =  (SecurityConstraint)def.getSecurityConstraints().get(0);
        assertNotNull("first constraint for " + defName + " not found ", constraint);
        assertEquals("update failed for constraints " + constraint.getPermissions().toString(), constraint.getPermissions().toString(), "[view, edit, help]");
        assertEquals("update failed for constraints " + constraint.getRoles().toString(), constraint.getRoles().toString(), "[user, manager, anon]");
       
        SecurityConstraint constraint2 =  (SecurityConstraint)def.getSecurityConstraints().get(1);
        assertNotNull("second constraint for " + defName + " not found ", constraint2);
        assertEquals("add failed for constraints " + constraint2.getPermissions().toString(), constraint2.getPermissions().toString(), "[view, edit, help]");
        assertEquals("add failed for constraints " + constraint2.getGroups().toString(), constraint2.getGroups().toString(), "[accounting, finance]");

        SecurityConstraint constraint3 =  (SecurityConstraint)def.getSecurityConstraints().get(2);
        assertNotNull("third constraint for " + defName + " not found ", constraint3);
        assertEquals("add failed for constraints " + constraint3.getPermissions().toString(), constraint3.getPermissions().toString(), "[view]");
        assertEquals("add failed for constraints " + constraint3.getUsers().toString(), constraint3.getUsers().toString(), "[tomcat]");

        SecurityConstraint constraint4 =  (SecurityConstraint)def.getSecurityConstraints().get(3);
        assertNotNull("fourth constraint for " + defName + " not found ", constraint4);
        assertEquals("add failed for constraints " + constraint4.getPermissions().toString(), constraint4.getPermissions().toString(), "[view, help]");
        assertEquals("add failed for constraints " + constraint4.getUsers().toString(), constraint4.getUsers().toString(), "[manager, admin]");
       
    }
View Full Code Here

            "<security-constraints-def name=\"" +
                  defName +
                  "\"><security-constraint><users>*</users><permissions>view</permissions></security-constraint></security-constraints-def>";
        runTest(xml, defName, method);
        PageSecurity pageSecurity = pageManager.getPageSecurity();
        SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(defName);
        assertNotNull("definition " + defName + " not found ", def);
        SecurityConstraint constraint =  (SecurityConstraint)def.getSecurityConstraints().get(0);
        assertNotNull("first constraint for " + defName + " not found ", def);
        assertEquals("delete merge failed for constraints " + constraint.getPermissions().toString(), constraint.getPermissions().toString(), "[view]");
        assertEquals("delete merge failed for constraints " + constraint.getUsers().toString(), constraint.getUsers().toString(), "[*]");       
        assertTrue("constrainst size should be 1 ", def.getSecurityConstraints().size() == 1);       
    }
View Full Code Here

        String method = "remove-def";       
        String defName = "deleteme";
        String xml = "";
        runTest(xml, defName, method);
        PageSecurity pageSecurity = pageManager.getPageSecurity();
        SecurityConstraintsDef def = pageSecurity.getSecurityConstraintsDef(defName);
        assertNull("definition " + defName + " should be deleted ", def);
    }
View Full Code Here

    public boolean checkConstraint(String securityConstraintName, String actions)
    {
        try
        {
            PageSecurity security = this.getPageSecurity();
            SecurityConstraintsDef def = security.getSecurityConstraintsDef(securityConstraintName);
            if (def != null)
            {
                return PageManagerSecurityUtils.checkConstraint(def, actions);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.page.SecurityConstraintsDef

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.