8026193: Enhance CORBA stub factories
authormsheppar
Tue, 12 Nov 2013 17:56:08 +0000
changeset 22361 ac542ac9f21d
parent 22173 f130ca87de66
child 22362 1eb21f1e04c1
8026193: Enhance CORBA stub factories Summary: modify com.sun.corba.se.impl.presenetation.rmi.StubFactoryDynamicBase inheritance structure. Reviewed-by: alanb, coffeys, ahgross
corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java
corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java
--- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java	Wed Jul 05 19:26:54 2017 +0200
+++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java	Tue Nov 12 17:56:08 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 package com.sun.corba.se.impl.presentation.rmi ;
 
+import java.io.SerializablePermission;
 import java.lang.reflect.InvocationHandler ;
 import java.lang.reflect.Proxy ;
 
@@ -38,11 +39,18 @@
 {
     protected final ClassLoader loader ;
 
-    public StubFactoryDynamicBase( PresentationManager.ClassData classData,
-        ClassLoader loader )
-    {
-        super( classData ) ;
+    private static Void checkPermission() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new SerializablePermission(
+                    "enableSubclassImplementation"));
+        }
+        return null;
+    }
 
+    private StubFactoryDynamicBase(Void unused,
+            PresentationManager.ClassData classData, ClassLoader loader) {
+        super(classData);
         // this.loader must not be null, or the newProxyInstance call
         // will fail.
         if (loader == null) {
@@ -55,5 +63,11 @@
         }
     }
 
+    public StubFactoryDynamicBase( PresentationManager.ClassData classData,
+        ClassLoader loader )
+    {
+        this (checkPermission(), classData, loader);
+    }
+
     public abstract org.omg.CORBA.Object makeStub() ;
 }
--- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java	Wed Jul 05 19:26:54 2017 +0200
+++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java	Tue Nov 12 17:56:08 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,22 @@
 
 package com.sun.corba.se.impl.presentation.rmi;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import com.sun.corba.se.spi.presentation.rmi.PresentationManager ;
 
 public class StubFactoryFactoryProxyImpl extends StubFactoryFactoryDynamicBase
 {
     public PresentationManager.StubFactory makeDynamicStubFactory(
-        PresentationManager pm, PresentationManager.ClassData classData,
-        ClassLoader classLoader )
+        PresentationManager pm, final PresentationManager.ClassData classData,
+        final ClassLoader classLoader )
     {
-        return new StubFactoryProxyImpl( classData, classLoader ) ;
+        return AccessController
+                .doPrivileged(new PrivilegedAction<StubFactoryProxyImpl>() {
+                    @Override
+                    public StubFactoryProxyImpl run() {
+                        return new StubFactoryProxyImpl(classData, classLoader);
+                    }
+                });
     }
 }