Package org.apache.felix.framework.util
Class SecureAction
- java.lang.Object
-
- org.apache.felix.framework.util.SecureAction
-
public class SecureAction extends java.lang.ObjectThis 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
Fields Modifier and Type Field Description protected static intBUFSIZE
-
Constructor Summary
Constructors Constructor Description SecureAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddURLToURLClassLoader(java.net.URL extension, java.lang.ClassLoader loader)java.lang.ObjectcreateProxy(java.lang.ClassLoader classLoader, java.lang.Class<?>[] interfaces, java.lang.reflect.InvocationHandler handler)java.io.FilecreateTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File dir)java.net.URLcreateURL(java.lang.String protocol, java.lang.String host, int port, java.lang.String path, java.net.URLStreamHandler handler)java.net.URLcreateURL(java.net.URL context, java.lang.String spec, java.net.URLStreamHandler handler)booleandeleteFile(java.io.File target)voiddeleteFileOnExit(java.io.File file)java.lang.Processexec(java.lang.String command)booleanfileExists(java.io.File file)voidflush(java.lang.Class targetClazz, java.lang.Object lock)java.lang.ClassforName(java.lang.String name, java.lang.ClassLoader classloader)java.lang.StringgetAbsolutePath(java.io.File file)java.lang.StringgetCanonicalPath(java.io.File dataFile)java.lang.ClassLoadergetClassLoader(java.lang.Class clazz)java.lang.reflect.ConstructorgetConstructor(java.lang.Class target, java.lang.Class[] types)java.lang.reflect.ConstructorgetDeclaredConstructor(java.lang.Class target, java.lang.Class[] types)java.lang.ObjectgetDeclaredField(java.lang.Class targetClass, java.lang.String name, java.lang.Object target)java.lang.reflect.MethodgetDeclaredMethod(java.lang.Class target, java.lang.String method, java.lang.Class[] types)java.nio.channels.FileChannelgetFileChannel(java.io.File file)java.io.FileInputStreamgetFileInputStream(java.io.File file)java.io.FileOutputStreamgetFileOutputStream(java.io.File file)java.io.InputStreamgetInputStream(java.io.File file)longgetLastModified(java.io.File file)java.lang.reflect.MethodgetMethod(java.lang.Class target, java.lang.String method, java.lang.Class[] types)java.io.OutputStreamgetOutputStream(java.io.File file)java.lang.ClassLoadergetParentClassLoader(java.lang.ClassLoader loader)java.security.PolicygetPolicy()java.lang.ClassLoadergetSystemClassLoader()java.lang.StringgetSystemProperty(java.lang.String name, java.lang.String def)java.io.InputStreamgetURLConnectionInputStream(java.net.URLConnection conn)java.lang.Objectinvoke(java.lang.reflect.Constructor constructor, java.lang.Object[] params)java.lang.Objectinvoke(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] params)voidinvokeBundleCollisionHook(CollisionHook ch, int operationType, Bundle targetBundle, java.util.Collection<Bundle> collisionCandidates)voidinvokeBundleEventHook(EventHook eh, BundleEvent event, java.util.Collection<BundleContext> contexts)voidinvokeBundleFindHook(FindHook fh, BundleContext bc, java.util.Collection<Bundle> bundles)java.lang.ObjectinvokeDirect(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] params)voidinvokeResolverHookEnd(ResolverHook rh)ResolverHookinvokeResolverHookFactory(ResolverHookFactory rhf, java.util.Collection<BundleRevision> triggers)voidinvokeResolverHookMatches(ResolverHook rh, BundleRequirement req, java.util.Collection<BundleCapability> candidates)voidinvokeResolverHookResolvable(ResolverHook rh, java.util.Collection<BundleRevision> candidates)voidinvokeResolverHookSingleton(ResolverHook rh, BundleCapability singleton, java.util.Collection<BundleCapability> collisions)voidinvokeServiceEventHook(EventHook eh, ServiceEvent event, java.util.Collection<BundleContext> contexts)voidinvokeServiceEventListenerHook(EventListenerHook elh, ServiceEvent event, java.util.Map<BundleContext,java.util.Collection<ListenerHook.ListenerInfo>> listeners)voidinvokeServiceFindHook(FindHook fh, BundleContext context, java.lang.String name, java.lang.String filter, boolean allServices, java.util.Collection<ServiceReference<?>> references)voidinvokeServiceListenerHookAdded(ListenerHook lh, java.util.Collection<ListenerHook.ListenerInfo> listeners)voidinvokeServiceListenerHookRemoved(ListenerHook lh, java.util.Collection<ListenerHook.ListenerInfo> listeners)voidinvokeWeavingHook(WeavingHook wh, WovenClass wc)voidinvokeWovenClassListener(WovenClassListener wcl, WovenClass wc)booleanisFile(java.io.File file)booleanisFileDirectory(java.io.File file)java.io.File[]listDirectory(java.io.File file)booleanmkdir(java.io.File file)booleanmkdirs(java.io.File file)java.util.jar.JarFileopenJarFile(java.io.File file)java.net.URLConnectionopenURLConnection(java.net.URL url)java.util.zip.ZipFileopenZipFile(java.io.File file)booleanrenameFile(java.io.File oldFile, java.io.File newFile)<T> Trun(java.security.PrivilegedAction<T> action)<T> Trun(java.security.PrivilegedExceptionAction<T> action)voidsetAccesssible(java.lang.reflect.Executable ao)voidstartActivator(BundleActivator activator, BundleContext context)voidstopActivator(BundleActivator activator, BundleContext context)java.lang.ObjectswapStaticFieldIfNotClass(java.lang.Class targetClazz, java.lang.Class targetType, java.lang.Class condition, java.lang.String lockName)java.net.URItoURI(java.io.File file)
-
-
-
Method Detail
-
getSystemProperty
public java.lang.String getSystemProperty(java.lang.String name, java.lang.String def)
-
getParentClassLoader
public java.lang.ClassLoader getParentClassLoader(java.lang.ClassLoader loader)
-
getSystemClassLoader
public java.lang.ClassLoader getSystemClassLoader()
-
getClassLoader
public java.lang.ClassLoader getClassLoader(java.lang.Class clazz)
-
forName
public java.lang.Class forName(java.lang.String name, java.lang.ClassLoader classloader) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
createURL
public java.net.URL createURL(java.lang.String protocol, java.lang.String host, int port, java.lang.String path, java.net.URLStreamHandler handler) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
createURL
public java.net.URL createURL(java.net.URL context, java.lang.String spec, java.net.URLStreamHandler handler) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
exec
public java.lang.Process exec(java.lang.String command) throws java.io.IOException- Throws:
java.io.IOException
-
getAbsolutePath
public java.lang.String getAbsolutePath(java.io.File file)
-
fileExists
public boolean fileExists(java.io.File file)
-
isFile
public boolean isFile(java.io.File file)
-
isFileDirectory
public boolean isFileDirectory(java.io.File file)
-
mkdir
public boolean mkdir(java.io.File file)
-
mkdirs
public boolean mkdirs(java.io.File file)
-
listDirectory
public java.io.File[] listDirectory(java.io.File file)
-
renameFile
public boolean renameFile(java.io.File oldFile, java.io.File newFile)
-
getInputStream
public java.io.InputStream getInputStream(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
getOutputStream
public java.io.OutputStream getOutputStream(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
getFileInputStream
public java.io.FileInputStream getFileInputStream(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
getFileOutputStream
public java.io.FileOutputStream getFileOutputStream(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
getFileChannel
public java.nio.channels.FileChannel getFileChannel(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
toURI
public java.net.URI toURI(java.io.File file)
-
getURLConnectionInputStream
public java.io.InputStream getURLConnectionInputStream(java.net.URLConnection conn) throws java.io.IOException- Throws:
java.io.IOException
-
deleteFile
public boolean deleteFile(java.io.File target)
-
createTempFile
public java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File dir) throws java.io.IOException- Throws:
java.io.IOException
-
deleteFileOnExit
public void deleteFileOnExit(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
openURLConnection
public java.net.URLConnection openURLConnection(java.net.URL url) throws java.io.IOException- Throws:
java.io.IOException
-
openZipFile
public java.util.zip.ZipFile openZipFile(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
openJarFile
public java.util.jar.JarFile openJarFile(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
startActivator
public void startActivator(BundleActivator activator, BundleContext context) throws java.lang.Exception
- Throws:
java.lang.Exception
-
stopActivator
public void stopActivator(BundleActivator activator, BundleContext context) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getPolicy
public java.security.Policy getPolicy()
-
addURLToURLClassLoader
public void addURLToURLClassLoader(java.net.URL extension, java.lang.ClassLoader loader) throws java.lang.Exception- Throws:
java.lang.Exception
-
getConstructor
public java.lang.reflect.Constructor getConstructor(java.lang.Class target, java.lang.Class[] types) throws java.lang.Exception- Throws:
java.lang.Exception
-
getDeclaredConstructor
public java.lang.reflect.Constructor getDeclaredConstructor(java.lang.Class target, java.lang.Class[] types) throws java.lang.Exception- Throws:
java.lang.Exception
-
getMethod
public java.lang.reflect.Method getMethod(java.lang.Class target, java.lang.String method, java.lang.Class[] types) throws java.lang.Exception- Throws:
java.lang.Exception
-
getDeclaredMethod
public java.lang.reflect.Method getDeclaredMethod(java.lang.Class target, java.lang.String method, java.lang.Class[] types) throws java.lang.Exception- Throws:
java.lang.Exception
-
setAccesssible
public void setAccesssible(java.lang.reflect.Executable ao)
-
invoke
public java.lang.Object invoke(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] params) throws java.lang.Exception- Throws:
java.lang.Exception
-
invokeDirect
public java.lang.Object invokeDirect(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] params) throws java.lang.Exception- Throws:
java.lang.Exception
-
invoke
public java.lang.Object invoke(java.lang.reflect.Constructor constructor, java.lang.Object[] params) throws java.lang.Exception- Throws:
java.lang.Exception
-
getDeclaredField
public java.lang.Object getDeclaredField(java.lang.Class targetClass, java.lang.String name, java.lang.Object target) throws java.lang.Exception- Throws:
java.lang.Exception
-
swapStaticFieldIfNotClass
public java.lang.Object swapStaticFieldIfNotClass(java.lang.Class targetClazz, java.lang.Class targetType, java.lang.Class condition, java.lang.String lockName) throws java.lang.Exception- Throws:
java.lang.Exception
-
flush
public void flush(java.lang.Class targetClazz, java.lang.Object lock) throws java.lang.Exception- Throws:
java.lang.Exception
-
invokeBundleCollisionHook
public void invokeBundleCollisionHook(CollisionHook ch, int operationType, Bundle targetBundle, java.util.Collection<Bundle> collisionCandidates) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeBundleFindHook
public void invokeBundleFindHook(FindHook fh, BundleContext bc, java.util.Collection<Bundle> bundles) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeBundleEventHook
public void invokeBundleEventHook(EventHook eh, BundleEvent event, java.util.Collection<BundleContext> contexts) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeWeavingHook
public void invokeWeavingHook(WeavingHook wh, WovenClass wc) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeServiceEventHook
public void invokeServiceEventHook(EventHook eh, ServiceEvent event, java.util.Collection<BundleContext> contexts) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeServiceFindHook
public void invokeServiceFindHook(FindHook fh, BundleContext context, java.lang.String name, java.lang.String filter, boolean allServices, java.util.Collection<ServiceReference<?>> references) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeServiceListenerHookAdded
public void invokeServiceListenerHookAdded(ListenerHook lh, java.util.Collection<ListenerHook.ListenerInfo> listeners) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeServiceListenerHookRemoved
public void invokeServiceListenerHookRemoved(ListenerHook lh, java.util.Collection<ListenerHook.ListenerInfo> listeners) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeServiceEventListenerHook
public void invokeServiceEventListenerHook(EventListenerHook elh, ServiceEvent event, java.util.Map<BundleContext,java.util.Collection<ListenerHook.ListenerInfo>> listeners) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeResolverHookFactory
public ResolverHook invokeResolverHookFactory(ResolverHookFactory rhf, java.util.Collection<BundleRevision> triggers) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeResolverHookResolvable
public void invokeResolverHookResolvable(ResolverHook rh, java.util.Collection<BundleRevision> candidates) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeResolverHookSingleton
public void invokeResolverHookSingleton(ResolverHook rh, BundleCapability singleton, java.util.Collection<BundleCapability> collisions) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeResolverHookMatches
public void invokeResolverHookMatches(ResolverHook rh, BundleRequirement req, java.util.Collection<BundleCapability> candidates) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeResolverHookEnd
public void invokeResolverHookEnd(ResolverHook rh) throws java.lang.Exception
- Throws:
java.lang.Exception
-
invokeWovenClassListener
public void invokeWovenClassListener(WovenClassListener wcl, WovenClass wc) throws java.lang.Exception
- Throws:
java.lang.Exception
-
run
public <T> T run(java.security.PrivilegedAction<T> action)
-
run
public <T> T run(java.security.PrivilegedExceptionAction<T> action) throws java.lang.Exception- Throws:
java.lang.Exception
-
getCanonicalPath
public java.lang.String getCanonicalPath(java.io.File dataFile) throws java.io.IOException- Throws:
java.io.IOException
-
createProxy
public java.lang.Object createProxy(java.lang.ClassLoader classLoader, java.lang.Class<?>[] interfaces, java.lang.reflect.InvocationHandler handler)
-
getLastModified
public long getLastModified(java.io.File file)
-
-