src/java.security.jgss/share/classes/javax/security/auth/kerberos/DelegationPermission.java
changeset 58831 b026a43e1809
parent 47216 71c04702a3d5
equal deleted inserted replaced
58830:fa0b9f9c597a 58831:b026a43e1809
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    76      * with the specified subordinate and target principals.
    76      * with the specified subordinate and target principals.
    77      *
    77      *
    78      * @param principals the name of the subordinate and target principals
    78      * @param principals the name of the subordinate and target principals
    79      *
    79      *
    80      * @throws NullPointerException if {@code principals} is {@code null}.
    80      * @throws NullPointerException if {@code principals} is {@code null}.
    81      * @throws IllegalArgumentException if {@code principals} is empty.
    81      * @throws IllegalArgumentException if {@code principals} is empty,
       
    82      *      or does not contain a pair of principals, or is improperly quoted
    82      */
    83      */
    83     public DelegationPermission(String principals) {
    84     public DelegationPermission(String principals) {
    84         super(principals);
    85         super(principals);
    85         init(principals);
    86         init(principals);
    86     }
    87     }
    92      * @param principals the name of the subordinate and target principals
    93      * @param principals the name of the subordinate and target principals
    93      *
    94      *
    94      * @param actions should be null.
    95      * @param actions should be null.
    95      *
    96      *
    96      * @throws NullPointerException if {@code principals} is {@code null}.
    97      * @throws NullPointerException if {@code principals} is {@code null}.
    97      * @throws IllegalArgumentException if {@code principals} is empty.
    98      * @throws IllegalArgumentException if {@code principals} is empty,
       
    99      *      or does not contain a pair of principals, or is improperly quoted
    98      */
   100      */
    99     public DelegationPermission(String principals, String actions) {
   101     public DelegationPermission(String principals, String actions) {
   100         super(principals, actions);
   102         super(principals, actions);
   101         init(principals);
   103         init(principals);
   102     }
   104     }
   114                  "] syntax invalid: " +
   116                  "] syntax invalid: " +
   115                  "improperly quoted");
   117                  "improperly quoted");
   116         } else {
   118         } else {
   117             t = new StringTokenizer(target, "\"", false);
   119             t = new StringTokenizer(target, "\"", false);
   118             subordinate = t.nextToken();
   120             subordinate = t.nextToken();
   119             if (t.countTokens() == 2) {
   121             switch (t.countTokens()) {
   120                 t.nextToken();  // bypass whitespace
   122                 case 2:
   121                 service = t.nextToken();
   123                     t.nextToken();  // bypass whitespace
   122             } else if (t.countTokens() > 0) {
   124                     service = t.nextToken();
   123                 throw new IllegalArgumentException
   125                     break;
   124                     ("service principal [" + t.nextToken() +
   126                 case 0:
   125                      "] syntax invalid: " +
   127                     throw new IllegalArgumentException
   126                      "improperly quoted");
   128                             ("service principal not provided");
       
   129                 default:
       
   130                     throw new IllegalArgumentException
       
   131                             ("service principal [" + t.nextToken() +
       
   132                             "] syntax invalid: " +
       
   133                             "improperly quoted");
   127             }
   134             }
   128         }
   135         }
   129     }
   136     }
   130 
   137 
   131     /**
   138     /**