57 this.encodedKey = encodedKey.clone(); 58 } 59 60 /** 61 * Creates a new {@code EncodedKeySpec} with the given encoded key. 62 * This constructor is useful when subsequent callers of the 63 * {@code EncodedKeySpec} object might not know the algorithm 64 * of the key. 65 * 66 * @param encodedKey the encoded key. The contents of the 67 * array are copied to protect against subsequent modification. 68 * @param algorithm the algorithm name of the encoded key 69 * See the KeyFactory section in the <a href= 70 * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory"> 71 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> 72 * for information about standard algorithm names. 73 * @throws NullPointerException if {@code encodedKey} 74 * or {@code algorithm} is null. 75 * @throws IllegalArgumentException if {@code algorithm} is 76 * the empty string {@code ""} 77 * @since 1.9 78 */ 79 protected EncodedKeySpec(byte[] encodedKey, String algorithm) { 80 if (algorithm == null) { 81 throw new NullPointerException("algorithm name may not be null"); 82 } 83 if (algorithm.isEmpty()) { 84 throw new IllegalArgumentException("algorithm name " 85 + "may not be empty"); 86 } 87 this.encodedKey = encodedKey.clone(); 88 this.algorithmName = algorithm; 89 90 } 91 92 /** 93 * Returns the name of the algorithm of the encoded key. 94 * 95 * @return the name of the algorithm, or null if not specified 96 * @since 1.9 97 */ 98 public String getAlgorithm() { 99 return algorithmName; 100 } 101 102 /** 103 * Returns the encoded key. 104 * 105 * @return the encoded key. Returns a new array each time 106 * this method is called. 107 */ 108 public byte[] getEncoded() { 109 return this.encodedKey.clone(); 110 } 111 112 /** 113 * Returns the name of the encoding format associated with this 114 * key specification. 115 * 116 * <p>If the opaque representation of a key | 57 this.encodedKey = encodedKey.clone(); 58 } 59 60 /** 61 * Creates a new {@code EncodedKeySpec} with the given encoded key. 62 * This constructor is useful when subsequent callers of the 63 * {@code EncodedKeySpec} object might not know the algorithm 64 * of the key. 65 * 66 * @param encodedKey the encoded key. The contents of the 67 * array are copied to protect against subsequent modification. 68 * @param algorithm the algorithm name of the encoded key 69 * See the KeyFactory section in the <a href= 70 * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory"> 71 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> 72 * for information about standard algorithm names. 73 * @throws NullPointerException if {@code encodedKey} 74 * or {@code algorithm} is null. 75 * @throws IllegalArgumentException if {@code algorithm} is 76 * the empty string {@code ""} 77 * @since 9 78 */ 79 protected EncodedKeySpec(byte[] encodedKey, String algorithm) { 80 if (algorithm == null) { 81 throw new NullPointerException("algorithm name may not be null"); 82 } 83 if (algorithm.isEmpty()) { 84 throw new IllegalArgumentException("algorithm name " 85 + "may not be empty"); 86 } 87 this.encodedKey = encodedKey.clone(); 88 this.algorithmName = algorithm; 89 90 } 91 92 /** 93 * Returns the name of the algorithm of the encoded key. 94 * 95 * @return the name of the algorithm, or null if not specified 96 * @since 9 97 */ 98 public String getAlgorithm() { 99 return algorithmName; 100 } 101 102 /** 103 * Returns the encoded key. 104 * 105 * @return the encoded key. Returns a new array each time 106 * this method is called. 107 */ 108 public byte[] getEncoded() { 109 return this.encodedKey.clone(); 110 } 111 112 /** 113 * Returns the name of the encoding format associated with this 114 * key specification. 115 * 116 * <p>If the opaque representation of a key |