/** * Throws out a {@link UnexpectedException} with message specified. * * @param msg * the message format pattern. * @param args * the message format arguments */ public static UnexpectedException unexpected(String msg, Object... args) { throw new UnexpectedException(msg, args); }
public String encrypt(String message) { try { return Crypto.encryptAES(message, secret); } catch (UnexpectedException e) { Throwable cause = e.getCause(); if (cause instanceof InvalidKeyException) { LOGGER.error("Cannot encrypt/decrypt! Please download Java Crypto Extension pack from Oracle: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html"); } throw e; } }
/** * Throws out a {@link UnexpectedException} with cause specified. * * @param cause * the cause of the unexpected exception. */ public static UnexpectedException unexpected(Throwable cause) { throw new UnexpectedException(cause); }
public String decrypt(String message) { try { return Crypto.decryptAES(message, secret); } catch (UnexpectedException e) { Throwable cause = e.getCause(); if (cause instanceof InvalidKeyException) { LOGGER.error("Cannot encrypt/decrypt! Please download Java Crypto Extension pack from Oracle: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html"); } throw e; } }
/** * Throws out a {@link UnexpectedException} with message specified. * * @param msg * the message format pattern. * @param args * the message format arguments */ public static UnexpectedException unexpected(String msg, Object... args) { throw new UnexpectedException(msg, args); }
public String decrypt(String message) { try { return Crypto.decryptAES(message, secret); } catch (UnexpectedException e) { Throwable cause = e.getCause(); if (cause instanceof InvalidKeyException) { LOGGER.error("Cannot encrypt/decrypt! Please download Java Crypto Extension pack from Oracle: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html"); } throw e; } }
public static void unexpectedIf(boolean tester) { if (tester) { throw new UnexpectedException(); } }
public String encrypt(String message) { try { return Crypto.encryptAES(message, secret); } catch (UnexpectedException e) { Throwable cause = e.getCause(); if (cause instanceof InvalidKeyException) { LOGGER.error("Cannot encrypt/decrypt! Please download Java Crypto Extension pack from Oracle: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html"); } throw e; } }
public static void unexpectedIf(boolean tester) { if (tester) { throw new UnexpectedException(); } }
cr.accept(theVisitor, 0); } catch (UnexpectedException e) { Throwable t = e.getCause(); if (t instanceof ClassNotFoundException) {
/** * Throws out a {@link UnexpectedException} with message and cause specified. * * @param cause * the cause of the unexpected exception. * @param msg * the error message format pattern. * @param args * the error message format arguments. */ public static UnexpectedException unexpected(Throwable cause, String msg, Object... args) { throw new UnexpectedException(cause, msg, args); }
/** * Throws out a {@link UnexpectedException} with cause specified. * * @param cause * the cause of the unexpected exception. */ public static UnexpectedException unexpected(Throwable cause) { throw new UnexpectedException(cause); }
/** * Throws out a {@link UnexpectedException} with message and cause specified. * * @param cause * the cause of the unexpected exception. * @param msg * the error message format pattern. * @param args * the error message format arguments. */ public static UnexpectedException unexpected(Throwable cause, String msg, Object... args) { throw new UnexpectedException(cause, msg, args); }
private void checkForEmpty(Interaction interaction) { if (null != status) { return; } if (null != text) { return; } if (!json.isEmpty()) { return; } if (!html.isEmpty()) { return; } if (!headers.isEmpty()) { return; } throw new UnexpectedException("Empty response spec found in interaction[%s]", interaction); }
/** * Build an hexadecimal MD5 hash for a String * * @param value The String to hash * @return An hexadecimal Hash */ public static String hexMD5(String value) { try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.reset(); messageDigest.update(value.getBytes("utf-8")); byte[] digest = messageDigest.digest(); return byteToHexString(digest); } catch (Exception ex) { throw new UnexpectedException(ex); } }
/** * Build an hexadecimal SHA1 hash for a String * * @param value The String to hash * @return An hexadecimal Hash */ public static String hexSHA1(String value) { try { MessageDigest md; md = MessageDigest.getInstance("SHA-1"); md.update(value.getBytes("utf-8")); byte[] digest = md.digest(); return byteToHexString(digest); } catch (Exception ex) { throw new UnexpectedException(ex); } }
/** * Build an hexadecimal SHA1 hash for a String * * @param value The String to hash * @return An hexadecimal Hash */ public static String hexSHA1(String value) { try { MessageDigest md; md = MessageDigest.getInstance("SHA-1"); md.update(value.getBytes("utf-8")); byte[] digest = md.digest(); return byteToHexString(digest); } catch (Exception ex) { throw new UnexpectedException(ex); } }
/** * Build an hexadecimal MD5 hash for a String * * @param value The String to hash * @return An hexadecimal Hash */ public static String hexMD5(String value) { try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.reset(); messageDigest.update(value.getBytes("utf-8")); byte[] digest = messageDigest.digest(); return byteToHexString(digest); } catch (Exception ex) { throw new UnexpectedException(ex); } }
PostConstructProcessor postConstructProcessor(Annotation annotation) { Class<? extends Annotation> annoClass = annotation.annotationType(); PostConstructProcessor processor = postConstructProcessors.get(annoClass); if (null == processor) { if (!annoClass.isAnnotationPresent(PostConstructProcess.class)) { throw new UnexpectedException("Cannot find PostConstructProcessor on %s", annoClass); } PostConstructProcess pcp = annoClass.getAnnotation(PostConstructProcess.class); Class<? extends PostConstructProcessor> cls = pcp.value(); processor = get(cls); PostConstructProcessor p2 = postConstructProcessors.putIfAbsent(annoClass, processor); if (null != p2) { processor = p2; } } return processor; }
PostConstructProcessor postConstructProcessor(Annotation annotation) { Class<? extends Annotation> annoClass = annotation.annotationType(); PostConstructProcessor processor = postConstructProcessors.get(annoClass); if (null == processor) { if (!annoClass.isAnnotationPresent(PostConstructProcess.class)) { throw new UnexpectedException("Cannot find PostConstructProcessor on %s", annoClass); } PostConstructProcess pcp = annoClass.getAnnotation(PostConstructProcess.class); Class<? extends PostConstructProcessor> cls = pcp.value(); processor = get(cls); PostConstructProcessor p2 = postConstructProcessors.putIfAbsent(annoClass, processor); if (null != p2) { processor = p2; } } return processor; }