< prev index next >

src/java.base/share/classes/sun/security/jca/GetInstance.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


  58         // old Security.getImpl() methods.
  59         public Object[] toArray() {
  60             return new Object[] {impl, provider};
  61         }
  62     }
  63 
  64     public static Service getService(String type, String algorithm)
  65             throws NoSuchAlgorithmException {
  66         ProviderList list = Providers.getProviderList();
  67         Service s = list.getService(type, algorithm);
  68         if (s == null) {
  69             throw new NoSuchAlgorithmException
  70                     (algorithm + " " + type + " not available");
  71         }
  72         return s;
  73     }
  74 
  75     public static Service getService(String type, String algorithm,
  76             String provider) throws NoSuchAlgorithmException,
  77             NoSuchProviderException {
  78         if ((provider == null) || (provider.length() == 0)) {
  79             throw new IllegalArgumentException("missing provider");
  80         }
  81         Provider p = Providers.getProviderList().getProvider(provider);
  82         if (p == null) {
  83             throw new NoSuchProviderException("no such provider: " + provider);
  84         }
  85         Service s = p.getService(type, algorithm);
  86         if (s == null) {
  87             throw new NoSuchAlgorithmException("no such algorithm: "
  88                 + algorithm + " for provider " + provider);
  89         }
  90         return s;
  91     }
  92 
  93     public static Service getService(String type, String algorithm,
  94             Provider provider) throws NoSuchAlgorithmException {
  95         if (provider == null) {
  96             throw new IllegalArgumentException("missing provider");
  97         }
  98         Service s = provider.getService(type, algorithm);




  58         // old Security.getImpl() methods.
  59         public Object[] toArray() {
  60             return new Object[] {impl, provider};
  61         }
  62     }
  63 
  64     public static Service getService(String type, String algorithm)
  65             throws NoSuchAlgorithmException {
  66         ProviderList list = Providers.getProviderList();
  67         Service s = list.getService(type, algorithm);
  68         if (s == null) {
  69             throw new NoSuchAlgorithmException
  70                     (algorithm + " " + type + " not available");
  71         }
  72         return s;
  73     }
  74 
  75     public static Service getService(String type, String algorithm,
  76             String provider) throws NoSuchAlgorithmException,
  77             NoSuchProviderException {
  78         if (provider == null || provider.isEmpty()) {
  79             throw new IllegalArgumentException("missing provider");
  80         }
  81         Provider p = Providers.getProviderList().getProvider(provider);
  82         if (p == null) {
  83             throw new NoSuchProviderException("no such provider: " + provider);
  84         }
  85         Service s = p.getService(type, algorithm);
  86         if (s == null) {
  87             throw new NoSuchAlgorithmException("no such algorithm: "
  88                 + algorithm + " for provider " + provider);
  89         }
  90         return s;
  91     }
  92 
  93     public static Service getService(String type, String algorithm,
  94             Provider provider) throws NoSuchAlgorithmException {
  95         if (provider == null) {
  96             throw new IllegalArgumentException("missing provider");
  97         }
  98         Service s = provider.getService(type, algorithm);


< prev index next >