提交 8119e7a8 编写于 作者: V valeriep

6469513: (smartcardio) CardPermission(String termName, String actions) violates specification

Summary: Changed to allow null actions value
Reviewed-by: xuelei
上级 de9a307d
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2016, 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
......@@ -118,7 +118,7 @@ public class CardPermission extends Permission {
/**
* @serial
*/
private volatile String actions;
private final String actions;
/**
* Constructs a new CardPermission with the specified actions.
......@@ -143,10 +143,14 @@ public class CardPermission extends Permission {
throw new NullPointerException();
}
mask = getMask(actions);
this.actions = getActions(mask);
}
private static int getMask(String actions) {
if ((actions == null) || (actions.length() == 0)) {
if (actions == null) {
return 0;
}
if (actions.length() == 0) {
throw new IllegalArgumentException("actions must not be empty");
}
......@@ -177,6 +181,9 @@ public class CardPermission extends Permission {
}
private static String getActions(int mask) {
if (mask == 0) {
return null;
}
if (mask == A_ALL) {
return S_ALL;
}
......@@ -200,9 +207,6 @@ public class CardPermission extends Permission {
* @return the canonical string representation of the actions.
*/
public String getActions() {
if (actions == null) {
actions = getActions(mask);
}
return actions;
}
......@@ -278,10 +282,6 @@ public class CardPermission extends Permission {
private void writeObject(ObjectOutputStream s) throws IOException {
// Write out the actions. The superclass takes care of the name.
// Call getActions to make sure actions field is initialized
if (actions == null) {
getActions();
}
s.defaultWriteObject();
}
......@@ -291,5 +291,4 @@ public class CardPermission extends Permission {
s.defaultReadObject();
mask = getMask(actions);
}
}
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2016, 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
......@@ -23,7 +23,7 @@
/**
* @test
* @bug 6293767
* @bug 6293767 6469513
* @summary Test for the CardPermission class
* @author Andreas Sterbenz
* @compile --add-modules=java.smartcardio TestCardPermission.java
......@@ -49,15 +49,14 @@ public class TestCardPermission {
test("Reset,coNnect", "connect,reset");
test("exclusive,*,connect", "*");
test("connect,reset,exclusive,transmitControl,getBasicChannel,openLogicalChannel", "*");
test(null, null);
invalid(null);
invalid("");
invalid("foo");
invalid("connect, reset");
invalid("connect,,reset");
invalid("connect,");
invalid(",connect");
invalid("");
}
private static void invalid(String s) throws Exception {
......@@ -77,7 +76,7 @@ public class TestCardPermission {
CardPermission p = new CardPermission("*", actions);
System.out.println(p);
String a = p.getActions();
if (canon.equals(a) == false) {
if (canon != null && canon.equals(a) == false) {
throw new Exception("Canonical actions mismatch: " + canon + " != " + a);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册