Example usage for javax.crypto IllegalBlockSizeException getCause

List of usage examples for javax.crypto IllegalBlockSizeException getCause

Introduction

In this page you can find the example usage for javax.crypto IllegalBlockSizeException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:main.java.vasolsim.common.file.__NONUSEDREFERENCE_VaSOLSimExam.java

/**
 * This function uses the initialized ciphers to encrypt properties of the file. If any properties or questions are
 * updated, this function must be called in order to have access to the encrypted data prior to the write process.
 * This function is called by default at the start of the write function. NOTE: if the cryptographic key is
 * updated,/*from   w ww  . jav  a 2s  . com*/
 * updateCryptoEngine() must be called first or this function will encrypt the data based off of the old key.
 * Regardless, the write function will force everything to be updated prior to actually writing to avoid write
 * complications.
 */
public void updateCryptoProperties() throws VaSolSimException {
    try {
        if (decryptedValidationHash.length > 0)
            encryptedValidationHash = encryptionCipher.doFinal(decryptedValidationHash);

        if (getDecryptedNotificationEmail() != null)
            encryptedNotificationEmail = encryptionCipher.doFinal(getDecryptedNotificationEmail().getBytes());

        if (getDecryptedNotificationEmailPassword().length > 0)
            encryptedNotificationEmailPassword = encryptionCipher
                    .doFinal(getDecryptedNotificationEmailPassword());

        if (getDecryptedStatisticsEmail() != null)
            encryptedStatisticsEmail = encryptionCipher.doFinal(getDecryptedStatisticsEmail().getBytes());

        if (getDecryptedStatisticsEmailPassword().length > 0)
            encryptedStatisticsEmailPassword = encryptionCipher.doFinal(getDecryptedStatisticsEmailPassword());
    } catch (IllegalBlockSizeException e) {
        throw new VaSolSimException(ERROR_MESSAGE_GENERIC_CRYPTO + "\n\nILLEGAL BLOCK SIZE\n" + e.toString()
                + "\n" + e.getCause() + "\n" + ExceptionUtils.getStackTrace(e), e);
    } catch (BadPaddingException e) {
        throw new VaSolSimException(ERROR_MESSAGE_GENERIC_CRYPTO + "\n\nBAD PADDING\n" + e.toString() + "\n"
                + e.getCause() + "\n" + ExceptionUtils.getStackTrace(e), e);
    }

}