protected void logCacheSettings(Logger log) { Util.logSetting(log, "caching", accountCache != null); Util.logSetting(log, "cacheTtl (mins)", cacheTtl); Util.logSetting(log, "cacheMax (accounts)", cacheMax); }
public static String getTypeId(String subjectTemplate, String bodyTemplateName) { return CryptoUtil.getHashSHA1(subjectTemplate + bodyTemplateName); } }
public static boolean doesClassExist(Optional<String> packageName, String className) { String fullClassName = buildClassName(packageName, className); return doesClassExist(fullClassName); }
public static <T> Class<T> getClass(Optional<String> packageName, String className) { String fullClassName = buildClassName(packageName, className); return getClass(fullClassName); }
public static <T extends Annotation> T getAnnotation(Class<?> objectClass, Class<T> annotationClass) { if (objectClass == null || Object.class == objectClass) { return null; } T annotation = objectClass.getAnnotation(annotationClass); if (annotation != null) { return annotation; } return getAnnotation(objectClass.getSuperclass(), annotationClass); }
public static String getHmacSHA256(String message, String secretKey) { return hmacDigest(message, secretKey, HMAC_SHA256); }
public CSRFHandler() { this(CryptoUtil.generateSecretKey()); }
/** * Calculates the SHA256 hash of the string. * * @param text * @return sha256 hash of the string */ public static String getHashSHA256(String text) { byte[] bytes = text.getBytes(StandardCharsets.ISO_8859_1); return getHashSHA256(bytes); }
/** * Calculates the MD5 hash of the string. * * @param text * @return md5 hash of the string */ public static String getHashMD5(String text) { byte[] bytes = text.getBytes(StandardCharsets.ISO_8859_1); return getHashMD5(bytes); }
public static URL getResource(String name) { List<URL> resources = getResources(name); if (resources.isEmpty()) { return null; } return resources.get(0); }
protected void logCacheSettings(Logger log) { Util.logSetting(log, "caching", accountCache != null); Util.logSetting(log, "cacheTtl (mins)", cacheTtl); Util.logSetting(log, "cacheMax (accounts)", cacheMax); }
protected void checkRequireAuthenticated(Account account, Method method) { RequireAuthenticated annotation = ClassUtil.getAnnotation(method, RequireAuthenticated.class); if (annotation != null) { account.checkAuthenticated(); } }
public static String getTypeId(String subjectTemplate, String bodyTemplateName) { return CryptoUtil.getHashSHA1(subjectTemplate + bodyTemplateName); } }
public static String getHmacMD5(String message, String secretKey) { return hmacDigest(message, secretKey, HMAC_MD5); }
protected void checkRequireAdministrator(Account account, Method method) { RequireAdministrator annotation = ClassUtil.getAnnotation(method, RequireAdministrator.class); if (annotation != null) { account.checkAdministrator(); } }
/** * Calculates the SHA1 hash of the string. * * @param text * @return sha1 hash of the string */ public static String getHashSHA1(String text) { byte[] bytes = text.getBytes(StandardCharsets.ISO_8859_1); return getHashSHA1(bytes); }
public static String getHmacSHA1(String message, String secretKey) { return hmacDigest(message, secretKey, HMAC_SHA1); }
protected void checkRequireGuest(Account account, Method method) { RequireGuest annotation = ClassUtil.getAnnotation(method, RequireGuest.class); if (annotation != null) { account.checkGuest(); } }
protected void checkRequireAuthenticated(Account account, Method method) { RequireAuthenticated annotation = ClassUtil.getAnnotation(method, RequireAuthenticated.class); if (annotation != null) { account.checkAuthenticated(); } }
protected void checkRequireAdministrator(Account account, Method method) { RequireAdministrator annotation = ClassUtil.getAnnotation(method, RequireAdministrator.class); if (annotation != null) { account.checkAdministrator(); } }