Java Code Examples for java.security.PrivilegedExceptionAction#run()
The following examples show how to use
java.security.PrivilegedExceptionAction#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: TestDelegationToken.java From big-c with Apache License 2.0 | 5 votes |
private void shouldThrow(PrivilegedExceptionAction<Object> action, Class<? extends Throwable> except) { try { action.run(); Assert.fail("action did not throw " + except); } catch (Throwable th) { LOG.info("Caught an exception: ", th); assertEquals("action threw wrong exception", except, th.getClass()); } }
Example 2
Source File: GetHDFSSequenceFile.java From localization_nifi with Apache License 2.0 | 5 votes |
protected Set<FlowFile> getFlowFiles(final Configuration conf, final FileSystem hdfs, final SequenceFileReader<Set<FlowFile>> reader, final Path file) throws Exception { PrivilegedExceptionAction<Set<FlowFile>> privilegedExceptionAction = new PrivilegedExceptionAction<Set<FlowFile>>() { @Override public Set<FlowFile> run() throws Exception { return reader.readSequenceFile(file, conf, hdfs); } }; UserGroupInformation userGroupInformation = getUserGroupInformation(); if (userGroupInformation == null) { return privilegedExceptionAction.run(); } else { return userGroupInformation.doAs(privilegedExceptionAction); } }
Example 3
Source File: Executors.java From jtransc with Apache License 2.0 | 5 votes |
public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { Objects.requireNonNull(action); return new Callable<Object>() { public Object call() throws Exception { return action.run(); } }; }
Example 4
Source File: StramClientUtils.java From Bats with Apache License 2.0 | 5 votes |
public static <T> T doAs(String userName, PrivilegedExceptionAction<T> action) throws Exception { if (StringUtils.isNotBlank(userName) && !userName.equals(UserGroupInformation.getLoginUser().getShortUserName())) { LOG.info("Executing command as {}", userName); UserGroupInformation ugi = UserGroupInformation.createProxyUser(userName, UserGroupInformation.getLoginUser()); return ugi.doAs(action); } else { LOG.info("Executing command as if there is no login info: {}", userName); return action.run(); } }
Example 5
Source File: TestDelegationToken.java From hadoop with Apache License 2.0 | 5 votes |
private void shouldThrow(PrivilegedExceptionAction<Object> action, Class<? extends Throwable> except) { try { action.run(); Assert.fail("action did not throw " + except); } catch (Throwable th) { LOG.info("Caught an exception: ", th); assertEquals("action threw wrong exception", except, th.getClass()); } }
Example 6
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 exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 7
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 exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 8
Source File: Executors.java From openjdk-8 with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 9
Source File: Executors.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 10
Source File: Executors.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 11
Source File: Executors.java From Java8CN with Apache License 2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 12
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 exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 13
Source File: Executors.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 14
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 exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 15
Source File: Executors.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 16
Source File: Executors.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 17
Source File: Executors.java From jdk8u60 with GNU General Public License v2.0 | 3 votes |
/** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 18
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 exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { 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 exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }
Example 20
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 exception action and returns * its result. * @param action the privileged exception action to run * @return a callable object * @throws NullPointerException if action null */ public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if (action == null) throw new NullPointerException(); return new Callable<Object>() { public Object call() throws Exception { return action.run(); }}; }