org.apache.felix.framework.util
Class SecureAction

java.lang.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)
           
 boolean fileExists(File file)
           
 Class forName(String name)
           
 String getAbsolutePath(File file)
           
 Constructor getConstructor(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)
           
 JarFile getJarURLConnectionJAR(JarURLConnection connection)
           
 Method getMethod(Class target, String method, Class[] types)
           
 Policy getPolicy()
           
 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)
           
 JarFile openJAR(File file, boolean verify)
           
 URLConnection openURLConnection(URL url)
           
 boolean renameFile(File oldFile, File newFile)
           
 void setAccesssible(Method method)
           
 void startActivator(BundleActivator activator, BundleContext context)
           
 void stopActivator(BundleActivator activator, BundleContext context)
           
 Object swapStaticFieldIfNotClass(Class targetClazz, Class targetType, Class condition, String lockName)
           
 
Methods inherited from class java.lang.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)

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

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

getJarURLConnectionJAR

public JarFile getJarURLConnectionJAR(JarURLConnection connection)
                               throws IOException
Throws:
IOException

openJAR

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

openJAR

public JarFile openJAR(File file,
                       boolean verify)
                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

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(Method method)

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


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.