/** * Gets pac4j context. * * @param request the request * @param sessionStore the session store * @return the pac4j context */ public static J2EContext getPac4jJ2EContext(final HttpServletRequest request, final SessionStore sessionStore) { return getPac4jJ2EContext(request, HttpRequestUtils.getHttpServletResponseFromRequestAttributes(), sessionStore); }
/** * Sha base 64 string. * * @param salt the salt * @param data the data * @param separator the separator * @return the string */ public static String shaBase64(final String salt, final String data, final String separator) { val result = rawDigest(MessageDigestAlgorithms.SHA_1, salt, separator == null ? data : data + separator); return EncodingUtils.encodeBase64(result); }
/** * Gets pac4j context. * * @param sessionStore the session store * @return the pac4j context */ public static J2EContext getPac4jJ2EContext(final SessionStore sessionStore) { return getPac4jJ2EContext(HttpRequestUtils.getHttpServletRequestFromRequestAttributes(), HttpRequestUtils.getHttpServletResponseFromRequestAttributes(), sessionStore); }
/** * Creates the pattern. Matching is by default * case insensitive. * * @param pattern the pattern, may not be null. * @return the pattern or or {@link RegexUtils#MATCH_NOTHING_PATTERN} * if pattern is null or invalid. */ public static Pattern createPattern(final String pattern) { return createPattern(pattern, Pattern.CASE_INSENSITIVE); }
/** * Gets http servlet request user agent from request context. * * @param request the request * @return the http servlet request user agent from request context */ public static String getHttpServletRequestUserAgentFromRequestContext(final HttpServletRequest request) { return HttpRequestUtils.getHttpServletRequestUserAgent(request); }
/** * Base64-decode the given string as byte[]. * * @param data the base64 string * @return the encoded array */ public static byte[] decodeUrlSafeBase64(final String data) { return decodeBase64(data); }
@Override protected String convertBytesToString(final byte[] random) { return EncodingUtils.hexEncode(random); } }
/** * Sha base 32 string. * * @param salt the salt * @param data the data * @param separator a string separator, if any * @param chunked the chunked * @return the string */ public static String shaBase32(final String salt, final String data, final String separator, final boolean chunked) { val result = rawDigest(MessageDigestAlgorithms.SHA_1, salt, separator == null ? data : data + separator); return EncodingUtils.encodeBase32(result, chunked); }
/** * Converts byte[] to String by Base64 encoding. * * @param random raw bytes * @return a converted String */ @Override protected String convertBytesToString(final byte[] random) { return EncodingUtils.encodeUrlSafeBase64(random); }
/** * Sign jws. * * @param key the key * @param value the value * @return the byte [] */ public static byte[] signJwsHMACSha512(final Key key, final byte[] value) { return signJws(key, value, AlgorithmIdentifiers.HMAC_SHA512); }
/** * Computes hex encoded SHA digest. * * @param data data to be hashed * @return sha hash */ public static String sha(final String data) { return digest(MessageDigestAlgorithms.SHA_1, data); }
/** * Encrypt value as jwt rsa oeap 256 aes 256 sha 512 string. * * @param key the key * @param value the value * @return the string */ public static String encryptValueAsJwtRsaOeap256Aes256Sha512(final Key key, final Serializable value) { return encryptValueAsJwt(key, value, KeyManagementAlgorithmIdentifiers.RSA_OAEP_256, CipherExecutor.DEFAULT_CONTENT_ENCRYPTION_ALGORITHM); }
/** * Sha base 64 string. * * @param salt the salt * @param data the data * @return the string */ public static String shaBase64(final String salt, final String data) { return shaBase64(salt, data, null); }
/** * Print ascii art. * * @param out the out * @param asciiArt the ascii art */ public static void printAsciiArt(final PrintStream out, final String asciiArt) { printAsciiArt(out, asciiArt, null); }
/** * Computes SHA digest. * * @param data data to be hashed * @return sha hash */ public static byte[] sha(final byte[] data) { return rawDigest(MessageDigestAlgorithms.SHA_1, data); }
/** * Sha base 64 string. * * @param salt the salt * @param data the data * @param separator a string separator, if any * @param chunked the chunked * @return the string */ public static String shaBase64(final String salt, final String data, final String separator, final boolean chunked) { val result = rawDigest(MessageDigestAlgorithms.SHA_1, salt, separator == null ? data : data + separator); return EncodingUtils.encodeBase64(result, chunked); }
/** * Sign jws. * * @param key the key * @param value the value * @return the byte [] */ public static byte[] signJwsRSASha512(final Key key, final byte[] value) { return signJws(key, value, AlgorithmIdentifiers.RSA_USING_SHA512); }