Package org.springframework.security.acls.model

Examples of org.springframework.security.acls.model.AccessControlEntry


        // Check the permissions are as they should be
        assertFalse(child.isGranted(delete, pSid, true)); // as earlier permission overrode
        assertTrue(child.isGranted(Arrays.asList(BasePermission.CREATE), pSid, true));

        // Now check the first ACE (index 0) really is DELETE for our Sid and is non-granting
        AccessControlEntry entry = child.getEntries().get(0);
        assertEquals(BasePermission.DELETE.getMask(), entry.getPermission().getMask());
        assertEquals(new PrincipalSid(auth), entry.getSid());
        assertFalse(entry.isGranting());
        assertNotNull(entry.getId());

        // Now delete that first ACE
        child.deleteAce(0);

        // Save and check it worked
View Full Code Here


                public int getBatchSize() {
                    return acl.getEntries().size();
                }

                public void setValues(PreparedStatement stmt, int i) throws SQLException {
                    AccessControlEntry entry_ = acl.getEntries().get(i);
                    Assert.isTrue(entry_ instanceof AccessControlEntryImpl, "Unknown ACE class");
                    AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_;

                    stmt.setLong(1, ((Long) acl.getId()).longValue());
                    stmt.setInt(2, i);
View Full Code Here

    public boolean isGranted(Acl acl, List<Permission> permission, List<Sid> sids, boolean administrativeMode)
            throws NotFoundException {

        final List<AccessControlEntry> aces = acl.getEntries();

        AccessControlEntry firstRejection = null;

        for (Permission p : permission) {
            for (Sid sid: sids) {
                // Attempt to find exact match for this permission mask and SID
                boolean scanNextSid = true;
View Full Code Here

    public void testAccessControlEntryImplGetters() {
        Acl mockAcl = mock(Acl.class);
        Sid sid = new PrincipalSid("johndoe");

        // Create a sample entry
        AccessControlEntry ace = new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid, BasePermission.ADMINISTRATION,
                true, true, true);

        // and check every get() method
        assertEquals(new Long(1), ace.getId());
        assertEquals(mockAcl, ace.getAcl());
        assertEquals(sid, ace.getSid());
        assertTrue(ace.isGranting());
        assertEquals(BasePermission.ADMINISTRATION, ace.getPermission());
        assertTrue(((AuditableAccessControlEntry) ace).isAuditFailure());
        assertTrue(((AuditableAccessControlEntry) ace).isAuditSuccess());
    }
View Full Code Here

        final ObjectIdentity oid = mock(ObjectIdentity.class);

        when(mockAcl.getObjectIdentity()).thenReturn(oid);
        Sid sid = new PrincipalSid("johndoe");

        AccessControlEntry ace = new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid, BasePermission.ADMINISTRATION,
                true, true, true);

        assertFalse(ace.equals(null));
        assertFalse(ace.equals(Long.valueOf(100)));
        assertTrue(ace.equals(ace));
        assertTrue(ace.equals(new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid,
                BasePermission.ADMINISTRATION, true, true, true)));
        assertFalse(ace.equals(new AccessControlEntryImpl(Long.valueOf(2), mockAcl, sid,
                BasePermission.ADMINISTRATION, true, true, true)));
        assertFalse(ace.equals(new AccessControlEntryImpl(Long.valueOf(1), mockAcl, new PrincipalSid("scott"),
                BasePermission.ADMINISTRATION, true, true, true)));
        assertFalse(ace.equals(new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid, BasePermission.WRITE, true,
                true, true)));
        assertFalse(ace.equals(new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid,
                BasePermission.ADMINISTRATION, false, true, true)));
        assertFalse(ace.equals(new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid,
                BasePermission.ADMINISTRATION, true, false, true)));
        assertFalse(ace.equals(new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid,
                BasePermission.ADMINISTRATION, true, true, false)));
    }
View Full Code Here

        bytes.reset();
    }

    @Test
    public void nonAuditableAceIsIgnored() {
        AccessControlEntry ace = mock(AccessControlEntry.class);
        logger.logIfNeeded(true, ace);
        assertEquals(0, bytes.size());
    }
View Full Code Here

                public int getBatchSize() {
                    return acl.getEntries().size();
                }

                public void setValues(PreparedStatement stmt, int i) throws SQLException {
                    AccessControlEntry entry_ = acl.getEntries().get(i);
                    Assert.isTrue(entry_ instanceof AccessControlEntryImpl, "Unknown ACE class");
                    AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_;

                    stmt.setLong(1, ((Long) acl.getId()).longValue());
                    stmt.setInt(2, i);
View Full Code Here

        if (!this.isSidLoaded(sids)) {
            throw new UnloadedSidException("ACL was not loaded for one or more SID");
        }

        AccessControlEntry firstRejection = null;

        for (Permission p : permission) {
            for (Sid sid: sids) {
                // Attempt to find exact match for this permission mask and SID
                boolean scanNextSid = true;
View Full Code Here

  }

  @Override
  public boolean isGranted(List<Permission> permission, List<Sid> sids, boolean administrativeMode) throws NotFoundException, UnloadedSidException {

    AccessControlEntry firstRejection = null;

    for (Permission p : permission) {
      for (Sid sid : sids) {
        // Attempt to find exact match for this permission mask and SID
        boolean scanNextSid = true;
View Full Code Here

    public void testHasPermission() throws Exception {
        evaluator.hasPermission(authentication, targetId, permission);
    }

    private AccessControlEntry createAccessControlEntry(JtalksPermission permission, boolean isGranted, Sid sid) {
        AccessControlEntry accessControlEntry = Mockito.mock(AccessControlEntry.class);
        Mockito.when(accessControlEntry.getSid()).thenReturn(sid);
        Mockito.when(accessControlEntry.isGranting()).thenReturn(isGranted);
        Mockito.when(accessControlEntry.getPermission()).thenReturn(permission);
        return accessControlEntry;
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.acls.model.AccessControlEntry

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.