changeset 553:08bd81c188de

8026193: Enhance CORBA stub factories Summary: modify com.sun.corba.se.impl.presenetation.rmi.StubFactoryDynamicBase inheritance structure. Reviewed-by: alanb, coffeys, ahgross
author msheppar
date Tue, 12 Nov 2013 17:56:08 +0000
parents 79a8136b18c1
children 28ea7aca8b5a
files src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java
diffstat 2 files changed, 31 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java	Mon Dec 23 18:42:26 2013 +0000
+++ b/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/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryFactoryProxyImpl.java	Mon Dec 23 18:42:26 2013 +0000
+++ b/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);
+                    }
+                });
     }
 }