Examples of AclImpl


Examples of org.jboss.security.acl.ACLImpl

      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();
      transaction.begin();
      try
      {
         acl1 = this.entityManager.merge(this.persistedACLs.get(0));
         acl1.addEntry(entry4);
         acl1.addEntry(entry5);

         acl2 = this.entityManager.merge(this.persistedACLs.get(1));
         acl2.addEntry(entry6);
         acl2.removeEntry(this.persistedEntries.get(0));
         transaction.commit();
      }
      catch (RuntimeException re)
      {
         re.printStackTrace();
         transaction.rollback();
      }

      // add the new entries to the persisted entries collection.
      this.persistedEntries.add(entry4);
      this.persistedEntries.add(entry5);
      this.persistedEntries.add(entry6);

      // clear the entity manager's cache.
      this.entityManager.clear();

      // load the ACLs again and validate the changes.
      ACLImpl loadedACL1 = this.entityManager.find(ACLImpl.class, acl1.getACLId());
      assertNotNull("ACL1 could not be retrieved", loadedACL1);
      assertEquals("Loaded ACL contains unexpected number of entries", 2, loadedACL1.getEntries().size());
      assertTrue(loadedACL1.getEntries().contains(entry4));
      assertTrue(loadedACL1.getEntries().contains(entry5));

      ACLImpl loadedACL2 = this.entityManager.find(ACLImpl.class, acl2.getACLId());
      assertNotNull("ACL2 could not be retrieved", loadedACL2);
      assertEquals("Loaded AC2 contains unexpected number of entries", 3, loadedACL2.getEntries().size());
      assertFalse(loadedACL2.getEntries().contains(this.persistedEntries.get(0)));
      assertTrue(loadedACL2.getEntries().contains(this.persistedEntries.get(1)));
      assertTrue(loadedACL2.getEntries().contains(this.persistedEntries.get(2)));
      assertTrue(loadedACL2.getEntries().contains(entry6));
   }
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

        // Retrieve this Acl from the InputMap
        Acl uncastAcl = inputMap.get(currentIdentity);
        Assert.isInstanceOf(AclImpl.class, uncastAcl, "The inputMap contained a non-AclImpl");

        AclImpl inputAcl = (AclImpl) uncastAcl;

        Acl parent = inputAcl.getParentAcl();

        if ((parent != null) && parent instanceof StubAclParent) {
            // Lookup the parent
            StubAclParent stubAclParent = (StubAclParent) parent;
            parent = convert(inputMap, stubAclParent.getId());
        }

        // Now we have the parent (if there is one), create the true AclImpl
        AclImpl result = new AclImpl(inputAcl.getObjectIdentity(), (Long) inputAcl.getId(), aclAuthorizationStrategy,
                grantingStrategy, parent, null, inputAcl.isEntriesInheriting(), inputAcl.getOwner());

        // Copy the "aces" from the input to the destination

        // Obtain the "aces" from the input ACL
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

                    owner = new PrincipalSid(rs.getString("acl_sid"));
                } else {
                    owner = new GrantedAuthoritySid(rs.getString("acl_sid"));
                }

                acl = new AclImpl(objectIdentity, id, aclAuthorizationStrategy, grantingStrategy, parentAcl, null,
                        entriesInheriting, owner);

                acls.put(id, acl);
            }
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(100));
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
                new SimpleGrantedAuthority("ROLE_GENERAL"));

        acl = new AclImpl(identity, Long.valueOf(1), aclAuthorizationStrategy, new ConsoleAuditLogger());
    }
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

        ObjectIdentity identityParent = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(2));
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
                new SimpleGrantedAuthority("ROLE_GENERAL"));
        MutableAcl parentAcl = new AclImpl(identityParent, Long.valueOf(2), aclAuthorizationStrategy, new ConsoleAuditLogger());
        acl.setParent(parentAcl);

        myCache.putInCache(acl);

        verify(cache, times(4)).put(element.capture());

        List<Element> allValues = element.getAllValues();

        assertThat(allValues.get(0).getKey()).isEqualTo(parentAcl.getObjectIdentity());
        assertThat(allValues.get(0).getObjectValue()).isEqualTo(parentAcl);

        assertThat(allValues.get(1).getKey()).isEqualTo(parentAcl.getId());
        assertThat(allValues.get(1).getObjectValue()).isEqualTo(parentAcl);


        assertThat(allValues.get(2).getKey()).isEqualTo(acl.getObjectIdentity());
        assertThat(allValues.get(2).getObjectValue()).isEqualTo(acl);
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

        SecurityContextHolder.clearContext();
    }

    private void changeOwner(int contactNumber, String newOwnerUsername) {
        AclImpl acl = (AclImpl) mutableAclService.readAclById(new ObjectIdentityImpl(Contact.class,
                    new Long(contactNumber)));
        acl.setOwner(new PrincipalSid(newOwnerUsername));
        updateAclInTransaction(acl);
    }
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

    public int getCreateEntities() {
        return createEntities;
    }

    private void grantPermissions(int contactNumber, String recipientUsername, Permission permission) {
        AclImpl acl = (AclImpl) mutableAclService.readAclById(new ObjectIdentityImpl(Contact.class,
                    new Long(contactNumber)));
        acl.insertAce(acl.getEntries().size(), permission, new PrincipalSid(recipientUsername), true);
        updateAclInTransaction(acl);
    }
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

        // Retrieve this Acl from the InputMap
        Acl uncastAcl = inputMap.get(currentIdentity);
        Assert.isInstanceOf(AclImpl.class, uncastAcl, "The inputMap contained a non-AclImpl");

        AclImpl inputAcl = (AclImpl) uncastAcl;

        Acl parent = inputAcl.getParentAcl();

        if ((parent != null) && parent instanceof StubAclParent) {
            // Lookup the parent
            StubAclParent stubAclParent = (StubAclParent) parent;
            parent = convert(inputMap, stubAclParent.getId());
        }

        // Now we have the parent (if there is one), create the true AclImpl
        AclImpl result = new AclImpl(inputAcl.getObjectIdentity(), (Long) inputAcl.getId(), aclAuthorizationStrategy,
                auditLogger, parent, null, inputAcl.isEntriesInheriting(), inputAcl.getOwner());

        // Copy the "aces" from the input to the destination

        // Obtain the "aces" from the input ACL
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

                    owner = new PrincipalSid(rs.getString("acl_sid"));
                } else {
                    owner = new GrantedAuthoritySid(rs.getString("acl_sid"));
                }

                acl = new AclImpl(objectIdentity, id, aclAuthorizationStrategy, auditLogger, parentAcl, null,
                        entriesInheriting, owner);

                acls.put(id, acl);
            }
View Full Code Here

Examples of org.springframework.security.acls.domain.AclImpl

        SecurityContextHolder.clearContext();
    }

    private void changeOwner(int contactNumber, String newOwnerUsername) {
        AclImpl acl = (AclImpl) mutableAclService.readAclById(new ObjectIdentityImpl(Contact.class,
                    new Long(contactNumber)));
        acl.setOwner(new PrincipalSid(newOwnerUsername));
        updateAclInTransaction(acl);
    }
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.