List of usage examples for java.security PrivilegedAction PrivilegedAction
PrivilegedAction
From source file:org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter.java
/** * This method will drive the introspection of the class-level information. It will store the * gathered information in the pertinent data members of the <code>DescriptionBuilderComposite</code> * * @param composite - <code>DescriptionBuilderComposite</code> *//*www. ja v a2s . c o m*/ private void introspectClass(DescriptionBuilderComposite composite) { // Need to investigate this, probably want to specify composite.setClassLoader(ClassLoaderUtils.getClassLoader(serviceClass)); composite.setIsInterface(serviceClass.isInterface()); composite.setSuperClassName( serviceClass.getSuperclass() != null ? serviceClass.getSuperclass().getName() : null); composite.setClassName(serviceClass.getName()); setInterfaces(composite); setTypeTargettedAnnotations(composite); Field[] fields = (Field[]) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return serviceClass.getFields(); } }); if (fields.length > 0) { JavaFieldsToFDCConverter fieldConverter = new JavaFieldsToFDCConverter(fields); List<FieldDescriptionComposite> fdcList = fieldConverter.convertFields(); ConverterUtils.attachFieldDescriptionComposites(composite, fdcList); } if (serviceClass.getMethods().length > 0) { // Inherited methods and constructors for superclasses will be in a seperate DBC for // the superclass. We only need the ones actually declared in this class. Method[] methods = (Method[]) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return serviceClass.getDeclaredMethods(); } }); Constructor[] declaredConstructors = (Constructor[]) AccessController .doPrivileged(new PrivilegedAction() { public Object run() { return serviceClass.getDeclaredConstructors(); } }); JavaMethodsToMDCConverter methodConverter = new JavaMethodsToMDCConverter(methods, declaredConstructors, serviceClass.getName()); List<MethodDescriptionComposite> mdcList = methodConverter.convertMethods(); ConverterUtils.attachMethodDescriptionComposites(composite, mdcList); } }
From source file:org.acmsl.commons.regexpplugin.RegexpManager.java
/** * Retrieves current engine.// ww w. j ava2 s . co m * Note: The lookup mechanism is adapted from Commons-Logging. * @param useClassLoader whether to use class loader or not. * @return the engine information. * @throws RegexpEngineNotFoundException if no engine can be used. */ @NotNull protected RegexpEngine getEngine(final boolean useClassLoader) throws RegexpEngineNotFoundException { @NotNull final RegexpEngine result; @NotNull ClassLoader t_ClassLoader = getClass().getClassLoader(); if (useClassLoader) { // Identify the class loader we will be using t_ClassLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return getContextClassLoader(); } }); } result = getEngineUsingClassLoader(t_ClassLoader); return result; }
From source file:org.apache.struts2.jasper.runtime.PageContextImpl.java
public Object getAttribute(final String name) { if (name == null) { throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name")); }/*from w w w. j a v a2 s .co m*/ if (SecurityUtil.isPackageProtectionEnabled()) { return AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return doGetAttribute(name); } }); } else { return doGetAttribute(name); } }
From source file:org.apache.ranger.services.hive.client.HiveClient.java
public List<String> getTableList(String tableNameMatching, List<String> databaseList, List<String> tblNameList) throws HadoopException { final String tblNameMatching = tableNameMatching; final List<String> dbList = databaseList; final List<String> tblList = tblNameList; List<String> tableList = Subject.doAs(getLoginSubject(), new PrivilegedAction<List<String>>() { public List<String> run() { List<String> ret = null; try { ret = getTblList(tblNameMatching, dbList, tblList); } catch (HadoopException he) { LOG.error("<== HiveClient getTblList() :Unable to get the Table List", he); throw he; }//from www . j a v a 2s . c o m return ret; } }); return tableList; }
From source file:com.reelfx.controller.LinuxController.java
public static void deleteOutput() { AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override/*from w w w .j a v a 2 s . c o m*/ public Object run() { try { if (MERGED_OUTPUT_FILE.exists() && !MERGED_OUTPUT_FILE.delete()) throw new Exception("Can't delete the old preview file on Linux!"); } catch (Exception e) { e.printStackTrace(); } return null; } }); }
From source file:org.eclipse.gemini.blueprint.extender.internal.blueprint.event.EventAdminDispatcher.java
public void waiting(final BlueprintEvent event) { if (dispatcher != null) { try {//from www .ja va2 s.co m if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { dispatcher.waiting(event); return null; } }); } else { dispatcher.waiting(event); } } catch (Throwable th) { log.warn("Cannot dispatch event " + event, th); } } }
From source file:org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer.java
@SuppressWarnings("deprecation") public void runLocalization(final InetSocketAddress nmAddr) throws IOException, InterruptedException { // load credentials initDirs(conf, user, appId, lfs, localDirs, userFolder); final Credentials creds = new Credentials(); DataInputStream credFile = null; try {/*from w w w. j a v a 2 s.co m*/ // assume credentials in cwd // TODO: Fix Path tokenPath = new Path(String.format(TOKEN_FILE_NAME_FMT, localizerId)); credFile = lfs.open(tokenPath); creds.readTokenStorageStream(credFile); // Explicitly deleting token file. lfs.delete(tokenPath, false); } finally { if (credFile != null) { credFile.close(); } } // create localizer context UserGroupInformation remoteUser = UserGroupInformation.createRemoteUser(user); remoteUser.addToken(creds.getToken(LocalizerTokenIdentifier.KIND)); final LocalizationProtocol nodeManager = remoteUser.doAs(new PrivilegedAction<LocalizationProtocol>() { @Override public LocalizationProtocol run() { return getProxy(nmAddr); } }); // create user context UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user); for (Token<? extends TokenIdentifier> token : creds.getAllTokens()) { ugi.addToken(token); } ExecutorService exec = null; try { exec = createDownloadThreadPool(); CompletionService<Path> ecs = createCompletionService(exec); localizeFiles(nodeManager, ecs, ugi); return; } catch (Throwable e) { throw new IOException(e); } finally { try { if (exec != null) { exec.shutdownNow(); } LocalDirAllocator.removeContext(appCacheDirContextName); } finally { closeFileSystems(ugi); } } }
From source file:org.eclipse.gemini.blueprint.test.provisioning.internal.LocalFileSystemMavenRepository.java
/** * Find a local maven artifact. First tries to find the resource as a * packaged artifact produced by a local maven build, and if that fails will * search the local maven repository./*w w w .j a va 2s .c om*/ * * @param groupId - the groupId of the organization supplying the bundle * @param artifactId - the artifact id of the bundle * @param version - the version of the bundle * @param type - the extension type of the artifact * @return */ public Resource locateArtifact(final String groupId, final String artifactId, final String version, final String type) { init(); return (Resource) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { return localMavenBuildArtifact(groupId, artifactId, version, type); } catch (IllegalStateException illStateEx) { Resource localMavenBundle = localMavenBundle(groupId, artifactId, version, type); if (log.isDebugEnabled()) { StringBuilder buf = new StringBuilder(); buf.append("["); buf.append(groupId); buf.append("|"); buf.append(artifactId); buf.append("|"); buf.append(version); buf.append("]"); log.debug(buf + " local maven build artifact detection failed, falling back to local maven bundle " + localMavenBundle.getDescription()); } return localMavenBundle; } } }); }
From source file:SecuritySupport.java
InputStream getResourceAsStream(final ClassLoader cl, final String name) { return (InputStream) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { InputStream ris;//from w w w. j a va 2 s.c om if (cl == null) { ris = ClassLoader.getSystemResourceAsStream(name); } else { ris = cl.getResourceAsStream(name); } return ris; } }); }
From source file:org.rhq.enterprise.client.LocalClient.java
@Override public ContentManagerRemote getContentManager() { return AccessController.doPrivileged(new PrivilegedAction<ContentManagerRemote>() { @Override// w w w . ja v a2 s . co m public ContentManagerRemote run() { return getProxy(LookupUtil.getContentManager(), ContentManagerRemote.class); } }); }