1.1 --- a/src/share/classes/org/omg/CORBA_2_3/portable/InputStream.java Tue Nov 12 17:56:08 2013 +0000 1.2 +++ b/src/share/classes/org/omg/CORBA_2_3/portable/InputStream.java Tue Nov 12 18:04:13 2013 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -31,6 +31,10 @@ 1.11 1.12 package org.omg.CORBA_2_3.portable; 1.13 1.14 +import java.io.SerializablePermission; 1.15 +import java.security.AccessController; 1.16 +import java.security.PrivilegedAction; 1.17 + 1.18 /** 1.19 * InputStream provides for the reading of all of the mapped IDL types 1.20 * from the stream. It extends org.omg.CORBA.portable.InputStream. This 1.21 @@ -43,6 +47,43 @@ 1.22 1.23 public abstract class InputStream extends org.omg.CORBA.portable.InputStream { 1.24 1.25 + 1.26 + private static final String ALLOW_SUBCLASS_PROP = "jdk.corba.allowInputStreamSubclass"; 1.27 + 1.28 + private static final boolean allowSubclass = AccessController.doPrivileged( 1.29 + new PrivilegedAction<Boolean>() { 1.30 + @Override 1.31 + public Boolean run() { 1.32 + String prop = System.getProperty(ALLOW_SUBCLASS_PROP); 1.33 + return prop == null ? false : 1.34 + (prop.equalsIgnoreCase("false") ? false : true); 1.35 + } 1.36 + }); 1.37 + 1.38 + private static Void checkPermission() { 1.39 + SecurityManager sm = System.getSecurityManager(); 1.40 + if (sm != null) { 1.41 + if (!allowSubclass) 1.42 + sm.checkPermission(new 1.43 + SerializablePermission("enableSubclassImplementation")); 1.44 + } 1.45 + return null; 1.46 + } 1.47 + 1.48 + private InputStream(Void ignore) { } 1.49 + 1.50 + /** 1.51 + * Create a new instance of this class. 1.52 + * 1.53 + * throw SecurityException if SecurityManager is installed and 1.54 + * enableSubclassImplementation SerializablePermission 1.55 + * is not granted or jdk.corba.allowOutputStreamSubclass system 1.56 + * property is either not set or is set to 'false' 1.57 + */ 1.58 + public InputStream() { 1.59 + this(checkPermission()); 1.60 + } 1.61 + 1.62 /** 1.63 * Unmarshalls a value type from the input stream. 1.64 * @return the value type unmarshalled from the input stream