List of usage examples for org.springframework.security.acls.model ObjectIdentity getType
String getType();
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:org.jtalks.common.security.acl.TypeConvertingObjectIdentityGeneratorTest.java
@Test public void getObjectIdentityShouldApplySameRuleForSubclass() { TypeConvertingObjectIdentityGenerator sut = createDefaultGenerator(); ObjectIdentity objectIdentity = sut.getObjectIdentity(new BranchOffspring()); assertEquals(objectIdentity.getType(), "BRANCH"); }
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//from w w w.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", "unchecked" }) @Test//from ww w. j ava 2 s . c o m 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:net.projectmonkey.spring.acl.enhancement.identity.strategy.ConfigurableObjectIdentityRetrievalStrategyTest.java
@SuppressWarnings({ "rawtypes" }) @Test/*from w ww .ja va2 s . co m*/ 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:net.projectmonkey.spring.acl.enhancement.identity.strategy.ConfigurableObjectIdentityRetrievalStrategyTest.java
@SuppressWarnings({ "rawtypes" }) @Test//from ww w.j av a 2 s . co m 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.security.acl.TypeConvertingObjectIdentityGeneratorTest.java
@Test public void createObjectIdentityShouldNotConvertType() throws Exception { TypeConvertingObjectIdentityGenerator sut = createDefaultGenerator(); ObjectIdentity oid = sut.createObjectIdentity(1L, Branch.class.getSimpleName()); assertEquals(Branch.class.getSimpleName(), oid.getType()); }
From source file:net.projectmonkey.spring.acl.hbase.repository.AclRecordTest.java
@Test public void creatingIdentityWithByteArrayIdentifier() { NavigableMap<byte[], byte[]> familyMap = recordMap(byte[].class, false); AclRecord underTest = new AclRecord(ID.getBytes(), familyMap, null); ObjectIdentity returnedIdentity = underTest.getIdentity(); assertEquals(TYPE, returnedIdentity.getType()); assertTrue(ArrayUtils.isEquals(ID.getBytes(), returnedIdentity.getIdentifier())); assertTrue(ArrayUtils.isEquals(ID.getBytes(), underTest.getKey())); assertTrue(ArrayUtils.isEquals(byte[].class.getName().getBytes(), underTest.getIdTypeBytes())); assertEquals(new GrantedAuthoritySid(SOME_PRINCIPAL), underTest.getOwner()); }