Example usage for org.springframework.security.acls.domain ObjectIdentityImpl ObjectIdentityImpl

List of usage examples for org.springframework.security.acls.domain ObjectIdentityImpl ObjectIdentityImpl

Introduction

In this page you can find the example usage for org.springframework.security.acls.domain ObjectIdentityImpl ObjectIdentityImpl.

Prototype

public ObjectIdentityImpl(Class<?> javaType, Serializable identifier) 

Source Link

Document

Constructor which uses the name of the supplied class as the type property.

Usage

From source file:net.projectmonkey.spring.acl.hbase.repository.AclRecordTest.java

@Test
public void creatingKeyFromIdentityWithByteArrayIdentifier() {
    ObjectIdentity identity = new ObjectIdentityImpl(TYPE, ID.getBytes());

    AclRecord underTest = new AclRecord(identity, null);

    assertEquals(identity, underTest.getIdentity());
    assertTrue(ArrayUtils.isEquals(ID.getBytes(), underTest.getKey()));
    assertTrue(ArrayUtils.isEquals(byte[].class.getName().getBytes(), underTest.getIdTypeBytes()));
}

From source file:sample.contact.service.impl.MenuServiceImpl.java

public void addPermission(Menu menu, Sid recipient, Permission permission) {
    MutableAcl acl;/* w w w .ja  v  a  2 s.c  om*/
    ObjectIdentity oid = new ObjectIdentityImpl(Menu.class, menu.getId());

    try {
        acl = (MutableAcl) mutableAclService.readAclById(oid);
    } catch (NotFoundException nfe) {
        acl = mutableAclService.createAcl(oid);
    }

    acl.insertAce(acl.getEntries().size(), permission, recipient, true);
    mutableAclService.updateAcl(acl);

    logger.debug("Added permission " + permission + " for Sid " + recipient + " menu " + menu);
}

From source file:grails.plugin.springsecurity.acl.model.StubAclParent.java

/**
 * {@inheritDoc}/*from   ww w  . j  a  va  2 s.co m*/
 * @see org.springframework.security.acls.model.Acl#getObjectIdentity()
 */
public ObjectIdentity getObjectIdentity() {
    return new ObjectIdentityImpl(getClass(), 0);
}

From source file:org.jtalks.common.security.acl.AclManagerTest.java

@Test(dataProviderClass = AclDataProvider.class, dataProvider = "provideAclWithMixedTypeSids")
public void testGetEntityPermissions(ExtendedMutableAcl acl) throws Exception {
    ObjectIdentity branch = new ObjectIdentityImpl(Branch.class, 0);
    when(mockAclUtil.getAclFor(branch)).thenReturn(acl);
    List<GroupAce> branchPermissions = manager.getGroupPermissionsOn(branch);
    //next check that UserGroupSids are in the resulting list and others are not there
    for (AccessControlEntry entry : acl.getEntries()) {
        if (entry.getSid() instanceof UserGroupSid) {
            GroupAce groupAce = findWithOriginalAce(branchPermissions, entry);
            assertSame(entry.getSid(), groupAce.getOriginalAce().getSid());
        } else {/*from   w w w  .j a  v a  2 s  .  c om*/
            assertNull(findWithOriginalAce(branchPermissions, entry));
        }
    }
}

From source file:net.projectmonkey.spring.acl.hbase.repository.AclRecordTest.java

@Test
public void creatingKeyFromIdentityWithConvertableIdentifier() {
    ObjectIdentity identity = new ObjectIdentityImpl(TYPE, ID);

    AclRecord underTest = new AclRecord(identity, new StringAclIdentifierConverter());

    assertEquals(identity, underTest.getIdentity());
    assertTrue(ArrayUtils.isEquals(ID.getBytes(), underTest.getKey()));
    assertTrue(ArrayUtils.isEquals(String.class.getName().getBytes(), underTest.getIdTypeBytes()));
}

From source file:org.jtalks.common.security.acl.AclUtilTest.java

@Test
public void testGetAclForObjectIdentity() throws Exception {
    ObjectIdentity identity = new ObjectIdentityImpl(getClass().getName(), 1);
    MutableAcl mockAcl = mock(MutableAcl.class);
    when(aclService.readAclById(identity)).thenReturn(mockAcl);

    ExtendedMutableAcl extendedMutableAcl = util.getAclFor(identity);
    assertSame(extendedMutableAcl.getAcl(), mockAcl);
}

From source file:org.bremersee.common.acl.test.AclServiceTests.java

@Test
public void testAcl() {
    LOG.info("Testing ...");

    RunAsUtil.runAs("tester", getRunAsRoles(), () -> {
        MutableAcl acl = aclService.createAcl(new ObjectIdentityImpl("TestObject", "100"));
        acl.setOwner(new PrincipalSid("tester"));
        acl.setEntriesInheriting(false);
        acl.setParent(null);//ww  w .j  a v  a2  s  .  c o  m
        acl.insertAce(acl.getEntries().size(), BasePermission.READ, new PrincipalSid("friend"), true);
        acl = aclService.updateAcl(acl);
        return acl;
    });

    MutableAcl acl = (MutableAcl) aclService.readAclById(new ObjectIdentityImpl("TestObject", "100"));
    LOG.info("Acl: " + acl);

    boolean friendCanRead = permissionEvaluator.hasPermission(
            new RunAsAuthentication("friend", new String[] { "ROLE_USER" }), "100", "TestObject", "READ");

    LOG.info("Successful? " + friendCanRead);
    TestCase.assertEquals(true, friendCanRead);

}

From source file:org.createnet.raptor.auth.service.services.AclTokenService.java

public List<Permission> list(Token token, User user) {
    ObjectIdentity oitoken = new ObjectIdentityImpl(token.getClass(), token.getId());
    return aclManagerService.getPermissionList(user, oitoken);
}

From source file:org.createnet.raptor.auth.service.services.AclDeviceService.java

public List<Permission> list(Device device, User user) {
    ObjectIdentity oiDevice = new ObjectIdentityImpl(Device.class, device.getId());
    return aclManagerService.getPermissionList(user, oiDevice);
}

From source file:sample.contact.ContactManagerBackend.java

public void addPermission(Contact contact, Sid recipient, Permission permission) {
    MutableAcl acl;/*from  www  . j ava 2 s. co  m*/
    ObjectIdentity oid = new ObjectIdentityImpl(Contact.class, contact.getId());

    try {
        acl = (MutableAcl) mutableAclService.readAclById(oid);
    } catch (NotFoundException nfe) {
        acl = mutableAclService.createAcl(oid);
    }

    acl.insertAce(acl.getEntries().size(), permission, recipient, true);
    mutableAclService.updateAcl(acl);

    logger.debug("Added permission " + permission + " for Sid " + recipient + " contact " + contact);
}