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