Java Code Examples for java.security.PrivilegedAction#run()
The following examples show how to use
java.security.PrivilegedAction#run() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecurityUtil.java From hadoop with Apache License 2.0 | 6 votes |
/** * Perform the given action as the daemon's login user. If the login * user cannot be determined, this will log a FATAL error and exit * the whole JVM. */ public static <T> T doAsLoginUserOrFatal(PrivilegedAction<T> action) { if (UserGroupInformation.isSecurityEnabled()) { UserGroupInformation ugi = null; try { ugi = UserGroupInformation.getLoginUser(); } catch (IOException e) { LOG.fatal("Exception while getting login user", e); e.printStackTrace(); Runtime.getRuntime().exit(-1); } return ugi.doAs(action); } else { return action.run(); } }
Example 2
Source File: HibernateMethodLookupDispatcher.java From lams with GNU General Public License v2.0 | 5 votes |
private static Method doPrivilegedAction(PrivilegedAction<Method> privilegedAction) { Class<?> callerClass = getCallerClass(); if ( !authorizedClasses.contains( callerClass.getName() ) ) { throw new SecurityException( "Unauthorized call by class " + callerClass ); } return System.getSecurityManager() != null ? AccessController.doPrivileged( privilegedAction ) : privilegedAction.run(); }
Example 3
Source File: RMIConnectionImpl.java From JDKSourceCode1.8 with MIT License | 4 votes |
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // returns null to force the client to stop fetching if (logger.debugOn()) logger.debug("fetchNotifications", "The notification server has been closed, " + "returns null to force the client to stop fetching"); return null; } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
Example 4
Source File: TAccessController.java From Bytecoder with Apache License 2.0 | 4 votes |
public static <T> T doPrivileged(final PrivilegedAction<T> action) { return action.run(); }
Example 5
Source File: RMIConnectionImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // returns null to force the client to stop fetching if (logger.debugOn()) logger.debug("fetchNotifications", "The notification server has been closed, " + "returns null to force the client to stop fetching"); return null; } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
Example 6
Source File: QuarkusDirContextFactory.java From quarkus with Apache License 2.0 | 4 votes |
private static <T> T doPrivileged(final PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged(action) : action.run(); }
Example 7
Source File: DelegatingLdapContext.java From quarkus with Apache License 2.0 | 4 votes |
private static <T> T doPrivileged(final PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged(action) : action.run(); }
Example 8
Source File: RMIConnectionImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // returns null to force the client to stop fetching if (logger.debugOn()) logger.debug("fetchNotifications", "The notification server has been closed, " + "returns null to force the client to stop fetching"); return null; } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
Example 9
Source File: RMIConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // returns null to force the client to stop fetching if (logger.debugOn()) logger.debug("fetchNotifications", "The notification server has been closed, " + "returns null to force the client to stop fetching"); return null; } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
Example 10
Source File: TAccessController.java From Bytecoder with Apache License 2.0 | 4 votes |
public static <T> T doPrivileged(final PrivilegedAction<T> action, final AccessControlContext context) { return action.run(); }
Example 11
Source File: RMIConnectionImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // returns null to force the client to stop fetching if (logger.debugOn()) logger.debug("fetchNotifications", "The notification server has been closed, " + "returns null to force the client to stop fetching"); return null; } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
Example 12
Source File: RMIConnectionImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // returns null to force the client to stop fetching if (logger.debugOn()) logger.debug("fetchNotifications", "The notification server has been closed, " + "returns null to force the client to stop fetching"); return null; } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
Example 13
Source File: RMIConnectionImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // returns null to force the client to stop fetching if (logger.debugOn()) logger.debug("fetchNotifications", "The notification server has been closed, " + "returns null to force the client to stop fetching"); return null; } final long csn = clientSequenceNumber; final int mn = maxNotifications; final long t = timeout; PrivilegedAction<NotificationResult> action = new PrivilegedAction<NotificationResult>() { public NotificationResult run() { return getServerNotifFwd().fetchNotifs(csn, t, mn); } }; if (acc == null) return action.run(); else return AccessController.doPrivileged(action, acc); } finally { serverCommunicatorAdmin.rspOutgoing(); } }
Example 14
Source File: Executors.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged action and returns its result. * @param action the privileged action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() { return action.run(); }}; }
Example 15
Source File: Executors.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged action and returns its result. * @param action the privileged action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() { return action.run(); }}; }
Example 16
Source File: Executors.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged action and returns its result. * @param action the privileged action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() { return action.run(); }}; }
Example 17
Source File: Executors.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged action and returns its result. * @param action the privileged action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() { return action.run(); }}; }
Example 18
Source File: Executors.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged action and returns its result. * @param action the privileged action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() { return action.run(); }}; }
Example 19
Source File: Executors.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged action and returns its result. * @param action the privileged action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() { return action.run(); }}; }
Example 20
Source File: ArcConstraintValidatorFactoryImpl.java From quarkus with Apache License 2.0 | 2 votes |
/** * Runs the given privileged action, using a privileged block if required. * <p> * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged(action) : action.run(); }