Package 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

Fields
Modifier and Type
Field
Description
`protected static int`
`BUFSIZE`

## Constructor Summary

Constructors
Constructor
Description
`SecureAction()`

## Method Summary

Modifier and Type
Method
Description
`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)`
`void`
`deleteFileOnExit(File file)`
`Process`
`exec(String command)`
`boolean`
`fileExists(File file)`
`void`
`flush(Class targetClazz, Object lock)`
`Class`
`forName(String name, ClassLoader classloader)`
`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)`
`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)`
`Object`
`invokeDirect(Method method, Object target, Object[] params)`
`void`
`invokeResolverHookEnd(ResolverHook rh)`
`ResolverHook`
`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`
`invokeServiceListenerHookAdded(ListenerHook lh, Collection<ListenerHook.ListenerInfo> listeners)`
`void`
`invokeServiceListenerHookRemoved(ListenerHook lh, Collection<ListenerHook.ListenerInfo> listeners)`
`void`
`invokeWeavingHook(WeavingHook wh, WovenClass wc)`
`void`
`invokeWovenClassListener(WovenClassListener wcl, WovenClass wc)`
`boolean`
`isFileDirectory(File file)`
`File[]`
`listDirectory(File file)`
`boolean`
`mkdir(File file)`
`boolean`
`mkdirs(File file)`
`JarFile`
`openJarFile(File file)`
`URLConnection`
`openURLConnection(URL url)`
`ZipFile`
`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`

## Field Details

### BUFSIZE

protected static transient int BUFSIZE

## Constructor Details

### SecureAction

public SecureAction()

## Method Details

### 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, ClassLoader classloader) 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`

### deleteFileOnExit

public void deleteFileOnExit(File file) throws IOException

Throws:
  `IOException`

### openURLConnection

public URLConnection openURLConnection(URL url) throws IOException

Throws:
  `IOException`

### openZipFile

public ZipFile openZipFile(File file) throws IOException

Throws:
  `IOException`

### openJarFile

public JarFile openJarFile(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`

### 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

public void invokeWeavingHook(WeavingHook wh, WovenClass wc) throws Exception

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

public void invokeResolverHookEnd(ResolverHook rh) throws Exception

Throws:
  `Exception`

### invokeWovenClassListener

public void invokeWovenClassListener(WovenClassListener wcl, WovenClass wc) throws Exception

Throws:
  `Exception`