< prev index next >

test/java/security/ProtectionDomain/PreserveCombinerTest.java

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.security.AccessControlContext;
  25 import java.security.AccessController;
  26 import java.security.DomainCombiner;
  27 import java.security.PrivilegedAction;
  28 import java.security.ProtectionDomain;
  29 import sun.misc.SharedSecrets;
  30 
  31 /*
  32  * @test
  33  * @bug 8064331
  34  * @summary Make sure that JavaSecurityAccess.doIntersectionPrivilege()
  35  *          is not dropping the information about the domain combiner of
  36  *          the stack ACC

  37  */
  38 
  39 public class PreserveCombinerTest {
  40     public static void main(String[]args) throws Exception {
  41         final DomainCombiner dc = new DomainCombiner() {
  42             @Override
  43             public ProtectionDomain[] combine(ProtectionDomain[] currentDomains, ProtectionDomain[] assignedDomains) {
  44                 return currentDomains; // basically a no-op
  45             }
  46         };
  47 
  48         // Get an instance of the saved ACC
  49         AccessControlContext saved = AccessController.getContext();
  50         // Simulate the stack ACC with a DomainCombiner attached
  51         AccessControlContext stack = new AccessControlContext(AccessController.getContext(), dc);
  52 
  53         // Now try to run JavaSecurityAccess.doIntersectionPrivilege() and assert
  54         // whether the DomainCombiner from the stack ACC is preserved
  55         boolean ret = SharedSecrets.getJavaSecurityAccess().doIntersectionPrivilege(new PrivilegedAction<Boolean>() {
  56             @Override


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.security.AccessControlContext;
  25 import java.security.AccessController;
  26 import java.security.DomainCombiner;
  27 import java.security.PrivilegedAction;
  28 import java.security.ProtectionDomain;
  29 import sun.misc.SharedSecrets;
  30 
  31 /*
  32  * @test
  33  * @bug 8064331
  34  * @summary Make sure that JavaSecurityAccess.doIntersectionPrivilege()
  35  *          is not dropping the information about the domain combiner of
  36  *          the stack ACC
  37  * @modules java.base/sun.misc
  38  */
  39 
  40 public class PreserveCombinerTest {
  41     public static void main(String[]args) throws Exception {
  42         final DomainCombiner dc = new DomainCombiner() {
  43             @Override
  44             public ProtectionDomain[] combine(ProtectionDomain[] currentDomains, ProtectionDomain[] assignedDomains) {
  45                 return currentDomains; // basically a no-op
  46             }
  47         };
  48 
  49         // Get an instance of the saved ACC
  50         AccessControlContext saved = AccessController.getContext();
  51         // Simulate the stack ACC with a DomainCombiner attached
  52         AccessControlContext stack = new AccessControlContext(AccessController.getContext(), dc);
  53 
  54         // Now try to run JavaSecurityAccess.doIntersectionPrivilege() and assert
  55         // whether the DomainCombiner from the stack ACC is preserved
  56         boolean ret = SharedSecrets.getJavaSecurityAccess().doIntersectionPrivilege(new PrivilegedAction<Boolean>() {
  57             @Override
< prev index next >