mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 03:54:33 +02:00
8231365: ServicePermission::equals doesn't comply to the spec
8231196: DelegationPermission allows to create an instance that thows NPE on ::equals call Reviewed-by: mullan
This commit is contained in:
parent
055a49a266
commit
026a05d0c6
5 changed files with 106 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, 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
|
||||
|
@ -78,7 +78,8 @@ public final class DelegationPermission extends BasicPermission
|
|||
* @param principals the name of the subordinate and target principals
|
||||
*
|
||||
* @throws NullPointerException if {@code principals} is {@code null}.
|
||||
* @throws IllegalArgumentException if {@code principals} is empty.
|
||||
* @throws IllegalArgumentException if {@code principals} is empty,
|
||||
* or does not contain a pair of principals, or is improperly quoted
|
||||
*/
|
||||
public DelegationPermission(String principals) {
|
||||
super(principals);
|
||||
|
@ -94,7 +95,8 @@ public final class DelegationPermission extends BasicPermission
|
|||
* @param actions should be null.
|
||||
*
|
||||
* @throws NullPointerException if {@code principals} is {@code null}.
|
||||
* @throws IllegalArgumentException if {@code principals} is empty.
|
||||
* @throws IllegalArgumentException if {@code principals} is empty,
|
||||
* or does not contain a pair of principals, or is improperly quoted
|
||||
*/
|
||||
public DelegationPermission(String principals, String actions) {
|
||||
super(principals, actions);
|
||||
|
@ -116,14 +118,19 @@ public final class DelegationPermission extends BasicPermission
|
|||
} else {
|
||||
t = new StringTokenizer(target, "\"", false);
|
||||
subordinate = t.nextToken();
|
||||
if (t.countTokens() == 2) {
|
||||
t.nextToken(); // bypass whitespace
|
||||
service = t.nextToken();
|
||||
} else if (t.countTokens() > 0) {
|
||||
throw new IllegalArgumentException
|
||||
("service principal [" + t.nextToken() +
|
||||
"] syntax invalid: " +
|
||||
"improperly quoted");
|
||||
switch (t.countTokens()) {
|
||||
case 2:
|
||||
t.nextToken(); // bypass whitespace
|
||||
service = t.nextToken();
|
||||
break;
|
||||
case 0:
|
||||
throw new IllegalArgumentException
|
||||
("service principal not provided");
|
||||
default:
|
||||
throw new IllegalArgumentException
|
||||
("service principal [" + t.nextToken() +
|
||||
"] syntax invalid: " +
|
||||
"improperly quoted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, 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
|
||||
|
@ -238,7 +238,7 @@ public final class ServicePermission extends Permission
|
|||
return false;
|
||||
|
||||
ServicePermission that = (ServicePermission) obj;
|
||||
return ((this.mask & that.mask) == that.mask) &&
|
||||
return (this.mask == that.mask) &&
|
||||
this.getName().equals(that.getName());
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue