Java Code Examples for java.security.PrivilegedExceptionAction#run()
The following examples show how to use
java.security.PrivilegedExceptionAction#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: Bats File: StramClientUtils.java License: 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 2
Source Project: localization_nifi File: GetHDFSSequenceFile.java License: 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 Project: jtransc File: Executors.java License: 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 Project: hadoop File: TestDelegationToken.java License: 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 5
Source Project: big-c File: TestDelegationToken.java License: 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 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 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 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 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 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 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 Project: jdk8u60 File: Executors.java License: 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 Project: JDKSourceCode1.8 File: Executors.java License: 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 11
Source Project: openjdk-jdk8u File: Executors.java License: 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 12
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 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 Project: Bytecoder File: Executors.java License: 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 14
Source Project: openjdk-jdk9 File: Executors.java License: 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 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 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 Project: Java8CN File: Executors.java License: 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 17
Source Project: hottub File: Executors.java License: 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 Project: openjdk-8-source File: Executors.java License: 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 Project: openjdk-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 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 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 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(); }}; }