320 * @exception IllegalArgumentException if the given provider is null
321 * or empty.
322 * @exception IOException if an error occurs during de-serialiazation.
323 * @exception ClassNotFoundException if an error occurs during
324 * de-serialiazation.
325 * @exception NoSuchAlgorithmException if the algorithm to unseal the
326 * object is not available.
327 * @exception NoSuchProviderException if the given provider is not
328 * configured.
329 * @exception InvalidKeyException if the given key cannot be used to unseal
330 * the object (e.g., it has the wrong algorithm).
331 * @exception NullPointerException if <code>key</code> is null.
332 */
333 public final Object getObject(Key key, String provider)
334 throws IOException, ClassNotFoundException, NoSuchAlgorithmException,
335 NoSuchProviderException, InvalidKeyException
336 {
337 if (key == null) {
338 throw new NullPointerException("key is null");
339 }
340 if (provider == null || provider.length() == 0) {
341 throw new IllegalArgumentException("missing provider");
342 }
343
344 try {
345 return unseal(key, provider);
346 } catch (IllegalBlockSizeException | BadPaddingException ex) {
347 throw new InvalidKeyException(ex.getMessage());
348 }
349 }
350
351
352 private Object unseal(Key key, String provider)
353 throws IOException, ClassNotFoundException, NoSuchAlgorithmException,
354 NoSuchProviderException, InvalidKeyException,
355 IllegalBlockSizeException, BadPaddingException
356 {
357 /*
358 * Create the parameter object.
359 */
360 AlgorithmParameters params = null;
|
320 * @exception IllegalArgumentException if the given provider is null
321 * or empty.
322 * @exception IOException if an error occurs during de-serialiazation.
323 * @exception ClassNotFoundException if an error occurs during
324 * de-serialiazation.
325 * @exception NoSuchAlgorithmException if the algorithm to unseal the
326 * object is not available.
327 * @exception NoSuchProviderException if the given provider is not
328 * configured.
329 * @exception InvalidKeyException if the given key cannot be used to unseal
330 * the object (e.g., it has the wrong algorithm).
331 * @exception NullPointerException if <code>key</code> is null.
332 */
333 public final Object getObject(Key key, String provider)
334 throws IOException, ClassNotFoundException, NoSuchAlgorithmException,
335 NoSuchProviderException, InvalidKeyException
336 {
337 if (key == null) {
338 throw new NullPointerException("key is null");
339 }
340 if (provider == null || provider.isEmpty()) {
341 throw new IllegalArgumentException("missing provider");
342 }
343
344 try {
345 return unseal(key, provider);
346 } catch (IllegalBlockSizeException | BadPaddingException ex) {
347 throw new InvalidKeyException(ex.getMessage());
348 }
349 }
350
351
352 private Object unseal(Key key, String provider)
353 throws IOException, ClassNotFoundException, NoSuchAlgorithmException,
354 NoSuchProviderException, InvalidKeyException,
355 IllegalBlockSizeException, BadPaddingException
356 {
357 /*
358 * Create the parameter object.
359 */
360 AlgorithmParameters params = null;
|