Package org.apache.turbine.om.security

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


    public void testPermissionByName()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Permission permission = ss.getPermissionByName("Login");
        assertNotNull(permission);
        assertEquals(permission.getName(), "Login");
    }
View Full Code Here


    public void testPermissionById()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Permission permission = ss.getPermissionById(2);
        assertNotNull(permission);
        assertEquals(permission.getName(), "Application");
    }
View Full Code Here

    public void testAddPermission()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Permission newbie = ss.getPermissionInstance();
        newbie.setName("newbie");

        ss.addPermission(newbie);

        assertEquals("Permission was not added", 4, ss.getAllPermissions().size());

        try
        {
            Permission application = ss.getPermissionByName("Application");

            ss.addPermission(application);
            fail("Existing Permission could be added!");
        }
        catch (Exception e)
        {
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), EntityExistsException.class, e.getClass());
        }

        try
        {
            Permission empty = ss.getPermissionInstance();

            ss.addPermission(empty);
            fail("Permission with empty Permissionname could be added!");
        }
        catch (Exception e)
View Full Code Here

    {
      SecurityService ss = TurbineSecurity.getService();

      assertEquals("Permission was not added", 4, ss.getAllPermissions().size());

        Permission newbie = ss.getPermissionByName("newbie");
        assertNotNull(newbie);

        ss.removePermission(newbie);

        try
        {
            Permission foo = ss.getPermissionInstance();
            foo.setName("foo");

            ss.removePermission(foo);
            fail("Non Existing Permission could be deleted!");
        }
        catch (Exception e)
View Full Code Here

        SecurityService ss = TurbineSecurity.getService();

        Role admin = ss.getRoleByName("Admin");
        assertNotNull(admin);

        Permission app = ss.getPermissionByName("Application");
        assertNotNull(app);

        PermissionSet ps = admin.getPermissions();
        assertFalse(ps.contains(app));

        ss.grant(admin, app);

        Role admin2 = ss.getRoleByName("Admin");
        assertNotNull(admin2);

        PermissionSet ps2 = admin2.getPermissions();
        assertTrue(ps2.contains(app));

        // Get existing PermissionSet modified?
        assertFalse(ps.contains(app));

        try
        {
            ss.grant(admin2, app);
            fail("Permission could be granted twice!");
        }
        catch (Exception e)
        {
            //
            // Ugh. DataBackendError? This means that our query actually hit the database and only the "unique key"
            // prevented us from a double entry. This seems to be a bug
            //
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), DataBackendException.class, e.getClass());
        }

        try
        {
            Permission unknown = ss.getPermissionInstance("unknown");

            ss.grant(admin, unknown);
            fail("Nonexisting Permission could be granted!");
        }
        catch (Exception e)
View Full Code Here

        SecurityService ss = TurbineSecurity.getService();

        Role admin = ss.getRoleByName("Admin");
        assertNotNull(admin);

        Permission app = ss.getPermissionByName("Application");
        assertNotNull(app);

        PermissionSet ps = admin.getPermissions();
        assertTrue(ps.contains(app));

        ss.revoke(admin, app);

        Role admin2 = ss.getRoleByName("Admin");
        assertNotNull(admin2);

        PermissionSet ps2 = admin2.getPermissions();
        assertFalse(ps2.contains(app));

        // Get existing PermissionSet modified?
        assertTrue(ps.contains(app));

         try
         {
             Permission unknown = ss.getPermissionInstance("unknown");
             ss.revoke(admin, unknown);
             fail("Nonexisting Permission could be revoked!");
         }
         catch (Exception e)
         {
View Full Code Here

    public void testSavePermission()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Permission application = ss.getPermissionByName("Application");

        ss.savePermission(application);

        try
        {
            Permission fake = ss.getPermissionInstance("fake");

            ss.savePermission(fake);
            fail("Non Existing Permission could be saved!");
        }
        catch (Exception e)
View Full Code Here

    public void testRenamePermission()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Permission newbie = ss.getPermissionInstance("newbie");
        ss.addPermission(newbie);

        Permission test = ss.getPermissionByName("newbie");
        assertNotNull(test);

        ss.renamePermission(test, "fake");

        Permission fake = ss.getPermissionByName("fake");
        assertNotNull(fake);

//
// Now this is a Turbine Bug...
//
View Full Code Here

    public boolean add(Collection permissions)
    {
        boolean res = false;
        for (Iterator it = permissions.iterator(); it.hasNext();)
        {
            Permission p = (Permission) it.next();
            res |= add(p);
        }
        return res;
    }
View Full Code Here

    public boolean add(PermissionSet permissionSet)
    {
        boolean res = false;
        for( Iterator it = permissionSet.iterator(); it.hasNext();)
        {
            Permission p = (Permission) it.next();
            res |= add(p);
        }
        return res;
    }
View Full Code Here

TOP

Related Classes of org.apache.turbine.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.