org.apache.felix.framework.util
Class SecureAction
java.lang.Object
org.apache.felix.framework.util.SecureAction
public class SecureAction
- extends Object
This is a utility class to centralize all action that should be performed
in a doPrivileged() block. To perform a secure action, simply
create an instance of this class and use the specific method to perform
the desired action. When an instance is created, this class will capture
the security context and will then use that context when checking for
permission to perform the action. Instances of this class should not be
passed around since they may grant the receiver a capability to perform
privileged actions.
Field Summary |
protected static int |
BUFSIZE
|
Method Summary |
void |
addURLToURLClassLoader(URL extension,
ClassLoader loader)
|
File |
createTempFile(String prefix,
String suffix,
File dir)
|
URL |
createURL(String protocol,
String host,
int port,
String path,
URLStreamHandler handler)
|
URL |
createURL(URL context,
String spec,
URLStreamHandler handler)
|
boolean |
deleteFile(File target)
|
Process |
exec(String command)
|
boolean |
fileExists(File file)
|
void |
flush(Class targetClazz,
Object lock)
|
Class |
forName(String name)
|
String |
getAbsolutePath(File file)
|
ClassLoader |
getClassLoader(Class clazz)
|
Constructor |
getConstructor(Class target,
Class[] types)
|
Constructor |
getDeclaredConstructor(Class target,
Class[] types)
|
Object |
getDeclaredField(Class targetClass,
String name,
Object target)
|
Method |
getDeclaredMethod(Class target,
String method,
Class[] types)
|
FileInputStream |
getFileInputStream(File file)
|
FileOutputStream |
getFileOutputStream(File file)
|
Method |
getMethod(Class target,
String method,
Class[] types)
|
ClassLoader |
getParentClassLoader(ClassLoader loader)
|
Policy |
getPolicy()
|
ClassLoader |
getSystemClassLoader()
|
String |
getSystemProperty(String name,
String def)
|
InputStream |
getURLConnectionInputStream(URLConnection conn)
|
Object |
invoke(Constructor constructor,
Object[] params)
|
Object |
invoke(Method method,
Object target,
Object[] params)
|
Object |
invokeDirect(Method method,
Object target,
Object[] params)
|
boolean |
isFileDirectory(File file)
|
File[] |
listDirectory(File file)
|
boolean |
mkdir(File file)
|
boolean |
mkdirs(File file)
|
URLConnection |
openURLConnection(URL url)
|
ZipFileX |
openZipFile(File file)
|
boolean |
renameFile(File oldFile,
File newFile)
|
void |
setAccesssible(AccessibleObject ao)
|
void |
startActivator(BundleActivator activator,
BundleContext context)
|
void |
stopActivator(BundleActivator activator,
BundleContext context)
|
Object |
swapStaticFieldIfNotClass(Class targetClazz,
Class targetType,
Class condition,
String lockName)
|
URI |
toURI(File file)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BUFSIZE
protected static transient int BUFSIZE
SecureAction
public SecureAction()
getSystemProperty
public String getSystemProperty(String name,
String def)
getParentClassLoader
public ClassLoader getParentClassLoader(ClassLoader loader)
getSystemClassLoader
public ClassLoader getSystemClassLoader()
getClassLoader
public ClassLoader getClassLoader(Class clazz)
forName
public Class forName(String name)
throws ClassNotFoundException
- Throws:
ClassNotFoundException
createURL
public URL createURL(String protocol,
String host,
int port,
String path,
URLStreamHandler handler)
throws MalformedURLException
- Throws:
MalformedURLException
createURL
public URL createURL(URL context,
String spec,
URLStreamHandler handler)
throws MalformedURLException
- Throws:
MalformedURLException
exec
public Process exec(String command)
throws IOException
- Throws:
IOException
getAbsolutePath
public String getAbsolutePath(File file)
fileExists
public boolean fileExists(File file)
isFileDirectory
public boolean isFileDirectory(File file)
mkdir
public boolean mkdir(File file)
mkdirs
public boolean mkdirs(File file)
listDirectory
public File[] listDirectory(File file)
renameFile
public boolean renameFile(File oldFile,
File newFile)
getFileInputStream
public FileInputStream getFileInputStream(File file)
throws IOException
- Throws:
IOException
getFileOutputStream
public FileOutputStream getFileOutputStream(File file)
throws IOException
- Throws:
IOException
toURI
public URI toURI(File file)
getURLConnectionInputStream
public InputStream getURLConnectionInputStream(URLConnection conn)
throws IOException
- Throws:
IOException
deleteFile
public boolean deleteFile(File target)
createTempFile
public File createTempFile(String prefix,
String suffix,
File dir)
throws IOException
- Throws:
IOException
openURLConnection
public URLConnection openURLConnection(URL url)
throws IOException
- Throws:
IOException
openZipFile
public ZipFileX openZipFile(File file)
throws IOException
- Throws:
IOException
startActivator
public void startActivator(BundleActivator activator,
BundleContext context)
throws Exception
- Throws:
Exception
stopActivator
public void stopActivator(BundleActivator activator,
BundleContext context)
throws Exception
- Throws:
Exception
getPolicy
public Policy getPolicy()
addURLToURLClassLoader
public void addURLToURLClassLoader(URL extension,
ClassLoader loader)
throws Exception
- Throws:
Exception
getConstructor
public Constructor getConstructor(Class target,
Class[] types)
throws Exception
- Throws:
Exception
getDeclaredConstructor
public Constructor getDeclaredConstructor(Class target,
Class[] types)
throws Exception
- Throws:
Exception
getMethod
public Method getMethod(Class target,
String method,
Class[] types)
throws Exception
- Throws:
Exception
getDeclaredMethod
public Method getDeclaredMethod(Class target,
String method,
Class[] types)
throws Exception
- Throws:
Exception
setAccesssible
public void setAccesssible(AccessibleObject ao)
invoke
public Object invoke(Method method,
Object target,
Object[] params)
throws Exception
- Throws:
Exception
invokeDirect
public Object invokeDirect(Method method,
Object target,
Object[] params)
throws Exception
- Throws:
Exception
invoke
public Object invoke(Constructor constructor,
Object[] params)
throws Exception
- Throws:
Exception
getDeclaredField
public Object getDeclaredField(Class targetClass,
String name,
Object target)
throws Exception
- Throws:
Exception
swapStaticFieldIfNotClass
public Object swapStaticFieldIfNotClass(Class targetClazz,
Class targetType,
Class condition,
String lockName)
throws Exception
- Throws:
Exception
flush
public void flush(Class targetClazz,
Object lock)
throws Exception
- Throws:
Exception
Copyright © 2011 Apache Software Foundation. All Rights Reserved.