mx4j/src/core/mx4j/remote MX4JRemoteUtils.java,1.18,1.19

Simone Bordet <[email protected]> Sun, 21 Nov 2004 14:28:34 +0000
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/core/mx4j/remote
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26449/src/core/mx4j/remote

Modified Files:
	MX4JRemoteUtils.java 
Log Message:
Fix for when mx4j is in bootclasspath: the current domain can be null when combining the protection domains

Index: MX4JRemoteUtils.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/remote/MX4JRemoteUtils.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** MX4JRemoteUtils.java	13 Nov 2004 16:38:20 -0000	1.18
--- MX4JRemoteUtils.java	21 Nov 2004 14:28:32 -0000	1.19
***************
*** 14,17 ****
--- 14,18 ----
  import java.io.Serializable;
  import java.lang.reflect.Constructor;
+ import java.net.URL;
  import java.security.AccessControlContext;
  import java.security.AccessControlException;
***************
*** 26,29 ****
--- 27,31 ----
  import java.security.PrivilegedExceptionAction;
  import java.security.ProtectionDomain;
+ import java.security.cert.Certificate;
  import java.util.HashMap;
  import java.util.Iterator;
***************
*** 337,341 ****
              try
              {
!                domain = (ProtectionDomain)domainConstructor.newInstance(new Object[]{new CodeSource(null, null), null, null, principals});
              }
              catch (Exception x)
--- 339,344 ----
              try
              {
!                Object[] args = new Object[]{new CodeSource((URL)null, (Certificate[])null), null, null, principals};
!                domain = (ProtectionDomain)domainConstructor.newInstance(args);
              }
              catch (Exception x)
***************
*** 347,351 ****
           {
              // This is done for JDK 1.3 compatibility.
!             domain = new SubjectProtectionDomain(new CodeSource(null, null), subject);
           }
        }
--- 350,354 ----
           {
              // This is done for JDK 1.3 compatibility.
!             domain = new SubjectProtectionDomain(new CodeSource((URL)null, (Certificate[])null), subject);
           }
        }
***************
*** 358,374 ****
        public ProtectionDomain[] combine(ProtectionDomain[] current, ProtectionDomain[] assigned)
        {
-          int length = current.length;
           ProtectionDomain[] result = null;
!          if (assigned == null || assigned.length == 0)
           {
!             result = new ProtectionDomain[length + 1];
!             System.arraycopy(current, 0, result, 1, length);
           }
           else
           {
!             result = new ProtectionDomain[length + assigned.length + 1];
!             System.arraycopy(current, 0, result, 1, length);
!             System.arraycopy(assigned, 0, result, length + 1, assigned.length);
           }
           result[0] = domain;
           this.combined = result;
--- 361,393 ----
        public ProtectionDomain[] combine(ProtectionDomain[] current, ProtectionDomain[] assigned)
        {
           ProtectionDomain[] result = null;
! 
!          if (current == null || current.length == 0)
           {
!             if (assigned == null || assigned.length == 0)
!             {
!                result = new ProtectionDomain[1];
!             }
!             else
!             {
!                result = new ProtectionDomain[assigned.length + 1];
!                System.arraycopy(assigned, 0, result, 1, assigned.length);
!             }
           }
           else
           {
!             if (assigned == null || assigned.length == 0)
!             {
!                result = new ProtectionDomain[current.length + 1];
!                System.arraycopy(current, 0, result, 1, current.length);
!             }
!             else
!             {
!                result = new ProtectionDomain[current.length + assigned.length + 1];
!                System.arraycopy(current, 0, result, 1, current.length);
!                System.arraycopy(assigned, 0, result, current.length + 1, assigned.length);
!             }
           }
+ 
           result[0] = domain;
           this.combined = result;



-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8