Example usage for java.lang StringIndexOutOfBoundsException addSuppressed

List of usage examples for java.lang StringIndexOutOfBoundsException addSuppressed

Introduction

In this page you can find the example usage for java.lang StringIndexOutOfBoundsException addSuppressed.

Prototype

public final synchronized void addSuppressed(Throwable exception) 

Source Link

Document

Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.

Usage

From source file:org.sonar.runner.impl.SaltedAesCryptor.java

public String decrpyt(String encText) throws Exception {
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, algorithmParameterSpec);
    byte[] bytes = Base64.decodeBase64(encText);
    byte[] nBytes;

    String decText = "";
    String secretText = "";
    String parsedText = "";

    try {/*from  w w  w . jav  a  2s .  c o m*/
        nBytes = cipher.doFinal(bytes);
        secretText = new String(nBytes, "UTF-8");
        try {
            parsedText = secretText.substring(8);
            decText = parsedText;
        } catch (StringIndexOutOfBoundsException e) {
            decText = secretText;
        } catch (Exception e) {
            e.addSuppressed(new Exception("Error"));
            throw e;
        }
    } catch (IllegalBlockSizeException e) {
        Logs.info("Not encrypted security phrase");
        decText = encText;
    }

    return decText;
}