/** * Encrypts a key once for each key encryption parameters set that is supplied. * * @param key the key to encrypt * @param kekParamsList a list parameters for encrypting the key * @param containingDocument the document that will own the DOM element underlying the resulting EncryptedKey * objects * * @return the resulting list of EncryptedKey objects * * @throws EncryptionException exception thrown on encryption errors */ public List<EncryptedKey> encryptKey(Key key, List<KeyEncryptionParameters> kekParamsList, Document containingDocument) throws EncryptionException { checkParams(kekParamsList, false); List<EncryptedKey> encKeys = new ArrayList<EncryptedKey>(); for (KeyEncryptionParameters kekParam : kekParamsList) { encKeys.add(encryptKey(key, kekParam, containingDocument)); } return encKeys; }
/** * Encrypts a key once for each key encryption parameters set that is supplied. * * @param key the key to encrypt * @param kekParamsList a list parameters for encrypting the key * @param containingDocument the document that will own the DOM element underlying the resulting EncryptedKey * objects * * @return the resulting list of EncryptedKey objects * * @throws EncryptionException exception thrown on encryption errors */ public List<EncryptedKey> encryptKey(Key key, List<KeyEncryptionParameters> kekParamsList, Document containingDocument) throws EncryptionException { checkParams(kekParamsList, false); List<EncryptedKey> encKeys = new ArrayList<EncryptedKey>(); for (KeyEncryptionParameters kekParam : kekParamsList) { encKeys.add(encryptKey(key, kekParam, containingDocument)); } return encKeys; }
/** * Check a list of key encryption parameters for consistency and required values. * * @param kekParamsList the key encryption parameters list to check * @param allowEmpty if false, a null or empty list is treated as an error * * @throws EncryptionException thrown if any parameters are missing or have invalid values */ protected void checkParams(List<KeyEncryptionParameters> kekParamsList, boolean allowEmpty) throws EncryptionException { if (kekParamsList == null || kekParamsList.isEmpty()) { if (allowEmpty) { return; } else { log.error("Key encryption parameters list may not be empty"); throw new EncryptionException("Key encryption parameters list may not be empty"); } } for (KeyEncryptionParameters kekParams : kekParamsList) { checkParams(kekParams, false); } }
/** * Check a list of key encryption parameters for consistency and required values. * * @param kekParamsList the key encryption parameters list to check * @param allowEmpty if false, a null or empty list is treated as an error * * @throws EncryptionException thrown if any parameters are missing or have invalid values */ protected void checkParams(List<KeyEncryptionParameters> kekParamsList, boolean allowEmpty) throws EncryptionException { if (kekParamsList == null || kekParamsList.isEmpty()) { if (allowEmpty) { return; } else { log.error("Key encryption parameters list may not be empty"); throw new EncryptionException("Key encryption parameters list may not be empty"); } } for (KeyEncryptionParameters kekParams : kekParamsList) { checkParams(kekParams, false); } }
/** * Check the encryption parameters and key encryption parameters for valid combinations of options. * * @param encParams the encryption parameters to use * @param kekParamsList the key encryption parameters to use * @throws EncryptionException exception thrown on encryption errors */ protected void checkParams(EncryptionParameters encParams, List<KeyEncryptionParameters> kekParamsList) throws EncryptionException { checkParams(encParams); checkParams(kekParamsList, true); if (SecurityHelper.extractEncryptionKey(encParams.getEncryptionCredential()) == null && (kekParamsList == null || kekParamsList.isEmpty())) { log.error("Using a generated encryption key requires a KeyEncryptionParameters " + "object and key encryption key"); throw new EncryptionException("Using a generated encryption key requires a KeyEncryptionParameters " + "object and key encryption key"); } }
/** * Check the encryption parameters and key encryption parameters for valid combinations of options. * * @param encParams the encryption parameters to use * @param kekParamsList the key encryption parameters to use * @throws EncryptionException exception thrown on encryption errors */ protected void checkParams(EncryptionParameters encParams, List<KeyEncryptionParameters> kekParamsList) throws EncryptionException { checkParams(encParams); checkParams(kekParamsList, true); if (SecurityHelper.extractEncryptionKey(encParams.getEncryptionCredential()) == null && (kekParamsList == null || kekParamsList.isEmpty())) { log.error("Using a generated encryption key requires a KeyEncryptionParameters " + "object and key encryption key"); throw new EncryptionException("Using a generated encryption key requires a KeyEncryptionParameters " + "object and key encryption key"); } }
throws EncryptionException { checkParams(kekParams, false);
throws EncryptionException { checkParams(kekParams, false);
List<KeyEncryptionParameters> kekParamsList, boolean encryptContentMode) throws EncryptionException { checkParams(encParams, kekParamsList);
List<KeyEncryptionParameters> kekParamsList, boolean encryptContentMode) throws EncryptionException { checkParams(encParams, kekParamsList);