...
 
Commits (2)
......@@ -431,7 +431,8 @@ public class DefaultPermissionManager implements Clearable, PermissionManager {
// Yes if oid has bound source object and permission applies to that object
if (oid.getSourceObject().isPresent()) {
return oid.getSourceObject().map(Object::getClass)
return oid.getSourceObject().map(sourceObject ->
sourceObject instanceof Class<?> ? (Class<?>) sourceObject : sourceObject.getClass())
.filter(targetType -> isTargetTypeApplicable(permission, targetType))
.isPresent();
}
......
......@@ -25,7 +25,7 @@ import javax.inject.Provider;
public class PlayAuthCacheProvider implements Provider<Cache> {
public static final String MANGER_NAME = "ch.insign.playauth";
private static final String CONFIG_FILE_PATH = "ch.insign.playauth.ehcache.xml";
public static final String CONFIG_FILE_PATH = "ch.insign.playauth.ehcache.xml";
private final Cache cache;
......
......@@ -16,6 +16,7 @@
package ch.insign.playauth.authz;
import ch.insign.commons.util.Cache;
import ch.insign.playauth.authz.mock.AccessControlListMock;
import ch.insign.playauth.authz.mock.PermissionManagerProviderMock;
import ch.insign.playauth.authz.support.DefaultAccessControlListVoter;
......@@ -29,6 +30,8 @@ import play.inject.Injector;
import java.util.Optional;
import static ch.insign.playauth.providers.PlayAuthCacheProvider.CONFIG_FILE_PATH;
import static ch.insign.playauth.providers.PlayAuthCacheProvider.MANGER_NAME;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
......@@ -62,8 +65,9 @@ public class AccessControlListVoterTest {
ObjectIdentityRetrievalStrategy oidrs = new DefaultObjectIdentityRetrievalStrategy(pmp, injector);
SecurityIdentityRetrievalStrategy sidrs = new DefaultSecurityIdentityRetrievalStrategy();
PermissionManager pm = pmp.set(new DefaultPermissionManager(acl, oidrs, null, Environment.simple())).get();
Cache cache = new Cache(MANGER_NAME, this.getClass().getClassLoader().getResource(CONFIG_FILE_PATH));
AccessControlListVoter aclv = new DefaultAccessControlListVoter(dispatcher, pm, acl, sidrs, oidrs);
AccessControlListVoter aclv = new DefaultAccessControlListVoter(dispatcher, pm, acl, cache, sidrs, oidrs);
// Authorities
SecurityIdentity anyone = SecurityIdentity.ALL;
......