Example usage for javax.crypto IllegalBlockSizeException toString

List of usage examples for javax.crypto IllegalBlockSizeException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

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,//  w ww.j a v  a 2s . c o  m
 * 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);
    }

}