private static <T> Iterable<T> load(Class<T> providerClass) { PrivilegedAction<Iterable<T>> action = new PrivilegedAction<Iterable<T>>() { @Override public Iterable<T> run() { return ServiceLoader.load(providerClass, providerClass.getClassLoader()); } }; return WildFlySecurityManager.doUnchecked(action); }
private Thread setContextClassLoader(Thread thread) { PrivilegedAction<Thread> action = () -> { thread.setContextClassLoader(this.loader); return thread; }; return WildFlySecurityManager.doUnchecked(action); }
private static ThreadFactory createThreadFactory() { PrivilegedAction<ThreadFactory> action = () -> new JBossThreadFactory(new ThreadGroup(InfinispanSessionManager.class.getSimpleName()), Boolean.FALSE, null, "%G - %t", null, null); return WildFlySecurityManager.doUnchecked(action); }
private static ThreadFactory createThreadFactory(Class<?> targetClass) { PrivilegedAction<ThreadFactory> action = () -> new JBossThreadFactory(new ThreadGroup(targetClass.getSimpleName()), Boolean.FALSE, null, "%G - %t", null, null); return new ClassLoaderThreadFactory(WildFlySecurityManager.doUnchecked(action), targetClass.getClassLoader()); }
private void unregister(GroupListener listener) { ExecutorService executor = this.listeners.remove(listener); if (executor != null) { PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); try { executor.awaitTermination(this.cache.getCacheConfiguration().transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
private static ThreadFactory createThreadFactory(Class<?> targetClass) { PrivilegedAction<ThreadFactory> action = () -> new ClassLoaderThreadFactory(new JBossThreadFactory(new ThreadGroup(targetClass.getSimpleName()), Boolean.FALSE, null, "%G - %t", null, null), targetClass.getClassLoader()); return WildFlySecurityManager.doUnchecked(action); }
private static ThreadFactory createThreadFactory(Class<?> targetClass) { PrivilegedAction<ThreadFactory> action = () -> new ClassLoaderThreadFactory(new JBossThreadFactory(new ThreadGroup(targetClass.getSimpleName()), Boolean.FALSE, null, "%G - %t", null, null), targetClass.getClassLoader()); return WildFlySecurityManager.doUnchecked(action); }
private static ThreadFactory createThreadFactory(Class<?> targetClass) { PrivilegedAction<ThreadFactory> action = () -> new ClassLoaderThreadFactory(new JBossThreadFactory(new ThreadGroup(targetClass.getSimpleName()), Boolean.FALSE, null, "%G - %t", null, null), targetClass.getClassLoader()); return WildFlySecurityManager.doUnchecked(action); }
private void shutdown(ExecutorService executor) { PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); try { executor.awaitTermination(this.cache.getCacheConfiguration().transaction().cacheStopTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
@Override public void close() { this.cache.removeListener(this); this.cache.getCacheManager().removeListener(this); // Cleanup any unregistered listeners for (ExecutorService executor : this.listeners.values()) { PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow(); WildFlySecurityManager.doUnchecked(action); } this.listeners.clear(); }
private void setConnection(final RemoteConnection remoteConnection) { if (WildFlySecurityManager.isChecking()) { WildFlySecurityManager.doUnchecked(new PrivilegedAction<Void>() { @Override public Void run() { RemotingContext.setConnection(remoteConnection); return null; } }); } else { RemotingContext.setConnection(remoteConnection); } }
private List<ValidationProvider<?>> getValidationProviders(final ClassLoader classLoader) { if(WildFlySecurityManager.isChecking()) { return WildFlySecurityManager.doUnchecked(new PrivilegedAction<List<ValidationProvider<?>>>() { @Override public List<ValidationProvider<?>> run() { return loadProviders(classLoader); } }); } else { return loadProviders(classLoader); } }
private String setContextID(PrivilegedAction<String> action) { if(WildFlySecurityManager.isChecking()) { return WildFlySecurityManager.doUnchecked(action); }else { return action.run(); } }
@Override public ExecutorService createExecutor(ThreadFactory factory) { return super.createExecutor(new ClassLoaderThreadFactory(factory, WildFlySecurityManager.doUnchecked(GET_CLASS_LOADER_ACTION))); } };
static void setSecurityRoles(final Map<String, Set<String>> roles) { if(WildFlySecurityManager.isChecking()) { WildFlySecurityManager.doUnchecked(new PrivilegedAction<Void>() { public Void run() { SecurityRolesAssociation.setSecurityRoles(roles); return null; } }); } else { SecurityRolesAssociation.setSecurityRoles(roles); } }
@Override public void start(final StartContext context) { if (WildFlySecurityManager.isChecking()) { WildFlySecurityManager.doUnchecked(new PrivilegedAction<Void>() { public Void run() { doStart(); return null; } }); } else { doStart(); } }
private RemoteConnection getConnection() { if(WildFlySecurityManager.isChecking()) { return WildFlySecurityManager.doUnchecked((PrivilegedAction<RemoteConnection>) () -> RemotingContext.getRemoteConnection()); } else { return RemotingContext.getRemoteConnection(); } }
@Override public ScheduledExecutorService createExecutor(ThreadFactory factory) { // Use fixed size, based on maxThreads ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(maxThreads, new ClassLoaderThreadFactory(factory, WildFlySecurityManager.doUnchecked(GET_CLASS_LOADER_ACTION))); executor.setKeepAliveTime(keepAliveTime, TimeUnit.MILLISECONDS); executor.setRemoveOnCancelPolicy(true); executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); return executor; }
public Principal getCallerPrincipal() { if (isSecurityDomainKnown()) { return getCallerSecurityIdentity().getPrincipal(); } else if (WildFlySecurityManager.isChecking()) { return WildFlySecurityManager.doUnchecked(getCaller); } else { return this.serverSecurityManager.getCallerPrincipal(); } }
private ObjectCloner createCloner(final ClonerConfiguration paramConfig) { ObjectCloner parameterCloner; if(WildFlySecurityManager.isChecking()) { parameterCloner = WildFlySecurityManager.doUnchecked((PrivilegedAction<ObjectCloner>) () -> ObjectCloners.getSerializingObjectClonerFactory().createCloner(paramConfig)); } else { parameterCloner = ObjectCloners.getSerializingObjectClonerFactory().createCloner(paramConfig); } return parameterCloner; }