Examples of Permission


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

    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

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

    {
      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

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

        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

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

        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

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

    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

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

    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

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

    public static final Vector getDifference(Vector some, Vector all)
    {
        Vector clone = (Vector) all.clone();
        for (Enumeration e = some.elements() ; e.hasMoreElements() ;)
        {
            Permission tmp = (Permission) e.nextElement();
            for (Enumeration f = clone.elements() ; f.hasMoreElements() ;)
            {
                Permission tmp2 = (Permission) f.nextElement();
                if (((Persistent) tmp).getPrimaryKey() ==
                    ((Persistent) tmp2).getPrimaryKey())
                {
                    clone.removeElement(tmp2);
                    break;
View Full Code Here

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

        //
        // Wrap the returned Objects into TorquePermissions.
        //
        for (Iterator it = list.iterator(); it.hasNext(); )
        {
            Permission p = getNewPermission((Persistent) it.next());
            newList.add(p);
        }

        return newList;
    }
View Full Code Here

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

     *
     */

    public static Permission getNewPermission(Persistent p)
    {
        Permission perm = null;
        try
        {
            Class permissionWrapperClass = TurbineSecurity.getPermissionClass();

            Class [] clazz = new Class [] { Persistent.class };
View Full Code Here

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

            List results = new ArrayList();

            // Populate the object(s).
            for (int i = 0; i < rows.size(); i++)
            {
                Permission obj = TurbineSecurity.getPermissionInstance(null);
                Record row = (Record) rows.get(i);
                ((SecurityObject) obj).setPrimaryKey(
                        new NumberKey(row.getValue(1).asInt()));
                ((SecurityObject) obj).setName(row.getValue(2).asString());
                byte[] objectData = row.getValue(3).asBytes();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.