Package org.jboss.security.acl

Examples of org.jboss.security.acl.ACLEntryImpl


    *
    * @see org.jboss.xb.binding.GenericValueContainer#instantiate()
    */
   public Object instantiate()
   {
      return new ACLEntryImpl(this.permission, this.identity);
   }
View Full Code Here


         {
            if ((i + j) % 2 == 0)
            {
               // let some identities have all permissions.
               if (j % 5 == 0)
                  entries.add(new ACLEntryImpl(allPermission, this.identities[j]));
               else
                  entries.add(new ACLEntryImpl(readPermission, this.identities[j]));
            }
            else
            {
               entries.add(new ACLEntryImpl(noPermission, this.identities[j]));
            }
         }
         this.registration.registerACL(this.resources[i], entries);
      }
   }
View Full Code Here

      // =================================== ACLs ============================= //

      // register an ACL with the resource 0 - identity has all permissions here.
      Collection<ACLEntry> entries = new ArrayList<ACLEntry>();
      entries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()), this.identity));
      registration.registerACL(this.resources[0], entries);

      // register an ACL with the resource 4 - identity has read and update permissions.
      entries = new ArrayList<ACLEntry>();
      entries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.READ, BasicACLPermission.UPDATE),
            this.identity));
      registration.registerACL(this.resources[4], entries);

      // register an ACL with the resource 5 - identity has create, read and delete permissions.
      entries = new ArrayList<ACLEntry>();
      entries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.CREATE, BasicACLPermission.READ,
            BasicACLPermission.DELETE), this.identity));
      registration.registerACL(this.resources[5], entries);

      // register an ACL with the resource 7 - identity has no corresponding entry (no permissions).
      entries = new ArrayList<ACLEntry>();
      entries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()), IdentityFactory
            .createIdentity("Another Identity")));
      registration.registerACL(this.resources[7], entries);

      // register an ACL with the resource 9 - identity has only read permission.
      entries = new ArrayList<ACLEntry>();
      entries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.READ), this.identity));
      registration.registerACL(this.resources[9], entries);
   }
View Full Code Here

      roleGroup.addRole(role1);
      roleGroup.addRole(role2);
      this.identity = IdentityFactory.createIdentityWithRole("john", roleGroup);

      // create the ACLs for the resources.
      ACLEntry entry1 = new ACLEntryImpl(BasicACLPermission.READ, "role1");
      ACLEntry entry2 = new ACLEntryImpl(
            new CompositeACLPermission(BasicACLPermission.READ, BasicACLPermission.UPDATE), "role2");
      ACLEntry entry3 = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()), "role3");
      List<ACLEntry> entries = new ArrayList<ACLEntry>();
      entries.add(entry1);
      entries.add(entry2);
      entries.add(entry3);
      this.strategy.createACL(this.resources[0], entries);

      // the second ACL uses the identity name.
      entry1 = new ACLEntryImpl(BasicACLPermission.READ, "ritchie");
      entry2 = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()), "john");
      entries = new ArrayList<ACLEntry>();
      entries.add(entry1);
      entries.add(entry2);
      this.strategy.createACL(this.resources[1], entries);
   }
View Full Code Here

      // add some entries to the ACL.
      int entriesNumber = 20;
      for (int i = 0; i < entriesNumber; i++)
      {
         ACLEntry entry = new ACLEntryImpl(BasicACLPermission.CREATE, IdentityFactory.createIdentity("Identity" + i));
         acl.addEntry(entry);
      }
      assertTrue("Failed to update the ACL", this.strategy.updateACL(acl));

      // retrieve the ACL again and check it has the added entries.
      acl = this.strategy.getACL(this.resources[0]);
      assertEquals("Invalid number of entries", entriesNumber, acl.getEntries().size());

      // now remove one of the entries.
      ACLEntry entry = acl.getEntries().iterator().next();
      acl.removeEntry(entry);
      assertTrue("Failed to update the ACL", this.strategy.updateACL(acl));

      // retrieve the ACL again and check it has one less entry.
      acl = this.strategy.getACL(this.resources[0]);
      assertEquals("Invalid number of entries", entriesNumber - 1, acl.getEntries().size());

      // assert that update fails for an ACL not managed by the strategy.
      Collection<ACLEntry> entries = new ArrayList<ACLEntry>();
      entries.add(new ACLEntryImpl(BasicACLPermission.UPDATE, IdentityFactory.createIdentity("Another Identity")));
      ACL otherACL = new ACLImpl(this.resources[1], entries);
      assertFalse(this.strategy.updateACL(otherACL));
   }
View Full Code Here

      this.persistedACLs = new ArrayList<ACLImpl>();
      this.persistedEntries = new ArrayList<ACLEntryImpl>();

      // create the test entries.
      this.persistedEntries
            .add(new ACLEntryImpl(BasicACLPermission.READ, IdentityFactory.createIdentity("Identity-1")));
      this.persistedEntries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.CREATE,
            BasicACLPermission.READ), IdentityFactory.createIdentity("Identity-2")));
      this.persistedEntries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()),
            IdentityFactory.createIdentity("Identity-3")));

      // create the test acls.
      this.persistedACLs.add(new ACLImpl(new TestResource(100, "Resource-1")));
      this.persistedACLs.add(new ACLImpl(new TestResource(200, "Resource-2"), new ArrayList<ACLEntry>(
View Full Code Here

      this.identities = new Identity[ACL_SIZE];
      for (int i = 0; i < ACL_SIZE; i++)
         this.identities[i] = IdentityFactory.createIdentity("Identity" + i);
      // create an entry with a basic permission.
      this.entries = new ACLEntryImpl[ACL_SIZE];
      this.entries[0] = new ACLEntryImpl(BasicACLPermission.READ, this.identities[0]);
      // build the remaining entries with composite permissions.
      this.entries[1] = new ACLEntryImpl(new CompositeACLPermission(), this.identities[1]);
      this.entries[2] = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.READ), this.identities[2]);
      this.entries[3] = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.CREATE,
            BasicACLPermission.UPDATE, BasicACLPermission.DELETE), this.identities[3]);
      this.entries[4] = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()), this.identities[4]);
   }
View Full Code Here

      this.entityManager.clear();

      // load the entries from the database using their primary key and validate them.
      for (ACLEntryImpl entry : this.persistedEntries)
      {
         ACLEntryImpl loadedEntry = this.entityManager.find(ACLEntryImpl.class, entry.getACLEntryId());
         assertNotNull("Entry could not be retrieved by primary key", loadedEntry);
         assertEquals(entry, loadedEntry);
      }

      // execute some queries and validate the results.
      ACLEntryImpl entry = this.persistedEntries.get(1);
      ACLEntryImpl queryResult = (ACLEntryImpl) this.entityManager.createQuery(
            "SELECT e FROM ACLEntryImpl e WHERE e.identityOrRole LIKE '"
                  + entry.getIdentityOrRole() + "'").getSingleResult();
      assertNotNull("Entry2 could not be retrieved by it's identity", queryResult);
      assertEquals(entry, queryResult);
View Full Code Here

    * @throws Exception if an error occurs when running the test.
    */
   public void testUpdateACL() throws Exception
   {
      // add some entries to the acls and remove one of the existing entries from ACL2.
      ACLEntryImpl entry4 = new ACLEntryImpl(BasicACLPermission.CREATE, IdentityFactory.createIdentity("Identity-4"));
      ACLEntryImpl entry5 = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.CREATE,
            BasicACLPermission.DELETE), IdentityFactory.createIdentity("Identity-5"));
      ACLEntryImpl entry6 = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()), IdentityFactory
            .createIdentity("Identity-6"));

      ACLImpl acl1 = null;
      ACLImpl acl2 = null;
      EntityTransaction transaction = this.entityManager.getTransaction();
View Full Code Here

        UUIDResource localresource = new UUIDResource( uuid );

        Collection<ACLEntry> entries = new ArrayList<ACLEntry>();

        ACLEntry entry = new ACLEntryImpl( toSecurityByteMaskPermission( permission ),
                                           identity );

        entries.add( entry );

        registration.registerACL( localresource,
View Full Code Here

TOP

Related Classes of org.jboss.security.acl.ACLEntryImpl

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.