org.jboss.remoting.util
Class SecurityUtility

java.lang.Object
  extended by org.jboss.remoting.util.SecurityUtility

public class SecurityUtility
extends java.lang.Object

SecurityUtility provides a central point for making security sensitive calls. It is divided into six sections: 1. calls requiring FilePermissions 2. calls requiring MBeanPermissions 3. calls requiring PropertyPermissions 4. calls requiring RuntimePermissions 5. calls requiring SocketPermissions 6. calls requiring JBoss permissions When the SecurityUtility class is loaded, it checks for two conditions: 1. there is no security manager 2. the system property Remoting.SKIP_ACCESS_CONTROL ("skipAccessControl") is set to true. If either condition is true, then every method in SecurityUtility will bypass its call to AccessController.doPrivileged().

Version:
$Revision: 1.1 $

Copyright Mar 31, 2008

Author:
Ron Sigal

Constructor Summary
SecurityUtility()
           
 
Method Summary
static java.net.Socket accept(java.net.ServerSocket ss)
           
static void bind(java.net.ServerSocket ss, java.net.SocketAddress address)
           
static void bind(java.net.ServerSocket ss, java.net.SocketAddress address, int backlog)
           
static java.lang.Object callTransport(RMIServerInvokerInf server, java.lang.Object payload)
           
static boolean canRead(java.io.File file)
           
static void connect(java.net.HttpURLConnection conn)
           
static void connect(java.net.Socket socket, java.net.InetSocketAddress address)
           
static void connect(java.net.Socket socket, java.net.InetSocketAddress address, int timeout)
           
static javax.management.MBeanServer createMBeanServer()
           
static boolean createNewFile(java.io.File file)
           
static java.rmi.registry.Registry createRegistry(int port)
           
static RemotingClassLoader createRemotingClassLoader(java.lang.ClassLoader remotingClassLoader, java.lang.ClassLoader userClassLoader)
           
static RemotingClassLoader createRemotingClassLoader(java.lang.ClassLoader remotingClassLoader, java.lang.ClassLoader userClassLoader, boolean parentFirstDelegation)
           
static java.net.ServerSocket createServerSocket(int port)
           
static java.net.ServerSocket createServerSocket(int port, int backlog)
           
static java.net.ServerSocket createServerSocket(int port, int backlog, java.net.InetAddress inetAddress)
           
static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf)
           
static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf, int port)
           
static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf, int port, int backlog)
           
static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf, int port, int backlog, java.net.InetAddress inetAddress)
           
static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf)
           
static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf, int port)
           
static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf, int port, int backlog)
           
static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf, int port, int backlog, java.net.InetAddress inetAddress)
           
static java.net.Socket createSocket(javax.net.SocketFactory sf, java.lang.String host, int port)
           
static java.net.Socket createSocket(java.lang.String host, int port)
           
static javax.naming.Context createSubcontext(javax.naming.InitialContext initialContext, java.lang.String subContextName)
           
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit)
           
static void deleteOnExit(java.io.File file)
           
static java.rmi.Remote exportObject(java.rmi.Remote object, int port, java.rmi.server.RMIClientSocketFactory csf, java.rmi.server.RMIServerSocketFactory ssf)
           
static boolean fileExists(java.io.File file)
           
static java.util.ArrayList findMBeanServer(java.lang.String agentId)
           
static java.lang.Object forName(java.lang.String className)
           
static java.net.InetAddress getAddressByName(java.lang.String host)
           
static java.lang.ClassLoader getClassLoader(java.lang.Class c)
           
static java.lang.ClassLoader getContextClassLoader(java.lang.Thread thread)
           
static java.lang.reflect.Method getDeclaredMethod(java.lang.Class c, java.lang.String name, java.lang.Class[] parameterTypes)
           
static java.io.FileInputStream getFileInputStream(java.io.File file)
           
static java.io.FileInputStream getFileInputStream(java.lang.String path)
           
static java.io.FileOutputStream getFileOutputStream(java.io.File file)
           
static java.io.FileOutputStream getFileOutputStream(java.io.File file, boolean append)
           
static java.net.InetAddress getLocalHost()
           
static java.lang.String getLocalHostName()
           
static java.lang.Object getMBeanAttribute(javax.management.MBeanServer server, javax.management.ObjectName objectName, java.lang.String attribute)
           
static java.lang.reflect.Method getMethod(java.lang.Class c, java.lang.String name, java.lang.Class[] parameterTypes)
           
static java.io.OutputStream getOutputStream(java.net.HttpURLConnection conn)
           
static javax.management.MBeanServer getPlatformMBeanServer()
           
static java.rmi.registry.Registry getRegistry(int port)
           
static int getResponseCode(java.net.HttpURLConnection conn)
           
static java.lang.String getResponseMessage(java.net.HttpURLConnection conn)
           
static java.lang.ClassLoader getSystemClassLoader()
           
static java.lang.String getSystemProperty(java.lang.String name)
           
static java.lang.String getSystemProperty(java.lang.String name, java.lang.String defaultValue)
           
static javax.naming.Context initialContextLookup(javax.naming.InitialContext initialContext, java.lang.String subContextName)
           
static boolean isInstanceOf(javax.management.MBeanServer server, javax.management.ObjectName objectName, java.lang.String className)
           
static javax.naming.NamingEnumeration listBindings(javax.naming.Context context, java.lang.String bindName)
           
static java.rmi.Remote lookup(java.rmi.registry.Registry registry, java.lang.String name)
           
static void mapJavaBeanProperties(java.lang.Object o, java.util.Properties props, boolean isStrict)
           
static boolean mkdirs(java.io.File dir)
           
static void namingBeanImplStart(java.lang.Object namingBean, java.lang.reflect.Method startMethod)
           
static java.lang.Object readObject(java.io.ObjectInputStream ois)
           
static void rebind(javax.naming.Context context, java.lang.String name, java.lang.Object object)
           
static void rebind(java.rmi.registry.Registry registry, java.lang.String name, java.rmi.Remote object)
           
static void registerMBean(javax.management.MBeanServer server, java.lang.Object o, javax.management.ObjectName name)
           
static void setSystemProperty(java.lang.String name, java.lang.String value)
           
static boolean skipAccessControl()
           
static void unbind(javax.naming.Context context, java.lang.String name)
           
static void unbind(java.rmi.registry.Registry registry, java.lang.String name)
           
static void unregisterMBean(javax.management.MBeanServer server, javax.management.ObjectName name)
           
static void writeObject(java.io.ObjectOutputStream oos, java.lang.Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityUtility

public SecurityUtility()
Method Detail

skipAccessControl

public static boolean skipAccessControl()

createTempFile

public static java.io.File createTempFile(java.lang.String prefix,
                                          java.lang.String suffix,
                                          boolean deleteOnExit)
                                   throws java.io.IOException
Throws:
java.io.IOException

deleteOnExit

public static void deleteOnExit(java.io.File file)

fileExists

public static boolean fileExists(java.io.File file)

mkdirs

public static boolean mkdirs(java.io.File dir)

getFileInputStream

public static java.io.FileInputStream getFileInputStream(java.io.File file)
                                                  throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

getFileInputStream

public static java.io.FileInputStream getFileInputStream(java.lang.String path)
                                                  throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

getFileOutputStream

public static java.io.FileOutputStream getFileOutputStream(java.io.File file)
                                                    throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

getFileOutputStream

public static java.io.FileOutputStream getFileOutputStream(java.io.File file,
                                                           boolean append)
                                                    throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

canRead

public static boolean canRead(java.io.File file)

createNewFile

public static boolean createNewFile(java.io.File file)
                             throws java.io.IOException
Throws:
java.io.IOException

createMBeanServer

public static javax.management.MBeanServer createMBeanServer()
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

findMBeanServer

public static java.util.ArrayList findMBeanServer(java.lang.String agentId)

getMBeanAttribute

public static java.lang.Object getMBeanAttribute(javax.management.MBeanServer server,
                                                 javax.management.ObjectName objectName,
                                                 java.lang.String attribute)
                                          throws java.lang.Exception
Throws:
java.lang.Exception

getPlatformMBeanServer

public static javax.management.MBeanServer getPlatformMBeanServer()
                                                           throws java.lang.NoSuchMethodException,
                                                                  java.lang.IllegalAccessException,
                                                                  java.lang.reflect.InvocationTargetException
Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

isInstanceOf

public static boolean isInstanceOf(javax.management.MBeanServer server,
                                   javax.management.ObjectName objectName,
                                   java.lang.String className)
                            throws javax.management.InstanceNotFoundException
Throws:
javax.management.InstanceNotFoundException

registerMBean

public static void registerMBean(javax.management.MBeanServer server,
                                 java.lang.Object o,
                                 javax.management.ObjectName name)
                          throws java.lang.Exception
Throws:
java.lang.Exception

unregisterMBean

public static void unregisterMBean(javax.management.MBeanServer server,
                                   javax.management.ObjectName name)
                            throws java.lang.Exception
Throws:
java.lang.Exception

getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String name,
                                                 java.lang.String defaultValue)

getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String name)

setSystemProperty

public static void setSystemProperty(java.lang.String name,
                                     java.lang.String value)

createRemotingClassLoader

public static RemotingClassLoader createRemotingClassLoader(java.lang.ClassLoader remotingClassLoader,
                                                            java.lang.ClassLoader userClassLoader)

createRemotingClassLoader

public static RemotingClassLoader createRemotingClassLoader(java.lang.ClassLoader remotingClassLoader,
                                                            java.lang.ClassLoader userClassLoader,
                                                            boolean parentFirstDelegation)

forName

public static java.lang.Object forName(java.lang.String className)
                                throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

getClassLoader

public static java.lang.ClassLoader getClassLoader(java.lang.Class c)

getContextClassLoader

public static java.lang.ClassLoader getContextClassLoader(java.lang.Thread thread)

getSystemClassLoader

public static java.lang.ClassLoader getSystemClassLoader()

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class c,
                                                 java.lang.String name,
                                                 java.lang.Class[] parameterTypes)
                                          throws java.lang.NoSuchMethodException
Throws:
java.lang.NoSuchMethodException

getDeclaredMethod

public static java.lang.reflect.Method getDeclaredMethod(java.lang.Class c,
                                                         java.lang.String name,
                                                         java.lang.Class[] parameterTypes)
                                                  throws java.lang.NoSuchMethodException
Throws:
java.lang.NoSuchMethodException

mapJavaBeanProperties

public static void mapJavaBeanProperties(java.lang.Object o,
                                         java.util.Properties props,
                                         boolean isStrict)
                                  throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException

namingBeanImplStart

public static void namingBeanImplStart(java.lang.Object namingBean,
                                       java.lang.reflect.Method startMethod)
                                throws java.lang.IllegalAccessException,
                                       java.lang.reflect.InvocationTargetException
Throws:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

readObject

public static java.lang.Object readObject(java.io.ObjectInputStream ois)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeObject

public static void writeObject(java.io.ObjectOutputStream oos,
                               java.lang.Object o)
                        throws java.io.IOException
Throws:
java.io.IOException

accept

public static java.net.Socket accept(java.net.ServerSocket ss)
                              throws java.io.IOException
Throws:
java.io.IOException

bind

public static void bind(java.net.ServerSocket ss,
                        java.net.SocketAddress address)
                 throws java.io.IOException
Throws:
java.io.IOException

bind

public static void bind(java.net.ServerSocket ss,
                        java.net.SocketAddress address,
                        int backlog)
                 throws java.io.IOException
Throws:
java.io.IOException

connect

public static void connect(java.net.Socket socket,
                           java.net.InetSocketAddress address)
                    throws java.io.IOException
Throws:
java.io.IOException

connect

public static void connect(java.net.Socket socket,
                           java.net.InetSocketAddress address,
                           int timeout)
                    throws java.io.IOException
Throws:
java.io.IOException

connect

public static void connect(java.net.HttpURLConnection conn)
                    throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf,
                                                       int port)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf,
                                                       int port,
                                                       int backlog)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(ServerSocketFactoryMBean ssf,
                                                       int port,
                                                       int backlog,
                                                       java.net.InetAddress inetAddress)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf,
                                                       int port)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf,
                                                       int port,
                                                       int backlog)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(javax.net.ServerSocketFactory ssf,
                                                       int port,
                                                       int backlog,
                                                       java.net.InetAddress inetAddress)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(int port)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(int port,
                                                       int backlog)
                                                throws java.io.IOException
Throws:
java.io.IOException

createServerSocket

public static java.net.ServerSocket createServerSocket(int port,
                                                       int backlog,
                                                       java.net.InetAddress inetAddress)
                                                throws java.io.IOException
Throws:
java.io.IOException

createSocket

public static java.net.Socket createSocket(java.lang.String host,
                                           int port)
                                    throws java.io.IOException
Throws:
java.io.IOException

createSocket

public static java.net.Socket createSocket(javax.net.SocketFactory sf,
                                           java.lang.String host,
                                           int port)
                                    throws java.io.IOException
Throws:
java.io.IOException

getLocalHost

public static java.net.InetAddress getLocalHost()
                                         throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

getLocalHostName

public static java.lang.String getLocalHostName()
                                         throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

getAddressByName

public static java.net.InetAddress getAddressByName(java.lang.String host)
                                             throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

getOutputStream

public static java.io.OutputStream getOutputStream(java.net.HttpURLConnection conn)
                                            throws java.io.IOException
Throws:
java.io.IOException

getResponseCode

public static int getResponseCode(java.net.HttpURLConnection conn)
                           throws java.io.IOException
Throws:
java.io.IOException

getResponseMessage

public static java.lang.String getResponseMessage(java.net.HttpURLConnection conn)
                                           throws java.io.IOException
Throws:
java.io.IOException

callTransport

public static java.lang.Object callTransport(RMIServerInvokerInf server,
                                             java.lang.Object payload)
                                      throws java.io.IOException
Throws:
java.io.IOException

createRegistry

public static java.rmi.registry.Registry createRegistry(int port)
                                                 throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

exportObject

public static java.rmi.Remote exportObject(java.rmi.Remote object,
                                           int port,
                                           java.rmi.server.RMIClientSocketFactory csf,
                                           java.rmi.server.RMIServerSocketFactory ssf)
                                    throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getRegistry

public static java.rmi.registry.Registry getRegistry(int port)
                                              throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

lookup

public static java.rmi.Remote lookup(java.rmi.registry.Registry registry,
                                     java.lang.String name)
                              throws java.rmi.RemoteException,
                                     java.rmi.NotBoundException
Throws:
java.rmi.RemoteException
java.rmi.NotBoundException

rebind

public static void rebind(java.rmi.registry.Registry registry,
                          java.lang.String name,
                          java.rmi.Remote object)
                   throws java.io.IOException
Throws:
java.io.IOException

unbind

public static void unbind(java.rmi.registry.Registry registry,
                          java.lang.String name)
                   throws java.rmi.AccessException,
                          java.rmi.RemoteException,
                          java.rmi.NotBoundException
Throws:
java.rmi.AccessException
java.rmi.RemoteException
java.rmi.NotBoundException

createSubcontext

public static javax.naming.Context createSubcontext(javax.naming.InitialContext initialContext,
                                                    java.lang.String subContextName)
                                             throws javax.naming.NamingException
Throws:
javax.naming.NamingException

initialContextLookup

public static javax.naming.Context initialContextLookup(javax.naming.InitialContext initialContext,
                                                        java.lang.String subContextName)
                                                 throws javax.naming.NamingException
Throws:
javax.naming.NamingException

listBindings

public static javax.naming.NamingEnumeration listBindings(javax.naming.Context context,
                                                          java.lang.String bindName)
                                                   throws javax.naming.NamingException
Throws:
javax.naming.NamingException

rebind

public static void rebind(javax.naming.Context context,
                          java.lang.String name,
                          java.lang.Object object)
                   throws javax.naming.NamingException
Throws:
javax.naming.NamingException

unbind

public static void unbind(javax.naming.Context context,
                          java.lang.String name)
                   throws javax.naming.NamingException
Throws:
javax.naming.NamingException


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.