8008589: Better MBean permission validation
Better MBean permission validation Reviewed-by: skoivu, dfuchs, mchung, sjiang
This commit is contained in:
parent
f0b7243841
commit
455cd24c95
@ -26,6 +26,9 @@
|
|||||||
package javax.management;
|
package javax.management;
|
||||||
|
|
||||||
import java.security.BasicPermission;
|
import java.security.BasicPermission;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InvalidObjectException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This permission represents "trust" in a signer or codebase.
|
* This permission represents "trust" in a signer or codebase.
|
||||||
@ -75,15 +78,31 @@ public class MBeanTrustPermission extends BasicPermission {
|
|||||||
*/
|
*/
|
||||||
public MBeanTrustPermission(String name, String actions) {
|
public MBeanTrustPermission(String name, String actions) {
|
||||||
super(name, actions);
|
super(name, actions);
|
||||||
/* Check that actions is a null empty string */
|
validate(name,actions);
|
||||||
if (actions != null && actions.length() > 0)
|
}
|
||||||
throw new IllegalArgumentException("MBeanTrustPermission " +
|
|
||||||
"actions must be null: " +
|
|
||||||
actions);
|
|
||||||
|
|
||||||
if (!name.equals("register") && !name.equals("*"))
|
private static void validate(String name, String actions) {
|
||||||
throw new IllegalArgumentException("MBeanTrustPermission: " +
|
/* Check that actions is a null empty string */
|
||||||
"Unknown target name " +
|
if (actions != null && actions.length() > 0) {
|
||||||
|
throw new IllegalArgumentException("MBeanTrustPermission actions must be null: " +
|
||||||
|
actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!name.equals("register") && !name.equals("*")) {
|
||||||
|
throw new IllegalArgumentException("MBeanTrustPermission: Unknown target name " +
|
||||||
"[" + name + "]");
|
"[" + name + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readObject(ObjectInputStream in)
|
||||||
|
throws IOException, ClassNotFoundException {
|
||||||
|
|
||||||
|
// Reading private fields of base class
|
||||||
|
in.defaultReadObject();
|
||||||
|
try {
|
||||||
|
validate(super.getName(),super.getActions());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new InvalidObjectException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user