List of usage examples for java.security AccessController doPrivileged
@CallerSensitive public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws PrivilegedActionException
From source file:org.beangle.model.persist.hibernate.internal.ChainedClassLoader.java
public Class<?> loadClass(final String name) throws ClassNotFoundException { if (System.getSecurityManager() != null) { try {/* w ww. j a v a2s .com*/ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() { public Class<?> run() throws Exception { return doLoadClass(name); } }); } catch (PrivilegedActionException pae) { throw (ClassNotFoundException) pae.getException(); } } else { return doLoadClass(name); } }
From source file:it.cnr.icar.eric.server.container.DerbyHelper.java
/** * {@inheritDoc}/*from ww w . ja v a 2s .co m*/ * In this case, set ${derby.system.home} System property to provided * {@code configDirectory} value, if any. Does nothing for callers * with a consistent current directory -- for which this property * setting and the parameter value are unecessary. */ public void initialize(String configDirectory, GenericListener listener) { if (null != configDirectory && 0 < configDirectory.length()) { try { AccessController.doPrivileged(new SetDerbySystemProp(configDirectory)); } catch (Exception e) { log.error(rb.getString("message.failureSettingDerbyHome"), e); } } this.listener = listener; }
From source file:com.datos.vfs.impl.PrivilegedFileReplicator.java
/** * Creates a local copy of the file, and all its descendants. * * @param srcFile The source FileObject. * @param selector The file selector./*from w w w . j a v a 2 s. c om*/ * @return The replicated file. * @throws FileSystemException if an error occurs. */ @Override public File replicateFile(final FileObject srcFile, final FileSelector selector) throws FileSystemException { try { final ReplicateAction action = new ReplicateAction(srcFile, selector); return AccessController.doPrivileged(action); } catch (final PrivilegedActionException e) { throw new FileSystemException("vfs.impl/replicate-file.error", e, srcFile.getName()); } }
From source file:edu.ku.brc.dbsupport.SchemaUpdateService.java
/** * Returns the instance of the AppContextMgr. * @return the instance of the AppContextMgr. *///from ww w . java2 s .c o m public static SchemaUpdateService getInstance() { if (instance != null) { return instance; } // else String factoryNameStr = AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty(factoryName); } }); if (factoryNameStr != null) { try { instance = (SchemaUpdateService) Class.forName(factoryNameStr).newInstance(); return instance; } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaUpdateService.class, e); InternalError error = new InternalError( "Can't instantiate AppContextMgr factory " + factoryNameStr); //$NON-NLS-1$ error.initCause(e); throw error; } } return null; }
From source file:org.apache.openjpa.lib.util.Files.java
/** * Return the file for the class resource with the given extension. *//* w ww. j a v a 2s. c o m*/ private static File getClassFile(Class cls, String ext) { String name = Strings.getClassName(cls); // if it's an inner class, use the parent class name int innerIdx = name.indexOf('$'); if (innerIdx != -1) name = name.substring(0, innerIdx); URL rsrc = AccessController.doPrivileged(J2DoPrivHelper.getResourceAction(cls, name + ext)); if (rsrc != null && rsrc.getProtocol().equals("file")) return new File(URLDecoder.decode(rsrc.getFile())); return null; }
From source file:com.stratuscom.harvester.Utils.java
public static void logGrantsToClass(final Logger log, final Level level, final Class c) { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { ClassLoader cl = c.getClassLoader(); DynamicPolicyProvider dpp = (DynamicPolicyProvider) Policy.getPolicy(); Permission[] perms = dpp.getGrants(c, null); log.log(level, MessageNames.GRANTS_TO_CLASS_ARE, new Object[] { c.getName(), Utils.format(perms) }); return null; }/*from ww w. j a va 2 s. c o m*/ }); }
From source file:org.apache.ws.security.util.Loader.java
/** * Get the class loader of the class argument * <p/>/*from www .j ava 2s. c o m*/ * * @return the class loader of the argument */ public static ClassLoader getClassLoader(final Class clazz) { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return clazz.getClassLoader(); } }); }
From source file:gridool.util.system.SystemUtils.java
public static boolean isEpollEnabled() { final String osname = AccessController.doPrivileged(new GetPropertyAction("os.name")); if ("SunOS".equals(osname)) { return true; }/*w ww . ja v a 2 s.c o m*/ // use EPollSelectorProvider for Linux kernels >= 2.6 if ("Linux".equals(osname)) { String osversion = AccessController.doPrivileged(new GetPropertyAction("os.version")); final String[] vers = osversion.split("\\.", 0); if (vers.length >= 2) { try { final int major = Integer.parseInt(vers[0]); final int minor = Integer.parseInt(vers[1]); if (major > 2 || (major == 2 && minor >= 6)) { return true; } } catch (NumberFormatException x) { // format not recognized } } } return false; }
From source file:org.codice.ddf.admin.application.service.command.ProfileInstallCommand.java
@Override protected final void doExecute(ApplicationService applicationService, FeaturesService featuresService, BundleService bundleService) throws Exception { profileName = profileName.trim();//from ww w. j av a2 s. c om if (profileName.startsWith(".") || profileName.startsWith("/") || profileName.matches("((?i)(?s)[A-Z]):.*")) { throw new IllegalArgumentException( "Profile Name must not start with '.', '/', or a windows drive letter"); } try { AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> { installProfile(applicationService, featuresService, bundleService, profileName); return null; }); } catch (PrivilegedActionException e) { throw e.getException(); } }
From source file:org.apache.openjpa.persistence.PersistenceProductDerivation.java
@Override public void validate() throws Exception { // make sure JPA is available AccessController .doPrivileged(J2DoPrivHelper.getClassLoaderAction(javax.persistence.EntityManagerFactory.class)); }