Merge

Sun, 13 Oct 2013 22:00:30 +0100

author
chegar
date
Sun, 13 Oct 2013 22:00:30 +0100
changeset 526
47513cdce4ed
parent 508
d7e478820c56
parent 525
396854c032bb
child 527
438c54c148a6

Merge

     1.1 --- a/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java	Thu Oct 10 10:08:52 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java	Sun Oct 13 22:00:30 2013 +0100
     1.3 @@ -905,28 +905,4 @@
     1.4  
     1.5          return contents.toString();
     1.6      }
     1.7 -
     1.8 -    public static void main(String[] args) {
     1.9 -
    1.10 -        Class remoteInterface = java.rmi.Remote.class;
    1.11 -
    1.12 -        if( args.length > 0 ) {
    1.13 -            String className = args[0];
    1.14 -            try {
    1.15 -                remoteInterface = Class.forName(className);
    1.16 -            } catch(Exception e) {
    1.17 -                e.printStackTrace();
    1.18 -                System.exit(-1);
    1.19 -            }
    1.20 -        }
    1.21 -
    1.22 -        System.out.println("Building name translation for " + remoteInterface);
    1.23 -        try {
    1.24 -            IDLNameTranslator nameTranslator =
    1.25 -                IDLNameTranslatorImpl.get(remoteInterface);
    1.26 -            System.out.println(nameTranslator);
    1.27 -        } catch(IllegalStateException ise) {
    1.28 -            ise.printStackTrace();
    1.29 -        }
    1.30 -    }
    1.31  }
     2.1 --- a/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java	Thu Oct 10 10:08:52 2013 -0700
     2.2 +++ b/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java	Sun Oct 13 22:00:30 2013 +0100
     2.3 @@ -43,6 +43,8 @@
     2.4  import com.sun.corba.se.spi.orbutil.proxy.DelegateInvocationHandlerImpl ;
     2.5  import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandler ;
     2.6  import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl ;
     2.7 +import java.security.AccessController;
     2.8 +import java.security.PrivilegedAction;
     2.9  
    2.10  public class InvocationHandlerFactoryImpl implements InvocationHandlerFactory
    2.11  {
    2.12 @@ -114,24 +116,32 @@
    2.13          // which extends org.omg.CORBA.Object.  This handler delegates all
    2.14          // calls directly to a DynamicStubImpl, which extends
    2.15          // org.omg.CORBA.portable.ObjectImpl.
    2.16 -        InvocationHandler dynamicStubHandler =
    2.17 +        final InvocationHandler dynamicStubHandler =
    2.18              DelegateInvocationHandlerImpl.create( stub ) ;
    2.19  
    2.20          // Create an invocation handler that handles any remote interface
    2.21          // methods.
    2.22 -        InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
    2.23 +        final InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
    2.24              pm, classData, stub ) ;
    2.25  
    2.26          // Create a composite handler that handles the DynamicStub interface
    2.27          // as well as the remote interfaces.
    2.28          final CompositeInvocationHandler handler =
    2.29              new CustomCompositeInvocationHandlerImpl( stub ) ;
    2.30 +
    2.31 +        AccessController.doPrivileged(new PrivilegedAction<Void>() {
    2.32 +            @Override
    2.33 +            public Void run() {
    2.34          handler.addInvocationHandler( DynamicStub.class,
    2.35              dynamicStubHandler ) ;
    2.36          handler.addInvocationHandler( org.omg.CORBA.Object.class,
    2.37              dynamicStubHandler ) ;
    2.38          handler.addInvocationHandler( Object.class,
    2.39              dynamicStubHandler ) ;
    2.40 +                return null;
    2.41 +            }
    2.42 +        });
    2.43 +
    2.44  
    2.45          // If the method passed to invoke is not from DynamicStub or its superclasses,
    2.46          // it must be from an implemented interface, so we just handle
     3.1 --- a/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Thu Oct 10 10:08:52 2013 -0700
     3.2 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Sun Oct 13 22:00:30 2013 +0100
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -55,7 +55,7 @@
    3.11  /**
    3.12   * @author Harold Carr
    3.13   */
    3.14 -public class SelectorImpl
    3.15 +class SelectorImpl
    3.16      extends
    3.17          Thread
    3.18      implements
     4.1 --- a/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java	Thu Oct 10 10:08:52 2013 -0700
     4.2 +++ b/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java	Sun Oct 13 22:00:30 2013 +0100
     4.3 @@ -36,6 +36,7 @@
     4.4  
     4.5  import com.sun.corba.se.spi.logging.CORBALogDomains ;
     4.6  import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
     4.7 +import com.sun.corba.se.impl.presentation.rmi.DynamicAccessPermission;
     4.8  
     4.9  public class CompositeInvocationHandlerImpl implements
    4.10      CompositeInvocationHandler
    4.11 @@ -46,11 +47,13 @@
    4.12      public void addInvocationHandler( Class interf,
    4.13          InvocationHandler handler )
    4.14      {
    4.15 +        checkAccess();
    4.16          classToInvocationHandler.put( interf, handler ) ;
    4.17      }
    4.18  
    4.19      public void setDefaultHandler( InvocationHandler handler )
    4.20      {
    4.21 +        checkAccess();
    4.22          defaultHandler = handler ;
    4.23      }
    4.24  
    4.25 @@ -78,4 +81,12 @@
    4.26  
    4.27          return handler.invoke( proxy, method, args ) ;
    4.28      }
    4.29 +
    4.30 +    private static final DynamicAccessPermission perm = new DynamicAccessPermission("access");
    4.31 +    private void checkAccess() {
    4.32 +        final SecurityManager sm = System.getSecurityManager();
    4.33 +        if (sm != null) {
    4.34 +            sm.checkPermission(perm);
    4.35  }
    4.36 +    }
    4.37 +}
     5.1 --- a/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java	Thu Oct 10 10:08:52 2013 -0700
     5.2 +++ b/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java	Sun Oct 13 22:00:30 2013 +0100
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -34,6 +34,9 @@
    5.11  
    5.12  import java.io.File;
    5.13  import java.io.IOException;
    5.14 +import java.io.SerializablePermission;
    5.15 +import java.security.AccessController;
    5.16 +import java.security.PrivilegedAction;
    5.17  import java.util.Vector;
    5.18  import java.util.Hashtable;
    5.19  import java.util.Enumeration;
    5.20 @@ -49,6 +52,7 @@
    5.21  import com.sun.corba.se.impl.util.PackagePrefixChecker;
    5.22  import sun.rmi.rmic.Main;
    5.23  
    5.24 +
    5.25  /**
    5.26   * An IIOP stub/tie generator for rmic.
    5.27   *
    5.28 @@ -78,6 +82,7 @@
    5.29      protected boolean castArray = false;
    5.30      protected Hashtable transactionalObjects = new Hashtable() ;
    5.31      protected boolean POATie = false ;
    5.32 +    protected boolean emitPermissionCheck = false;
    5.33  
    5.34      /**
    5.35       * Default constructor for Main to use.
    5.36 @@ -193,6 +198,9 @@
    5.37                      } else if (argv[i].equals("-standardPackage")) {
    5.38                          standardPackage = true;
    5.39                          argv[i] = null;
    5.40 +                    } else if (argv[i].equals("-emitPermissionCheck")) {
    5.41 +                        emitPermissionCheck = true;
    5.42 +                        argv[i] = null;
    5.43                      } else if (arg.equals("-xstubbase")) {
    5.44                          argv[i] = null;
    5.45                          if (++i < argv.length && argv[i] != null && !argv[i].startsWith("-")) {
    5.46 @@ -390,9 +398,22 @@
    5.47  
    5.48          writePackageAndImports(p);
    5.49  
    5.50 +//        generate
    5.51 +//        import java.security.AccessController;
    5.52 +//        import java.security.PrivilegedAction;
    5.53 +//        import java.io.SerializablePermission;
    5.54 +        if (emitPermissionCheck) {
    5.55 +            p.pln("import java.security.AccessController;");
    5.56 +            p.pln("import java.security.PrivilegedAction;");
    5.57 +            p.pln("import java.io.SerializablePermission;");
    5.58 +            p.pln();
    5.59 +            p.pln();
    5.60 +        }
    5.61 +
    5.62          // Declare the stub class; implement all remote interfaces.
    5.63  
    5.64          p.p("public class " + currentClass);
    5.65 +
    5.66          p.p(" extends " + getName(stubBaseClass));
    5.67          p.p(" implements ");
    5.68          if (remoteInterfaces.length > 0) {
    5.69 @@ -422,6 +443,57 @@
    5.70          writeIds( p, theType, false );
    5.71          p.pln();
    5.72  
    5.73 +        if (emitPermissionCheck) {
    5.74 +
    5.75 +            // produce the following generated code for example
    5.76 +            // private static Void checkPermission() {
    5.77 +            // SecurityManager sm = System.getSecurityManager();
    5.78 +            // if (sm != null) {
    5.79 +            //     sm.checkPermission(new SerializablePermission(
    5.80 +            // "enableSubclassImplementation")); // testing
    5.81 +            // }
    5.82 +            // return null;
    5.83 +            // }
    5.84 +            //
    5.85 +            // private _XXXXX_Stub(Void ignore) {
    5.86 +            // }
    5.87 +            //
    5.88 +            // public _XXXXX_Stub() {
    5.89 +            // this(checkPermission());
    5.90 +            // }
    5.91 +            //
    5.92 +            // where XXXXX is the name of the remote interface
    5.93 +
    5.94 +                p.pln();
    5.95 +                p.plnI("private static Void checkPermission() {");
    5.96 +                p.plnI("SecurityManager sm = System.getSecurityManager();");
    5.97 +                p.pln("if (sm != null) {");
    5.98 +                p.pI();
    5.99 +                p.plnI("sm.checkPermission(new SerializablePermission(");
   5.100 +                p.plnI("\"enableSubclassImplementation\"));");
   5.101 +                p.pO();
   5.102 +                p.pO();
   5.103 +                p.pOln("}");
   5.104 +                p.pln("return null;");
   5.105 +                p.pO();
   5.106 +                p.pOln("}");
   5.107 +                p.pln();
   5.108 +                p.pO();
   5.109 +
   5.110 +                p.pI();
   5.111 +                p.pln("private " + currentClass + "(Void ignore) {  }");
   5.112 +                p.pln();
   5.113 +
   5.114 +                p.plnI("public " + currentClass + "() { ");
   5.115 +                p.pln("this(checkPermission());");
   5.116 +                p.pOln("}");
   5.117 +                p.pln();
   5.118 +        }
   5.119 +
   5.120 +       if (!emitPermissionCheck) {
   5.121 +            p.pI();
   5.122 +       }
   5.123 +
   5.124          // Write the _ids() method...
   5.125  
   5.126          p.plnI("public String[] _ids() { ");
   5.127 @@ -815,7 +887,6 @@
   5.128                              CompoundType theType) throws IOException {
   5.129  
   5.130          // Wtite the method declaration and opening brace...
   5.131 -
   5.132          String methodName = method.getName();
   5.133          String methodIDLName = method.getIDLName();
   5.134  

mercurial