List of usage examples for java.security PrivilegedAction PrivilegedAction
PrivilegedAction
From source file:com.scoredev.scores.HighScore.java
public HighScore(String gameName) { this.gameName = gameName; AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String path = System.getProperty("user.home") + File.separator + ".highscore"; highScoreFile = new File(path); return null; }/*from w w w . j ava2 s .co m*/ }); }
From source file:com.amazonaws.http.conn.ssl.privileged.PrivilegedMasterSecretValidator.java
/** * Double check the master secret of an SSL session is not null * /* w ww . j ava 2 s . co m*/ * @param socket * connected socket * @return True if master secret is valid (i.e. non-null) or master secret cannot be validated, * false otherwise */ public boolean isMasterSecretValid(final Socket socket) { return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { return privilegedIsMasterSecretValid(socket); } }); }
From source file:org.eclipse.gemini.blueprint.config.internal.adapter.CustomListenerAdapterUtils.java
/** * Specialised reflection utility that determines all methods that accept two parameters such: * /*from w w w. java 2 s . co m*/ * <pre> methodName(Type serviceType, Type1 arg) * * methodName(Type serviceType, Type2 arg) * * methodName(AnotherType serviceType, Type1 arg) * * methodName(Type serviceType) </pre> * * It will return a map which has the serviceType (first argument) as type and contains as list the variants of * methods using the second argument. This method is normally used by listeners when determining custom methods. * * @param target * @param methodName * @param possibleArgumentTypes * @param modifier * @return */ static Map<Class<?>, List<Method>> determineCustomMethods(final Class<?> target, final String methodName, final Class<?>[] possibleArgumentTypes, final boolean onlyPublic) { if (!StringUtils.hasText(methodName)) { return Collections.emptyMap(); } Assert.notEmpty(possibleArgumentTypes); if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedAction<Map<Class<?>, List<Method>>>() { public Map<Class<?>, List<Method>> run() { return doDetermineCustomMethods(target, methodName, possibleArgumentTypes, onlyPublic); } }); } else { return doDetermineCustomMethods(target, methodName, possibleArgumentTypes, onlyPublic); } }
From source file:org.codehaus.groovy.grails.web.pages.discovery.CachingGrailsConventionGroovyPageLocator.java
@Override public GroovyPageScriptSource findPageInBinding(final String uri, final GroovyPageBinding binding) { if (uri == null) return null; PrivilegedAction<GroovyPageScriptSource> updater = new PrivilegedAction<GroovyPageScriptSource>() { public GroovyPageScriptSource run() { GroovyPageScriptSource scriptSource = CachingGrailsConventionGroovyPageLocator.super.findPageInBinding( uri, binding);//from ww w . j a v a2s . c o m if (scriptSource == null) { scriptSource = NULL_SCRIPT; } return scriptSource; } }; return lookupCache(GroovyPageLocatorCacheKey.build(uri, null, binding), updater); }
From source file:org.ow2.chameleon.core.utils.FrameworkClassLoader.java
/** * Gets an instance of {@link org.ow2.chameleon.core.utils.FrameworkClassLoader}. * * @param basedir the base directory. The 'libs' folder must be a direct child of this directory. * @return the instance of classloader./*from w w w . j av a 2 s . c o m*/ */ public static ClassLoader getFrameworkClassLoader(final File basedir) { return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { return new FrameworkClassLoader(basedir, null); } }); }
From source file:com.agimatec.validation.jsr303.util.SecureActions.java
public static Field getDeclaredField(final Class clazz, final String fieldName) { return run(new PrivilegedAction<Field>() { public Field run() { try { Field f = clazz.getDeclaredField(fieldName); setAccessibility(f);/* ww w . j a va2s . c o m*/ return f; } catch (NoSuchFieldException e) { return null; } } }); }
From source file:edu.ku.brc.af.core.SchemaI18NService.java
/** * Returns the instance of the AppContextMgr. * @return the instance of the AppContextMgr. *///from ww w . j a v a 2 s.c o m public static SchemaI18NService 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 = (SchemaI18NService) Class.forName(factoryNameStr).newInstance(); return instance; } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaI18NService.class, e); InternalError error = new InternalError( "Can't instantiate SchemaI18NService factory " + factoryNameStr); //$NON-NLS-1$ error.initCause(e); throw error; } } throw new RuntimeException("The System porpoerty [" + factoryName + "] has not been set up!"); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:org.exoplatform.services.command.impl.CommandService.java
public CommandService() { this.catalogFactory = CatalogFactoryBase.getInstance(); final ConfigParser parser = new ConfigParser(); this.digester = SecurityHelper.doPrivilegedAction(new PrivilegedAction<Digester>() { public Digester run() { return parser.getDigester(); }//from www . j a v a 2s. co m }); }
From source file:org.apache.xml.security.Init.java
/** * Method init// ww w . j a v a2 s .co m * */ public synchronized static void init() { if (alreadyInitialized) { return; } InputStream is = AccessController.doPrivileged(new PrivilegedAction<InputStream>() { public InputStream run() { String cfile = System.getProperty("org.apache.xml.security.resource.config"); if (cfile == null) { return null; } return getClass().getResourceAsStream(cfile); } }); if (is == null) { dynamicInit(); } else { fileInit(is); } alreadyInitialized = true; }
From source file:com.github.persapiens.jsfboot.jetty.JsfJettyServerCustomizer.java
@Override public void customize(Server server) { Handler[] childHandlersByClass = server.getChildHandlersByClass(WebAppContext.class); final WebAppContext webAppContext = (WebAppContext) childHandlersByClass[0]; try {//from w w w . j av a 2 s . co m ClassPathResource classPathResource = new ClassPathResource( this.jettyProperties.getClassPathResource()); webAppContext.setBaseResource(new ResourceCollection(classPathResource.getURI().toString())); AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override public Void run() { webAppContext.setClassLoader(new URLClassLoader(new URL[0], this.getClass().getClassLoader())); return null; } }); LOGGER.info( "Setting Jetty classLoader to " + this.jettyProperties.getClassPathResource() + " directory"); } catch (IOException exception) { LOGGER.error("Unable to configure Jetty classLoader to " + this.jettyProperties.getClassPathResource() + " directory " + exception.getMessage()); throw new RuntimeException(exception); } }