[Felix Framework]

org.apache.felix.framework.util
Class SecureAction

Object
  extended by 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
protected static int BUFSIZE
           
 
Constructor Summary
SecureAction()
           
 
Method Summary
 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)
           
 Process exec(String command)
           
 boolean fileExists(File file)
           
 void flush(Class targetClazz, Object lock)
           
 Class forName(String name)
           
 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)
           
 InputStream getFileInputStream(File file)
           
 OutputStream 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)
           
 Object invokeDirect(Method method, Object target, Object[] params)
           
 boolean isFileDirectory(File file)
           
 File[] listDirectory(File file)
           
 boolean mkdir(File file)
           
 boolean mkdirs(File file)
           
 JarFileX openJAR(File file)
           
 JarFileX openJAR(File file, boolean verify)
           
 URLConnection openURLConnection(URL url)
           
 boolean renameFile(File oldFile, File newFile)
           
 void setAccesssible(AccessibleObject ao)
           
 void startActivator(org.osgi.framework.BundleActivator activator, org.osgi.framework.BundleContext context)
           
 void stopActivator(org.osgi.framework.BundleActivator activator, org.osgi.framework.BundleContext context)
           
 Object swapStaticFieldIfNotClass(Class targetClazz, Class targetType, Class condition, String lockName)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFSIZE

protected static transient int BUFSIZE
Constructor Detail

SecureAction

public SecureAction()
Method Detail

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)
              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 InputStream getFileInputStream(File file)
                               throws IOException
Throws:
IOException

getFileOutputStream

public OutputStream getFileOutputStream(File file)
                                 throws IOException
Throws:
IOException

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

openURLConnection

public URLConnection openURLConnection(URL url)
                                throws IOException
Throws:
IOException

openJAR

public JarFileX openJAR(File file)
                 throws IOException
Throws:
IOException

openJAR

public JarFileX openJAR(File file,
                        boolean verify)
                 throws IOException
Throws:
IOException

startActivator

public void startActivator(org.osgi.framework.BundleActivator activator,
                           org.osgi.framework.BundleContext context)
                    throws Exception
Throws:
Exception

stopActivator

public void stopActivator(org.osgi.framework.BundleActivator activator,
                          org.osgi.framework.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

[Felix Framework]