Example usage for org.springframework.security.acls.model ObjectIdentity getIdentifier

List of usage examples for org.springframework.security.acls.model ObjectIdentity getIdentifier

Introduction

In this page you can find the example usage for org.springframework.security.acls.model ObjectIdentity getIdentifier.

Prototype

Serializable getIdentifier();

Source Link

Document

Obtains the actual identifier.

Usage

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

@Override
public void evictFromCache(final ObjectIdentity objectIdentity) {
    evictFromCache(objectIdentity.getIdentifier());
}

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

@Override
public MutableAcl getFromCache(final ObjectIdentity objectIdentity) {
    return getFromCache(objectIdentity.getIdentifier());
}

From source file:net.projectmonkey.spring.acl.enhancement.identity.strategy.ConfigurableObjectIdentityRetrievalStrategyTest.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test//  w  ww. j  a v a  2 s .co  m
public void domainObjectAndSecuredClassUsedIfNoIdentifierMethodSpecified() {
    SimpleTestClass domainObject = new SimpleTestClass();
    Class clazz = SimpleTestClass.class;
    when(mapping.getDomainObject()).thenReturn(domainObject);
    when(mapping.getSecuredClass()).thenReturn(clazz);
    ObjectIdentity returned = underTest.getObjectIdentity(mapping);
    assertEquals(clazz.getName(), returned.getType());
    assertEquals(domainObject, returned.getIdentifier());
}

From source file:net.projectmonkey.spring.acl.enhancement.identity.strategy.ConfigurableObjectIdentityRetrievalStrategyTest.java

@SuppressWarnings({ "rawtypes" })
@Test/*from  ww w . j ava2  s. com*/
public void domainObjectAndSecuredClassUsedIfNoIdentifierMethodSpecifiedWhenUsingObject() {
    SimpleTestClass domainObject = new SimpleTestClass();
    Class clazz = SimpleTestClass.class;
    ObjectIdentity returned = underTest.getObjectIdentity(domainObject);
    assertEquals(clazz.getName(), returned.getType());
    assertEquals(domainObject, returned.getIdentifier());
}

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

@Test
public void getObjectIdentityShouldConvertIfRuleIsSet() throws Exception {
    TypeConvertingObjectIdentityGenerator sut = createDefaultGenerator();
    Branch domainObject = givenPersistedBranch();

    ObjectIdentity objectIdentity = sut.getObjectIdentity(domainObject);
    assertEquals("BRANCH", objectIdentity.getType());
    assertEquals(domainObject.getId(), objectIdentity.getIdentifier());
}

From source file:net.projectmonkey.spring.acl.enhancement.identity.strategy.ConfigurableObjectIdentityRetrievalStrategyTest.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test/*ww w  . j ava 2 s .com*/
public void internalMethodCallResultAndSecuredClassUsedIfIdentifierMethodSpecified() {
    underTest = new ConfigurableObjectIdentityRetrievalStrategy("getId");
    SimpleTestClass domainObject = new SimpleTestClass();
    Class clazz = SimpleTestClass.class;
    when(mapping.getDomainObject()).thenReturn(domainObject);
    when(mapping.getSecuredClass()).thenReturn(clazz);
    ObjectIdentity returned = underTest.getObjectIdentity(mapping);
    assertEquals(clazz.getName(), returned.getType());
    assertEquals(domainObject.getId(), returned.getIdentifier());
}

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

@Test(dataProvider = "randomEntity", dataProviderClass = AclDataProvider.class)
public void testCreateIdentityFor(Entity entity) throws Exception {
    ObjectIdentity identity = util.createIdentityFor(entity);
    assertEquals(identity.getType(), entity.getClass().getSimpleName());
    assertEquals(identity.getIdentifier(), entity.getId());
}

From source file:net.projectmonkey.spring.acl.enhancement.identity.strategy.ConfigurableObjectIdentityRetrievalStrategyTest.java

@SuppressWarnings({ "rawtypes" })
@Test/*from   w  ww .j  a  va  2  s  . c om*/
public void internalMethodCallResultAndSecuredClassUsedIfIdentifierMethodSpecifiedWhenUsingObject() {
    // the DefaultObjectIdentityRetrievalStrategy uses getId as per the existing Spring implementation
    underTest = new DefaultObjectIdentityRetrievalStrategy();
    SimpleTestClass domainObject = new SimpleTestClass();
    Class clazz = SimpleTestClass.class;
    ObjectIdentity returned = underTest.getObjectIdentity(domainObject);
    assertEquals(clazz.getName(), returned.getType());
    assertEquals(domainObject.getId(), returned.getIdentifier());
}

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

@Test
public void getObjectIdentityShouldNotConvertWithEmptyRules() throws Exception {
    TypeConvertingObjectIdentityGenerator sut = new TypeConvertingObjectIdentityGenerator();
    Branch domainObject = givenPersistedBranch();

    ObjectIdentity objectIdentity = sut.getObjectIdentity(domainObject);
    assertEquals(Branch.class.getSimpleName(), objectIdentity.getType());
    assertEquals(domainObject.getId(), objectIdentity.getIdentifier());
}

From source file:org.jtalks.common.service.security.DtoLookupStrategyTest.java

@BeforeMethod
public void setUp() {
    mapper = mock(DtoMapper.class);
    strategy = mock(LookupStrategy.class);
    when(strategy.readAclsById(anyListOf(ObjectIdentity.class), anyListOf(Sid.class)))
            .thenAnswer(new Answer<Map<ObjectIdentity, Acl>>() {
                @Override/*from  w  w w .  j ava2s. c o m*/
                public Map<ObjectIdentity, Acl> answer(InvocationOnMock invocation) throws Throwable {
                    stragegyCallArgument = (List<ObjectIdentity>) invocation.getArguments()[0];
                    Map<ObjectIdentity, Acl> result = new HashMap<ObjectIdentity, Acl>();
                    result.put(stragegyCallArgument.get(0), null);

                    return result;
                }
            });

    ObjectIdentity identity = mock(ObjectIdentity.class);
    when(identity.getType()).thenReturn(c1.class.getCanonicalName());
    when(identity.getIdentifier()).thenReturn(1L);

    objects = new ArrayList<ObjectIdentity>();
    objects.add(identity);

    sids = new ArrayList<Sid>();

    sut = new DtoLookupStrategy(strategy, mapper);
}