Search in sources :

Example 16 with RuntimeException

use of java.lang.RuntimeException in project jdk8u_jdk by JetBrains.

the class CipherInputStreamExceptions method gcm_suppressUnreadCorrupt.

/*
     * Verify doFinal() exception is suppressed when input stream is not
     * read before it is closed.
     * This test:
     *   1) Encrypt 100 bytes with AES/GCM/PKCS5Padding
     *   2) Changes the last byte to invalidate the authetication tag.
     *   3) Opens a CipherInputStream and the closes it. Never reads from it.
     *
     * There should be no exception thrown.
     */
static void gcm_suppressUnreadCorrupt() throws Exception {
    Cipher c;
    byte[] read = new byte[200];
    System.out.println("Running supressUnreadCorrupt test");
    // Encrypt 100 bytes with AES/GCM/PKCS5Padding
    byte[] ct = encryptedText("GCM", 100);
    // Corrupt the encrypted message
    ct = corruptGCM(ct);
    // Create stream for decryption
    CipherInputStream in = getStream("GCM", ct);
    try {
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail: " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
Also used : RuntimeException(java.lang.RuntimeException) CipherInputStream(javax.crypto.CipherInputStream) Cipher(javax.crypto.Cipher) IOException(java.io.IOException)

Example 17 with RuntimeException

use of java.lang.RuntimeException in project jdk8u_jdk by JetBrains.

the class CipherInputStreamExceptions method cbc_shortRead400.

/* Check that close() does not throw an exception when the whole message is
     * inside the internal buffer (ibuffer) in CipherInputStream and we read
     * one byte and close the stream.
     * This test:
     *   1) Encrypts a 400 byte message with AES/CBC/PKCS5Padding
     *   2) Read one byte from the stream
     *   3) Close and expect no exception
     */
static void cbc_shortRead400() throws Exception {
    System.out.println("Running cbc_shortRead400");
    // Encrypt 400 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 400);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);
    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
Also used : RuntimeException(java.lang.RuntimeException) CipherInputStream(javax.crypto.CipherInputStream) IOException(java.io.IOException)

Example 18 with RuntimeException

use of java.lang.RuntimeException in project jdk8u_jdk by JetBrains.

the class CipherInputStreamExceptions method cbc_shortRead600.

/* Check that close() does not throw an exception when the  inside the
     * internal buffer (ibuffer) in CipherInputStream does not contain the
     * whole message.
     * This test:
     *   1) Encrypts a 600 byte message with AES/CBC/PKCS5Padding
     *   2) Read one byte from the stream
     *   3) Close and expect no exception
     */
static void cbc_shortRead600() throws Exception {
    System.out.println("Running cbc_shortRead600");
    // Encrypt 600 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 600);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);
    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
Also used : RuntimeException(java.lang.RuntimeException) CipherInputStream(javax.crypto.CipherInputStream) IOException(java.io.IOException)

Example 19 with RuntimeException

use of java.lang.RuntimeException in project XPrivacy by M66B.

the class Util method bug.

public static void bug(XHook hook, Throwable ex) {
    if (ex instanceof InvocationTargetException) {
        InvocationTargetException exex = (InvocationTargetException) ex;
        if (exex.getTargetException() != null)
            ex = exex.getTargetException();
    }
    int priority;
    if (ex instanceof ActivityShare.AbortException)
        priority = Log.WARN;
    else if (ex instanceof ActivityShare.ServerException)
        priority = Log.WARN;
    else if (ex instanceof ConnectTimeoutException)
        priority = Log.WARN;
    else if (ex instanceof FileNotFoundException)
        priority = Log.WARN;
    else if (ex instanceof HttpHostConnectException)
        priority = Log.WARN;
    else if (ex instanceof NameNotFoundException)
        priority = Log.WARN;
    else if (ex instanceof NoClassDefFoundError)
        priority = Log.WARN;
    else if (ex instanceof OutOfMemoryError)
        priority = Log.WARN;
    else if (ex instanceof RuntimeException)
        priority = Log.WARN;
    else if (ex instanceof SecurityException)
        priority = Log.WARN;
    else if (ex instanceof SocketTimeoutException)
        priority = Log.WARN;
    else if (ex instanceof SSLPeerUnverifiedException)
        priority = Log.WARN;
    else if (ex instanceof StackOverflowError)
        priority = Log.WARN;
    else if (ex instanceof TransactionTooLargeException)
        priority = Log.WARN;
    else if (ex instanceof UnknownHostException)
        priority = Log.WARN;
    else if (ex instanceof UnsatisfiedLinkError)
        priority = Log.WARN;
    else
        priority = Log.ERROR;
    boolean xprivacy = false;
    for (StackTraceElement frame : ex.getStackTrace()) if (frame.getClassName() != null && frame.getClassName().startsWith("biz.bokhorst.xprivacy")) {
        xprivacy = true;
        break;
    }
    if (!xprivacy)
        priority = Log.WARN;
    log(hook, priority, ex.toString() + " uid=" + Process.myUid() + "\n" + Log.getStackTraceString(ex));
}
Also used : UnknownHostException(java.net.UnknownHostException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) SSLPeerUnverifiedException(javax.net.ssl.SSLPeerUnverifiedException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SuppressLint(android.annotation.SuppressLint) RuntimeException(java.lang.RuntimeException) SocketTimeoutException(java.net.SocketTimeoutException) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) TransactionTooLargeException(android.os.TransactionTooLargeException) StackOverflowError(java.lang.StackOverflowError) ConnectTimeoutException(org.apache.http.conn.ConnectTimeoutException)

Example 20 with RuntimeException

use of java.lang.RuntimeException in project selenium_java by sergueik.

the class App method testVerifyText.

@Test
public static void testVerifyText() {
    WebElement element = null;
    try {
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Hotels")));
    } catch (RuntimeException timeoutException) {
    }
    element = driver.findElement(By.linkText("Hotels"));
    assertEquals("Hotels", element.getText());
    JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
    javascriptExecutor.executeScript("arguments[0].style.border='3px solid yellow'", element);
    try {
        Thread.sleep(highlight_interval);
    } catch (InterruptedException e) {
    }
    javascriptExecutor.executeScript("arguments[0].style.border=''", element);
    element.click();
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) RuntimeException(java.lang.RuntimeException) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Aggregations

RuntimeException (java.lang.RuntimeException)23 IOException (java.io.IOException)11 CipherInputStream (javax.crypto.CipherInputStream)9 WebElement (org.openqa.selenium.WebElement)7 Hashtable (java.util.Hashtable)4 Cipher (javax.crypto.Cipher)4 File (java.io.File)3 Exception (java.lang.Exception)3 Throwable (java.lang.Throwable)3 AEADBadTagException (javax.crypto.AEADBadTagException)3 Test (org.junit.Test)3 FileNotFoundException (java.io.FileNotFoundException)2 Boolean (java.lang.Boolean)2 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)2 SearchContext (org.openqa.selenium.SearchContext)2 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)2 SuppressLint (android.annotation.SuppressLint)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 TransactionTooLargeException (android.os.TransactionTooLargeException)1 BufferedReader (java.io.BufferedReader)1