Java Code Examples for java.security.PrivilegedAction#run()
The following examples show how to use
java.security.PrivilegedAction#run() .
These examples are extracted from open source projects.
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 Project: hadoop File: SecurityUtil.java License: 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 Project: lams File: HibernateMethodLookupDispatcher.java License: 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 Project: openjdk-jdk8u-backup File: RMIConnectionImpl.java License: 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 4
Source Project: dragonwell8_jdk File: RMIConnectionImpl.java License: 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 5
Source Project: TencentKona-8 File: RMIConnectionImpl.java License: 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 Project: Bytecoder File: TAccessController.java License: Apache License 2.0 | 4 votes |
public static <T> T doPrivileged(final PrivilegedAction<T> action, final AccessControlContext context) { return action.run(); }
Example 7
Source Project: openjdk-jdk9 File: RMIConnectionImpl.java License: 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 8
Source Project: jdk8u-jdk File: RMIConnectionImpl.java License: 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 Project: JDKSourceCode1.8 File: RMIConnectionImpl.java License: 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 10
Source Project: quarkus File: DelegatingLdapContext.java License: 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 11
Source Project: quarkus File: QuarkusDirContextFactory.java License: 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 12
Source Project: openjdk-jdk8u File: RMIConnectionImpl.java License: 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 Project: Bytecoder File: TAccessController.java License: Apache License 2.0 | 4 votes |
public static <T> T doPrivileged(final PrivilegedAction<T> action) { return action.run(); }
Example 14
Source Project: jdk1.8-source-analysis File: Executors.java License: 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 Project: dragonwell8_jdk File: Executors.java License: 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 16
Source Project: TencentKona-8 File: Executors.java License: 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 Project: Bytecoder File: Executors.java License: 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 18
Source Project: jdk8u-jdk File: Executors.java License: 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 Project: openjdk-jdk8u-backup File: Executors.java License: 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 Project: quarkus File: ArcConstraintValidatorFactoryImpl.java License: 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(); }