Package org.apache.felix.framework.util
Class SecureAction
java.lang.Object
org.apache.felix.framework.util.SecureAction
This is a utility class centralizing the I/O, reflection and class loading operations performed by the framework.
Historically every method here wrapped its operation in a doPrivileged() block against a captured security context. Java SE 24 permanently disabled the Security Manager (JEP 486), so those blocks no longer had any effect and have been removed; each method now performs its operation directly. The class is retained as the framework's single point of access for these operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]protected static intprivate static Consumer<AccessibleObject[]> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidprivate static Object_swapStaticFieldIfNotClass(Class<?> targetClazz, Class<?> targetType, Class<?> condition, String lockName) voidaddURLToURLClassLoader(URL extension, ClassLoader loader) createProxy(ClassLoader classLoader, Class<?>[] interfaces, InvocationHandler handler) 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) booleandeleteFile(File target) voiddeleteFileOnExit(File file) booleanfileExists(File file) voidClass<?> forName(String name, ClassLoader classloader) getAbsolutePath(File file) private static Consumer<AccessibleObject[]> getAccessor(Class<?> clazz) getCanonicalPath(File dataFile) getClassLoader(Class<?> clazz) Constructor<?> getConstructor(Class<?> target, Class<?>[] types) Constructor<?> getDeclaredConstructor(Class<?> target, Class<?>[] types) getDeclaredField(Class<?> targetClass, String name, Object target) getDeclaredMethod(Class<?> target, String method, Class<?>[] types) getFileChannel(File file) getFileInputStream(File file) getFileOutputStream(File file) getInputStream(File file) longgetLastModified(File file) getOutputStream(File file) getParentClassLoader(ClassLoader loader) getSystemProperty(String name, String def) invoke(Constructor<?> constructor, Object[] params) voidinvokeBundleCollisionHook(CollisionHook ch, int operationType, Bundle targetBundle, Collection<Bundle> collisionCandidates) voidinvokeBundleEventHook(EventHook eh, BundleEvent event, Collection<BundleContext> contexts) voidinvokeBundleFindHook(FindHook fh, BundleContext bc, Collection<Bundle> bundles) invokeDirect(Method method, Object target, Object[] params) voidinvokeResolverHookFactory(ResolverHookFactory rhf, Collection<BundleRevision> triggers) voidinvokeResolverHookMatches(ResolverHook rh, BundleRequirement req, Collection<BundleCapability> candidates) voidinvokeResolverHookResolvable(ResolverHook rh, Collection<BundleRevision> candidates) voidinvokeResolverHookSingleton(ResolverHook rh, BundleCapability singleton, Collection<BundleCapability> collisions) voidinvokeServiceEventHook(EventHook eh, ServiceEvent event, Collection<BundleContext> contexts) voidinvokeServiceEventListenerHook(EventListenerHook elh, ServiceEvent event, Map<BundleContext, Collection<ListenerHook.ListenerInfo>> listeners) voidinvokeServiceFindHook(FindHook fh, BundleContext context, String name, String filter, boolean allServices, Collection<ServiceReference<?>> references) voidvoidvoidinvokeWeavingHook(WeavingHook wh, WovenClass wc) voidbooleanbooleanisFileDirectory(File file) File[]listDirectory(File file) booleanbooleanopenJarFile(File file) openURLConnection(URL url) openZipFile(File file) booleanrenameFile(File oldFile, File newFile) <T> Trun(PrivilegedAction<T> action) <T> Trun(PrivilegedExceptionAction<T> action) voidvoidstartActivator(BundleActivator activator, BundleContext context) voidstopActivator(BundleActivator activator, BundleContext context) swapStaticFieldIfNotClass(Class<?> targetClazz, Class<?> targetType, Class<?> condition, String lockName)
-
Field Details
-
accessor
private static final byte[] accessor -
BUFSIZE
protected static transient int BUFSIZE -
m_accessorCache
-
-
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
-
isFile
-
isFileDirectory
-
mkdir
-
mkdirs
-
listDirectory
-
renameFile
-
getInputStream
- Throws:
IOException
-
getOutputStream
- Throws:
IOException
-
getFileInputStream
- Throws:
IOException
-
getFileOutputStream
- Throws:
IOException
-
getFileChannel
- 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
-
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
-
getAccessor
-
_swapStaticFieldIfNotClass
private static Object _swapStaticFieldIfNotClass(Class<?> targetClazz, Class<?> targetType, Class<?> condition, String lockName) throws Exception - Throws:
Exception
-
flush
- 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
-
run
-
run
- Throws:
Exception
-
getCanonicalPath
- Throws:
IOException
-
createProxy
public Object createProxy(ClassLoader classLoader, Class<?>[] interfaces, InvocationHandler handler) -
getLastModified
-