System.arraycopy(iv, 0, encryptedBytes, 0, iv.length);
System.arraycopy(cipherOutput, 0, encryptedBytes, iv.length, cipherOutput.length);
return encryptedBytes;
} catch (NoSuchAlgorithmException ex) {
logger.log(Level.SEVERE, LogStringsMessages.WSS_1909_UNSUPPORTED_DATAENCRYPTION_ALGORITHM(getAlgorithm()), ex);
throw new XWSSecurityRuntimeException("Unable to compute CipherValue as "+getAlgorithm()+" is not supported", ex);
} catch (NoSuchPaddingException ex) {
logger.log(Level.SEVERE, LogStringsMessages.WSS_1905_ERROR_INITIALIZING_CIPHER(), ex);
throw new XWSSecurityRuntimeException("Error occurred while initializing the Cipher", ex);
} catch (InvalidKeyException ex) {
logger.log(Level.SEVERE, LogStringsMessages.WSS_1906_INVALID_KEY_ERROR(), ex);
throw new XWSSecurityRuntimeException("Unable to calculate cipher value as invalid key was provided", ex);
} catch (IllegalBlockSizeException ibse) {
logger.log(Level.SEVERE, LogStringsMessages.WSS_1915_INVALID_ALGORITHM_PARAMETERS(getAlgorithm()), ibse);
throw new XWSSecurityRuntimeException(ibse);
} catch (BadPaddingException bpe) {
logger.log(Level.SEVERE, LogStringsMessages.WSS_1915_INVALID_ALGORITHM_PARAMETERS(getAlgorithm()), bpe);
throw new XWSSecurityRuntimeException(bpe);
}
}