< prev index next >

src/java.base/share/classes/javax/crypto/Cipher.java

Print this page

        

*** 491,515 **** * See the Cipher section in the <a href= * "{@docRoot}/../technotes/guides/security/StandardNames.html#Cipher"> * Java Cryptography Architecture Standard Algorithm Name Documentation</a> * for information about standard transformation names. * ! * @return a cipher that implements the requested transformation. * ! * @exception NoSuchAlgorithmException if {@code transformation} ! * is null, empty, in an invalid format, ! * or if no Provider supports a CipherSpi implementation for the ! * specified algorithm. * ! * @exception NoSuchPaddingException if {@code transformation} ! * contains a padding scheme that is not available. * * @see java.security.Provider */ public static final Cipher getInstance(String transformation) throws NoSuchAlgorithmException, NoSuchPaddingException { List<Transform> transforms = getTransforms(transformation); List<ServiceId> cipherServices = new ArrayList<>(transforms.size()); for (Transform transform : transforms) { cipherServices.add(new ServiceId("Cipher", transform.transform)); } --- 491,518 ---- * See the Cipher section in the <a href= * "{@docRoot}/../technotes/guides/security/StandardNames.html#Cipher"> * Java Cryptography Architecture Standard Algorithm Name Documentation</a> * for information about standard transformation names. * ! * @return a cipher that implements the requested transformation * ! * @throws NoSuchAlgorithmException if {@code transformation} ! * is {@code null}, empty, in an invalid format, ! * or if no {@code Provider} supports a {@code CipherSpi} ! * implementation for the specified algorithm * ! * @throws NoSuchPaddingException if {@code transformation} ! * contains a padding scheme that is not available * * @see java.security.Provider */ public static final Cipher getInstance(String transformation) throws NoSuchAlgorithmException, NoSuchPaddingException { + if ((transformation == null) || transformation.equals("")) { + throw new NoSuchAlgorithmException("Null or empty transformation"); + } List<Transform> transforms = getTransforms(transformation); List<ServiceId> cipherServices = new ArrayList<>(transforms.size()); for (Transform transform : transforms) { cipherServices.add(new ServiceId("Cipher", transform.transform)); }
*** 568,600 **** * Java Cryptography Architecture Standard Algorithm Name Documentation</a> * for information about standard transformation names. * * @param provider the name of the provider. * ! * @return a cipher that implements the requested transformation. * ! * @exception NoSuchAlgorithmException if {@code transformation} ! * is null, empty, in an invalid format, ! * or if a CipherSpi implementation for the specified algorithm ! * is not available from the specified provider. * ! * @exception NoSuchProviderException if the specified provider is not ! * registered in the security provider list. * ! * @exception NoSuchPaddingException if {@code transformation} ! * contains a padding scheme that is not available. * ! * @exception IllegalArgumentException if the {@code provider} ! * is null or empty. * * @see java.security.Provider */ public static final Cipher getInstance(String transformation, String provider) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException { if ((provider == null) || (provider.length() == 0)) { throw new IllegalArgumentException("Missing provider"); } Provider p = Security.getProvider(provider); if (p == null) { --- 571,607 ---- * Java Cryptography Architecture Standard Algorithm Name Documentation</a> * for information about standard transformation names. * * @param provider the name of the provider. * ! * @return a cipher that implements the requested transformation * ! * @throws IllegalArgumentException if the {@code provider} ! * is {@code null} or empty * ! * @throws NoSuchAlgorithmException if {@code transformation} ! * is {@code null}, empty, in an invalid format, ! * or if a {@code CipherSpi} implementation for the ! * specified algorithm is not available from the specified ! * provider * ! * @throws NoSuchPaddingException if {@code transformation} ! * contains a padding scheme that is not available * ! * @throws NoSuchProviderException if the specified provider is not ! * registered in the security provider list * * @see java.security.Provider */ public static final Cipher getInstance(String transformation, String provider) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException { + if ((transformation == null) || transformation.equals("")) { + throw new NoSuchAlgorithmException("Null or empty transformation"); + } if ((provider == null) || (provider.length() == 0)) { throw new IllegalArgumentException("Missing provider"); } Provider p = Security.getProvider(provider); if (p == null) {
*** 620,648 **** * Java Cryptography Architecture Standard Algorithm Name Documentation</a> * for information about standard transformation names. * * @param provider the provider. * ! * @return a cipher that implements the requested transformation. * ! * @exception NoSuchAlgorithmException if {@code transformation} ! * is null, empty, in an invalid format, ! * or if a CipherSpi implementation for the specified algorithm ! * is not available from the specified Provider object. * ! * @exception NoSuchPaddingException if {@code transformation} ! * contains a padding scheme that is not available. * ! * @exception IllegalArgumentException if the {@code provider} ! * is null. * * @see java.security.Provider */ public static final Cipher getInstance(String transformation, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException { if (provider == null) { throw new IllegalArgumentException("Missing provider"); } Exception failure = null; List<Transform> transforms = getTransforms(transformation); --- 627,659 ---- * Java Cryptography Architecture Standard Algorithm Name Documentation</a> * for information about standard transformation names. * * @param provider the provider. * ! * @return a cipher that implements the requested transformation * ! * @throws IllegalArgumentException if the {@code provider} ! * is {@code null} * ! * @throws NoSuchAlgorithmException if {@code transformation} ! * is {@code null}, empty, in an invalid format, ! * or if a {@code CipherSpi} implementation for the ! * specified algorithm is not available from the specified ! * {@code Provider} object * ! * @throws NoSuchPaddingException if {@code transformation} ! * contains a padding scheme that is not available * * @see java.security.Provider */ public static final Cipher getInstance(String transformation, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException { + if ((transformation == null) || transformation.equals("")) { + throw new NoSuchAlgorithmException("Null or empty transformation"); + } if (provider == null) { throw new IllegalArgumentException("Missing provider"); } Exception failure = null; List<Transform> transforms = getTransforms(transformation);
< prev index next >