8026193: Enhance CORBA stub factories

Modify com.sun.corba.se.impl.presenetation.rmi.StubFactoryDynamicBase inheritance structure.

Reviewed-by: alanb, coffeys, ahgross
This commit is contained in:
Mark Sheppard 2013-11-12 17:56:08 +00:00
parent 343c8d34a8
commit 9b16d87703
2 changed files with 31 additions and 9 deletions

View File

@ -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 @@ public abstract class StubFactoryDynamicBase extends StubFactoryBase
{
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 abstract class StubFactoryDynamicBase extends StubFactoryBase
}
}
public StubFactoryDynamicBase( PresentationManager.ClassData classData,
ClassLoader loader )
{
this (checkPermission(), classData, loader);
}
public abstract org.omg.CORBA.Object makeStub() ;
}

View File

@ -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);
}
});
}
}