JDK-8232155 : DelegationPermission constructors have imprecise spec
  • Type: CSR
  • Component: security-libs
  • Sub-Component: javax.security
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-10-11
  • Updated: 2019-11-15
  • Resolved: 2019-10-29
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Update the spec of 2 `DelegationPermission` constructors to precisely describe when an `IllegalArgumentException` would be thrown.

Problem
-------

The current spec shows `@throws IllegalArgumentException if {@code principals} is empty` but the exception is also thrown when the argument is not correctly quoted. Also, when the argument does not contain a pair of principals, the constructor will succeed but the service principal inside is null and any method called on the newly created object would throw a NPE. This should also be dealt with in the constructors.

Solution
--------

See spec below.

Specification
-------------

    --- a/src/java.security.jgss/share/classes/javax/security/auth/kerberos/DelegationPermission.java
    +++ b/src/java.security.jgss/share/classes/javax/security/auth/kerberos/DelegationPermission.java
    @@ -78,7 +78,8 @@
          * @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 @@
          * @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);


Comments
Moving to Approved; I see a release note is already planned.
29-10-2019