java.lang.Exception Java Examples
The following examples show how to use
java.lang.Exception.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeakCrypto.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #2
Source File: WeakCrypto.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #3
Source File: CipherInputStreamExceptions.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #4
Source File: WeakCrypto.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #5
Source File: WeakCrypto.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #6
Source File: CipherInputStreamExceptions.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #7
Source File: ProviderVersionCheck.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String arg[]) throws Exception{ boolean failure = false; for (Provider p: Security.getProviders()) { System.out.print(p.getName() + " "); if (p.getVersion() != 1.8d) { System.out.println("failed. " + "Version received was " + p.getVersion()); failure = true; } else { System.out.println("passed."); } } if (failure) { throw new Exception("Provider(s) failed to have the expected " + "version value."); } }
Example #8
Source File: ProviderVersionCheck.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void main(String arg[]) throws Exception{ boolean failure = false; for (Provider p: Security.getProviders()) { System.out.print(p.getName() + " "); if (p.getVersion() != 1.8d) { System.out.println("failed. " + "Version received was " + p.getVersion()); failure = true; } else { System.out.println("passed."); } } if (failure) { throw new Exception("Provider(s) failed to have the expected " + "version value."); } }
Example #9
Source File: ProviderVersionCheck.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String arg[]) throws Exception{ boolean failure = false; for (Provider p: Security.getProviders()) { System.out.print(p.getName() + " "); if (p.getVersion() != 1.8d) { System.out.println("failed. " + "Version received was " + p.getVersion()); failure = true; } else { System.out.println("passed."); } } if (failure) { throw new Exception("Provider(s) failed to have the expected " + "version value."); } }
Example #10
Source File: CipherInputStreamExceptions.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #11
Source File: WeakCrypto.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #12
Source File: WeakCrypto.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #13
Source File: CipherInputStreamExceptions.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
static void gcm_oneReadByte() throws Exception { System.out.println("Running gcm_oneReadByte test"); // Encrypt 100 bytes with AES/GCM/PKCS5Padding byte[] ct = encryptedText("GCM", 100); // Create stream for decryption CipherInputStream in = getStream("GCM", ct); try { in.read(); System.out.println(" Pass."); } catch (Exception e) { System.out.println(" Fail: " + e.getMessage()); throw new RuntimeException(e.getCause()); } }
Example #14
Source File: CipherInputStreamExceptions.java From hottub with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #15
Source File: DisplayChangeVITest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { DisplayChangeVITest test = new DisplayChangeVITest(); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(test); Thread t = new Thread(test); t.run(); synchronized (lock) { while (!done) { try { lock.wait(50); } catch (InterruptedException ex) { ex.printStackTrace(); } } } System.err.println("Test Passed."); } else { System.err.println("Full screen not supported. Test passed."); } }
Example #16
Source File: CipherInputStreamExceptions.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #17
Source File: CipherInputStreamExceptions.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static void gcm_oneReadByte() throws Exception { System.out.println("Running gcm_oneReadByte test"); // Encrypt 100 bytes with AES/GCM/PKCS5Padding byte[] ct = encryptedText("GCM", 100); // Create stream for decryption CipherInputStream in = getStream("GCM", ct); try { in.read(); System.out.println(" Pass."); } catch (Exception e) { System.out.println(" Fail: " + e.getMessage()); throw new RuntimeException(e.getCause()); } }
Example #18
Source File: CipherInputStreamExceptions.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static void cbc_shortStream() throws Exception { Cipher c; AlgorithmParameters params; byte[] read = new byte[200]; System.out.println("Running cbc_shortStream"); // Encrypt 97 byte with AES/CBC/PKCS5Padding byte[] ct = encryptedText("CBC", 97); // Create stream with only 96 bytes of encrypted data CipherInputStream in = getStream("CBC", ct, 96); try { int size = in.read(read); in.close(); if (size != 80) { throw new RuntimeException("Fail: CipherInputStream.read() " + "returned " + size + ". Should have been 80"); } System.out.println(" Pass."); } catch (IOException e) { System.out.println(" Fail: " + e.getMessage()); throw new RuntimeException(e.getCause()); } }
Example #19
Source File: CipherInputStreamExceptions.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #20
Source File: CipherInputStreamExceptions.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #21
Source File: CipherInputStreamExceptions.java From hottub with GNU General Public License v2.0 | 6 votes |
static void cbc_shortStream() throws Exception { Cipher c; AlgorithmParameters params; byte[] read = new byte[200]; System.out.println("Running cbc_shortStream"); // Encrypt 97 byte with AES/CBC/PKCS5Padding byte[] ct = encryptedText("CBC", 97); // Create stream with only 96 bytes of encrypted data CipherInputStream in = getStream("CBC", ct, 96); try { int size = in.read(read); in.close(); if (size != 80) { throw new RuntimeException("Fail: CipherInputStream.read() " + "returned " + size + ". Should have been 80"); } System.out.println(" Pass."); } catch (IOException e) { System.out.println(" Fail: " + e.getMessage()); throw new RuntimeException(e.getCause()); } }
Example #22
Source File: CipherInputStreamExceptions.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
static void gcm_oneReadByteCorrupt() throws Exception { System.out.println("Running gcm_oneReadByteCorrupt 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.read(); System.out.println(" Fail. No exception thrown."); } catch (IOException e) { Throwable ec = e.getCause(); if (ec instanceof AEADBadTagException) { System.out.println(" Pass."); } else { System.out.println(" Fail: " + ec.getMessage()); throw new RuntimeException(ec); } } }
Example #23
Source File: NonNFastaSizeTest.java From picard with MIT License | 6 votes |
@Test public void noIntervals() throws IOException { final File input = new File(REFERENCE); final File outfile = File.createTempFile("nonNcount", ".txt"); outfile.deleteOnExit(); final String[] args = new String[] { "INPUT=" + input.getAbsolutePath(), "OUTPUT=" + outfile.getAbsolutePath() }; Assert.assertEquals(new NonNFastaSize().instanceMain(args), 0); final BufferedReader reader = IOUtil.openFileForBufferedReading(outfile); final String count = reader.readLine(); try { Assert.assertEquals(Long.parseLong(count), 1008); } catch (Exception e) { System.err.println("Failed to read in count because of error: " + e.getMessage()); } }
Example #24
Source File: CipherInputStreamExceptions.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #25
Source File: ProviderVersionCheck.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String arg[]) throws Exception{ boolean failure = false; for (Provider p: Security.getProviders()) { System.out.print(p.getName() + " "); if (p.getVersion() != 1.8d) { System.out.println("failed. " + "Version received was " + p.getVersion()); failure = true; } else { System.out.println("passed."); } } if (failure) { throw new Exception("Provider(s) failed to have the expected " + "version value."); } }
Example #26
Source File: WeakCrypto.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String conf = "[libdefaults]\n" + (args.length > 0 ? ("allow_weak_crypto = " + args[0]) : ""); Files.write(Paths.get("krb5.conf"), conf.getBytes()); System.setProperty("java.security.krb5.conf", "krb5.conf"); boolean expected = args.length != 0 && args[0].equals("true"); int[] etypes = EType.getBuiltInDefaults(); boolean found = false; for (int i=0, length = etypes.length; i<length; i++) { if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 || etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) { found = true; } } if (expected != found) { throw new Exception(); } }
Example #27
Source File: DisplayChangeVITest.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { DisplayChangeVITest test = new DisplayChangeVITest(); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(test); Thread t = new Thread(test); t.run(); synchronized (lock) { while (!done) { try { lock.wait(50); } catch (InterruptedException ex) { ex.printStackTrace(); } } } System.err.println("Test Passed."); } else { System.err.println("Full screen not supported. Test passed."); } }
Example #28
Source File: DisplayChangeVITest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { DisplayChangeVITest test = new DisplayChangeVITest(); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(test); Thread t = new Thread(test); t.run(); synchronized (lock) { while (!done) { try { lock.wait(50); } catch (InterruptedException ex) { ex.printStackTrace(); } } } System.err.println("Test Passed."); } else { System.err.println("Full screen not supported. Test passed."); } }
Example #29
Source File: ClusterAdminClient.java From carbon-commons with Apache License 2.0 | 5 votes |
public Group[] getGroups() throws java.lang.Exception { try { return stub.getGroups(); } catch (java.lang.Exception e) { String msg = bundle.getString("cannot.get.groups"); handleException(msg, e); } return new Group[0]; }
Example #30
Source File: AbstractFSharpCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void postProcessFile(File file, String fileType) { if (file == null) { return; } String fsharpPostProcessFile = System.getenv("FSHARP_POST_PROCESS_FILE"); if (StringUtils.isEmpty(fsharpPostProcessFile)) { return; // skip if FSHARP_POST_PROCESS_FILE env variable is not defined } // only process files with .fs extension if ("fs".equals(FilenameUtils.getExtension(file.toString()))) { String command = fsharpPostProcessFile + " " + file.toString(); try { Process p = Runtime.getRuntime().exec(command); int exitValue = p.waitFor(); if (exitValue != 0) { LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue); } else { LOGGER.info("Successfully executed: " + command); } } catch (Exception e) { LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); } } }