[jboss-remoting-commits] JBoss Remoting SVN: r5007 - remoting2/branches/2.x/src/main/org/jboss/remoting/security.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Tue Apr 14 06:17:17 EDT 2009
Author: ron.sigal at jboss.com
Date: 2009-04-14 06:17:17 -0400 (Tue, 14 Apr 2009)
New Revision: 5007
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java
remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java 2009-04-14 10:16:38 UTC (rev 5006)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/security/SSLSocketBuilder.java 2009-04-14 10:17:17 UTC (rev 5007)
@@ -396,14 +396,14 @@
if (getUseSSLSocketFactory())
{
- String defaultFactoryName = SecurityUtility.getSystemProperty(REMOTING_DEFAULT_SOCKET_FACTORY_CLASS);
+ String defaultFactoryName = getSystemProperty(REMOTING_DEFAULT_SOCKET_FACTORY_CLASS);
if (defaultFactoryName != null)
{
try
{
final Class sfClass = ClassLoaderUtility.loadClass(defaultFactoryName, SSLSocketBuilder.class);
- Method m = SecurityUtility.getMethod(sfClass, "getDefault", null);
+ Method m = getMethod(sfClass, "getDefault", null);
if (m == null)
{
@@ -616,7 +616,7 @@
if(keyStoreFilePath == null)
{
- String path = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_FILE_PATH);;
+ String path = getSystemProperty(STANDARD_KEY_STORE_FILE_PATH);;
if(path != null && path.length() > 0)
{
setKeyStoreURL( path );
@@ -670,7 +670,7 @@
if(keyStoreType == null)
{
- keyStoreType = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_TYPE);
+ keyStoreType = getSystemProperty(STANDARD_KEY_STORE_TYPE);
if(keyStoreType == null)
{
keyStoreType = DEFAULT_KEY_STORE_TYPE;
@@ -746,7 +746,7 @@
if(keyStorePassword == null)
{
- keyStorePassword = SecurityUtility.getSystemProperty(STANDARD_KEY_STORE_PASSWORD);
+ keyStorePassword = getSystemProperty(STANDARD_KEY_STORE_PASSWORD);
}
return keyStorePassword;
@@ -797,7 +797,7 @@
if(trustStoreFilePath == null)
{
- String path = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_FILE_PATH);
+ String path = getSystemProperty(STANDARD_TRUST_STORE_FILE_PATH);
if(path != null && path.length() > 0)
{
setTrustStoreURL( path );
@@ -851,7 +851,7 @@
if(trustStoreType == null)
{
- trustStoreType = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_TYPE);
+ trustStoreType = getSystemProperty(STANDARD_TRUST_STORE_TYPE);
if(trustStoreType == null)
{
trustStoreType = getKeyStoreType();
@@ -927,7 +927,7 @@
if(trustStorePassword == null)
{
- trustStorePassword = SecurityUtility.getSystemProperty(STANDARD_TRUST_STORE_PASSWORD);
+ trustStorePassword = getSystemProperty(STANDARD_TRUST_STORE_PASSWORD);
if(trustStorePassword == null)
{
trustStorePassword = getKeyStorePassword();
@@ -1716,4 +1716,52 @@
super(message);
}
}
+
+ static private String getSystemProperty(final String name)
+ {
+ if (SecurityUtility.skipAccessControl())
+ return System.getProperty(name);
+
+ String value = null;
+ try
+ {
+ value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+
+ return value;
+ }
+
+ static private Method getMethod(final Class c, final String name, final Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return c.getMethod(name, parameterTypes);
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ return c.getMethod(name, parameterTypes);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
}
\ No newline at end of file
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java 2009-04-14 10:16:38 UTC (rev 5006)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java 2009-04-14 10:17:17 UTC (rev 5007)
@@ -24,6 +24,9 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import javax.net.ServerSocketFactory;
@@ -43,27 +46,124 @@
public ServerSocket createServerSocket(final int i) throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory, i);
+ return createServerSocket(serverSocketFactory, i);
}
public ServerSocket createServerSocket(final int i, final int i1) throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory, i, i1);
+ return createServerSocket(serverSocketFactory, i, i1);
}
public ServerSocket createServerSocket(final int i, final int i1, final InetAddress inetAddress) throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory, i, i1, inetAddress);
+ return createServerSocket(serverSocketFactory, i, i1, inetAddress);
}
public ServerSocket createServerSocket() throws IOException
{
- return SecurityUtility.createServerSocket(serverSocketFactory);
+ return createServerSocket(serverSocketFactory);
}
public ServerSocketFactoryMBean getDelegate()
{
return serverSocketFactory;
}
+
+ static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf) throws IOException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return ssf.createServerSocket();
+ }
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws IOException
+ {
+ return ssf.createServerSocket();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+ static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port) throws IOException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return ssf.createServerSocket(port);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+ static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port, final int backlog)
+ throws IOException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return ssf.createServerSocket(port, backlog);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port, backlog);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
+
+ static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
+ final int port, final int backlog,
+ final InetAddress inetAddress)
+ throws IOException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return ssf.createServerSocket(port, backlog, inetAddress);
+ }
+
+ try
+ {
+ return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return ssf.createServerSocket(port, backlog, inetAddress);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (IOException) e.getCause();
+ }
+ }
}
\ No newline at end of file
More information about the jboss-remoting-commits
mailing list