< prev index next >

src/java.base/share/classes/java/security/Policy.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb


 439      *         support a {@code PolicySpi} implementation for the specified
 440      *         type
 441      *
 442      * @throws NoSuchProviderException if the specified provider is not
 443      *         registered in the security provider list
 444      *
 445      * @throws NullPointerException if {@code type} is {@code null}
 446      *
 447      * @throws SecurityException if the caller does not have permission
 448      *         to get a {@code Policy} instance for the specified type
 449      *
 450      * @see Provider
 451      * @since 1.6
 452      */
 453     public static Policy getInstance(String type,
 454                                 Policy.Parameters params,
 455                                 String provider)
 456                 throws NoSuchProviderException, NoSuchAlgorithmException {
 457 
 458         Objects.requireNonNull(type, "null type name");
 459         if (provider == null || provider.length() == 0) {
 460             throw new IllegalArgumentException("missing provider");
 461         }
 462 
 463         checkPermission(type);
 464         try {
 465             GetInstance.Instance instance = GetInstance.getInstance("Policy",
 466                                                         PolicySpi.class,
 467                                                         type,
 468                                                         params,
 469                                                         provider);
 470             return new PolicyDelegate((PolicySpi)instance.impl,
 471                                                         instance.provider,
 472                                                         type,
 473                                                         params);
 474         } catch (NoSuchAlgorithmException nsae) {
 475             return handleException(nsae);
 476         }
 477     }
 478 
 479     /**




 439      *         support a {@code PolicySpi} implementation for the specified
 440      *         type
 441      *
 442      * @throws NoSuchProviderException if the specified provider is not
 443      *         registered in the security provider list
 444      *
 445      * @throws NullPointerException if {@code type} is {@code null}
 446      *
 447      * @throws SecurityException if the caller does not have permission
 448      *         to get a {@code Policy} instance for the specified type
 449      *
 450      * @see Provider
 451      * @since 1.6
 452      */
 453     public static Policy getInstance(String type,
 454                                 Policy.Parameters params,
 455                                 String provider)
 456                 throws NoSuchProviderException, NoSuchAlgorithmException {
 457 
 458         Objects.requireNonNull(type, "null type name");
 459         if (provider == null || provider.isEmpty()) {
 460             throw new IllegalArgumentException("missing provider");
 461         }
 462 
 463         checkPermission(type);
 464         try {
 465             GetInstance.Instance instance = GetInstance.getInstance("Policy",
 466                                                         PolicySpi.class,
 467                                                         type,
 468                                                         params,
 469                                                         provider);
 470             return new PolicyDelegate((PolicySpi)instance.impl,
 471                                                         instance.provider,
 472                                                         type,
 473                                                         params);
 474         } catch (NoSuchAlgorithmException nsae) {
 475             return handleException(nsae);
 476         }
 477     }
 478 
 479     /**


< prev index next >