Package org.apache.felix.framework.util
Class SecureAction
- java.lang.Object
-
- org.apache.felix.framework.util.SecureAction
-
public class SecureAction extends java.lang.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
Fields Modifier and Type Field Description protected static int
BUFSIZE
-
Constructor Summary
Constructors Constructor Description SecureAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addURLToURLClassLoader(java.net.URL extension, java.lang.ClassLoader loader)
java.io.File
createTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File dir)
java.net.URL
createURL(java.lang.String protocol, java.lang.String host, int port, java.lang.String path, java.net.URLStreamHandler handler)
java.net.URL
createURL(java.net.URL context, java.lang.String spec, java.net.URLStreamHandler handler)
boolean
deleteFile(java.io.File target)
void
deleteFileOnExit(java.io.File file)
java.lang.Process
exec(java.lang.String command)
boolean
fileExists(java.io.File file)
void
flush(java.lang.Class targetClazz, java.lang.Object lock)
java.lang.Class
forName(java.lang.String name, java.lang.ClassLoader classloader)
java.lang.String
getAbsolutePath(java.io.File file)
java.lang.ClassLoader
getClassLoader(java.lang.Class clazz)
java.lang.reflect.Constructor
getConstructor(java.lang.Class target, java.lang.Class[] types)
java.lang.reflect.Constructor
getDeclaredConstructor(java.lang.Class target, java.lang.Class[] types)
java.lang.Object
getDeclaredField(java.lang.Class targetClass, java.lang.String name, java.lang.Object target)
java.lang.reflect.Method
getDeclaredMethod(java.lang.Class target, java.lang.String method, java.lang.Class[] types)
java.io.FileInputStream
getFileInputStream(java.io.File file)
java.io.FileOutputStream
getFileOutputStream(java.io.File file)
java.lang.reflect.Method
getMethod(java.lang.Class target, java.lang.String method, java.lang.Class[] types)
java.lang.ClassLoader
getParentClassLoader(java.lang.ClassLoader loader)
java.security.Policy
getPolicy()
java.lang.ClassLoader
getSystemClassLoader()
java.lang.String
getSystemProperty(java.lang.String name, java.lang.String def)
java.io.InputStream
getURLConnectionInputStream(java.net.URLConnection conn)
java.lang.Object
invoke(java.lang.reflect.Constructor constructor, java.lang.Object[] params)
java.lang.Object
invoke(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] params)
void
invokeBundleCollisionHook(CollisionHook ch, int operationType, Bundle targetBundle, java.util.Collection<Bundle> collisionCandidates)
void
invokeBundleEventHook(EventHook eh, BundleEvent event, java.util.Collection<BundleContext> contexts)
void
invokeBundleFindHook(FindHook fh, BundleContext bc, java.util.Collection<Bundle> bundles)
java.lang.Object
invokeDirect(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] params)
void
invokeResolverHookEnd(ResolverHook rh)
ResolverHook
invokeResolverHookFactory(ResolverHookFactory rhf, java.util.Collection<BundleRevision> triggers)
void
invokeResolverHookMatches(ResolverHook rh, BundleRequirement req, java.util.Collection<BundleCapability> candidates)
void
invokeResolverHookResolvable(ResolverHook rh, java.util.Collection<BundleRevision> candidates)
void
invokeResolverHookSingleton(ResolverHook rh, BundleCapability singleton, java.util.Collection<BundleCapability> collisions)
void
invokeServiceEventHook(EventHook eh, ServiceEvent event, java.util.Collection<BundleContext> contexts)
void
invokeServiceEventListenerHook(EventListenerHook elh, ServiceEvent event, java.util.Map<BundleContext,java.util.Collection<ListenerHook.ListenerInfo>> listeners)
void
invokeServiceFindHook(FindHook fh, BundleContext context, java.lang.String name, java.lang.String filter, boolean allServices, java.util.Collection<ServiceReference<?>> references)
void
invokeServiceListenerHookAdded(ListenerHook lh, java.util.Collection<ListenerHook.ListenerInfo> listeners)
void
invokeServiceListenerHookRemoved(ListenerHook lh, java.util.Collection<ListenerHook.ListenerInfo> listeners)
void
invokeWeavingHook(WeavingHook wh, WovenClass wc)
void
invokeWovenClassListener(WovenClassListener wcl, WovenClass wc)
boolean
isFileDirectory(java.io.File file)
java.io.File[]
listDirectory(java.io.File file)
boolean
mkdir(java.io.File file)
boolean
mkdirs(java.io.File file)
java.util.jar.JarFile
openJarFile(java.io.File file)
java.net.URLConnection
openURLConnection(java.net.URL url)
java.util.zip.ZipFile
openZipFile(java.io.File file)
boolean
renameFile(java.io.File oldFile, java.io.File newFile)
void
setAccesssible(java.lang.reflect.AccessibleObject ao)
void
startActivator(BundleActivator activator, BundleContext context)
void
stopActivator(BundleActivator activator, BundleContext context)
java.lang.Object
swapStaticFieldIfNotClass(java.lang.Class targetClazz, java.lang.Class targetType, java.lang.Class condition, java.lang.String lockName)
java.net.URI
toURI(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)
-
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)
-
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
-
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.AccessibleObject 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
-
-