List of usage examples for java.security AccessController doPrivileged
@CallerSensitive public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws PrivilegedActionException
From source file:edu.ku.brc.af.core.db.BackupServiceFactory.java
/** * Returns the instance to the singleton * @return the instance to the singleton *///w w w. ja va 2 s .c o m public static BackupServiceFactory getInstance() { if (instance != null) { return instance; } // else String factoryNameStr = AccessController.doPrivileged(new java.security.PrivilegedAction<String>() { public String run() { return System.getProperty(factoryName); } }); if (isNotEmpty(factoryNameStr)) { try { return instance = (BackupServiceFactory) Class.forName(factoryNameStr).newInstance(); } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BackupServiceFactory.class, e); InternalError error = new InternalError("Can't instantiate RecordSet factory " + factoryNameStr); //$NON-NLS-1$ error.initCause(e); throw error; } } return null; }
From source file:edu.ku.brc.helpers.ZipFileHelper.java
/** * /*w w w. ja v a 2 s .c om*/ */ public ZipFileHelper() { super(); AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { cleanUp(); } }); return null; } }); }
From source file:com.github.persapiens.jsfboot.undertow.JsfUndertowDeploymentInfoCustomizer.java
@Override public void customize(final DeploymentInfo di) { AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override/*from w ww .j a v a 2 s . co m*/ public Void run() { ClassLoader jsfClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader()); di.setClassLoader(jsfClassLoader); di.setResourceManager( new ClassPathResourceManager(jsfClassLoader, undertowProperties.getClassPathResource())); return null; } }); LOGGER.info("Setting Undertow classLoader to " + undertowProperties.getClassPathResource() + " directory"); }
From source file:SecuritySupport.java
static String getSystemProperty(final String propName) { return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(propName); }//from w w w . ja va2 s . com }); }
From source file:org.apache.openjpa.lib.conf.FileValue.java
protected String getInternalString() { return (value == null) ? null : AccessController.doPrivileged(J2DoPrivHelper.getAbsolutePathAction(value)); }
From source file:org.apache.axis.utils.BeanUtils.java
private static PropertyDescriptor[] getPropertyDescriptors(final Class secJavaType) { return (PropertyDescriptor[]) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { PropertyDescriptor[] result = null; // START FIX http://nagoya.apache.org/bugzilla/showattachment.cgi?attach_id=4937 try { // privileged code goes here if (AxisFault.class.isAssignableFrom(secJavaType)) { // Don't include AxisFault data result = Introspector.getBeanInfo(secJavaType, AxisFault.class).getPropertyDescriptors(); } else if (Throwable.class != secJavaType && Throwable.class.isAssignableFrom(secJavaType)) { // Don't include Throwable data result = Introspector.getBeanInfo(secJavaType, Throwable.class).getPropertyDescriptors(); } else { // privileged code goes here result = Introspector.getBeanInfo(secJavaType).getPropertyDescriptors(); }//from w ww . jav a2 s . c o m // END FIX http://nagoya.apache.org/bugzilla/showattachment.cgi?attach_id=4937 } catch (java.beans.IntrospectionException Iie) { } return result; } }); }
From source file:ddf.security.encryption.impl.EncryptionServiceImpl.java
public EncryptionServiceImpl() { crypter = AccessController.doPrivileged((PrivilegedAction<Crypter>) () -> new Crypter(CRYPTER_NAME)); }
From source file:org.codice.ddf.commands.util.DigitalSignature.java
public DigitalSignature() { Security security = Security.getInstance(); this.keyStore = AccessController.doPrivileged((PrivilegedAction<KeyStore>) security::getSystemKeyStore); }
From source file:edu.ku.brc.af.ui.weblink.WebLinkMgr.java
/** * Returns the instance to the singleton * @return the instance to the singleton *//*from w ww .j a va2 s . c o m*/ public static WebLinkMgr getInstance() { if (instance != null) { return instance; } // else String factoryNameStr = AccessController.doPrivileged(new java.security.PrivilegedAction<String>() { public String run() { return System.getProperty(factoryName); } }); if (isNotEmpty(factoryNameStr)) { try { return instance = (WebLinkMgr) Class.forName(factoryNameStr).newInstance(); } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WebLinkMgr.class, e); InternalError error = new InternalError("Can't instantiate WebLink factory " + factoryNameStr); //$NON-NLS-1$ error.initCause(e); throw error; } } // if not factory than pass an instance of this in // and this does nothing to the SQL. return instance = new WebLinkMgr(); }
From source file:spring.osgi.context.internal.classloader.BundleDelegatingClassLoader.java
/** * Factory method for creating a class loader over the given bundle and with * a given class loader as fall-back. In case the bundle cannot find a class * or locate a resource, the given class loader will be used as fall back. * * @param bundle bundle used for class loading and resource acquisition * @param bridge class loader used as fall back in case the bundle cannot * load a class or find a resource. Can be <code>null</code> * @return class loader adapter over the given bundle and class loader */// w ww. jav a 2 s . c o m public static BundleDelegatingClassLoader createBundleClassLoaderFor(final Bundle bundle, final ClassLoader bridge) { return (BundleDelegatingClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return new BundleDelegatingClassLoader(bundle, bridge); } }); }