package org.infinispan.query.dsl.embedded.impl;
import java.security.AccessController;
import java.security.PrivilegedAction;
import org.infinispan.AdvancedCache;
import org.infinispan.factories.ComponentRegistry;
import org.infinispan.security.AuthorizationManager;
import org.infinispan.security.Security;
import org.infinispan.security.actions.GetCacheAuthorizationManagerAction;
import org.infinispan.security.actions.GetCacheComponentRegistryAction;
/**
* SecurityActions for the org.infinispan.query.dsl.embedded.impl package. Do not move and do not change class and
* method visibility!
*
* @author anistor@redhat.com
* @since 7.2
*/
final class SecurityActions {
private SecurityActions() {
}
static <T> T doPrivileged(PrivilegedAction<T> action) {
return System.getSecurityManager() != null ?
AccessController.doPrivileged(action) : Security.doPrivileged(action);
}
static AuthorizationManager getCacheAuthorizationManager(AdvancedCache<?, ?> cache) {
return doPrivileged(new GetCacheAuthorizationManagerAction(cache));
}
static ComponentRegistry getCacheComponentRegistry(AdvancedCache<?, ?> cache) {
return doPrivileged(new GetCacheComponentRegistryAction(cache));
}
}