@Override public JwtParser setSigningKeyResolver(SigningKeyResolver signingKeyResolver) { Assert.notNull(signingKeyResolver, "SigningKeyResolver cannot be null."); this.signingKeyResolver = signingKeyResolver; return this; }
/** * Returns a new {@link JwtParser} instance that can be configured and then used to parse JWT strings. * * @return a new {@link JwtParser} instance that can be configured and then used to parse JWT strings. */ public static JwtParser parser() { return Classes.newInstance("io.jsonwebtoken.impl.DefaultJwtParser"); }
/** * Check whether the given String has actual text. * More specifically, returns <code>true</code> if the string not <code>null</code>, * its length is greater than 0, and it contains at least one non-whitespace character. * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not <code>null</code>, its length is * greater than 0, and it does not contain whitespace only * @see #hasText(CharSequence) */ public static boolean hasText(String str) { return hasText((CharSequence) str); }
public static <T> T newInstance(String fqcn, Class[] ctorArgTypes, Object... args) { Class<T> clazz = forName(fqcn); Constructor<T> ctor = getConstructor(clazz, ctorArgTypes); return instantiate(ctor, args); }
public static CharSequence clean(CharSequence str) { str = trimWhitespace(str); if (!hasLength(str)) { return null; } return str; }
/** * Assert that a Map has entries; that is, it must not be <code>null</code> * and must have at least one entry. * <pre class="code">Assert.notEmpty(map);</pre> * @param map the map to check * @throws IllegalArgumentException if the map is <code>null</code> or has no entries */ public static void notEmpty(Map map) { notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry"); }
public static boolean isAvailable(String fullyQualifiedClassName) { try { forName(fullyQualifiedClassName); return true; } catch (UnknownClassException e) { return false; } }
/** * Capitalize a <code>String</code>, changing the first letter to * upper case as per {@link Character#toUpperCase(char)}. * No other letters are changed. * @param str the String to capitalize, may be <code>null</code> * @return the capitalized String, <code>null</code> if null */ public static String capitalize(String str) { return changeFirstCharacterCase(str, true); }
protected final ClassLoader getClassLoader() { try { return doGetClassLoader(); } catch (Throwable t) { //Unable to get ClassLoader } return null; }
/** * Assert that an array has no null elements. * Note: Does not complain if the array is empty! * <pre class="code">Assert.noNullElements(array);</pre> * @param array the array to check * @throws IllegalArgumentException if the object array contains a <code>null</code> element */ public static void noNullElements(Object[] array) { noNullElements(array, "[Assertion failed] - this array must not contain any null elements"); }
/** * Check whether the given String contains any whitespace characters. * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not empty and * contains at least 1 whitespace character * @see #containsWhitespace(CharSequence) */ public static boolean containsWhitespace(String str) { return containsWhitespace((CharSequence) str); }
/** * Unqualify a string qualified by a '.' dot character. For example, * "this.name.is.qualified", returns "qualified". * @param qualifiedName the qualified name */ public static String unqualify(String qualifiedName) { return unqualify(qualifiedName, '.'); }
/** * Convenience method to return a Collection as a CSV String. * E.g. useful for <code>toString()</code> implementations. * @param coll the Collection to display * @return the delimited String */ public static String collectionToCommaDelimitedString(Collection<?> coll) { return collectionToDelimitedString(coll, ","); }
/** * Adapt an enumeration to an iterator. * @param enumeration the enumeration * @return the iterator */ public static <E> Iterator<E> toIterator(Enumeration<E> enumeration) { return new EnumerationIterator<E>(enumeration); }
@Override public JwtParser setCompressionCodecResolver(CompressionCodecResolver compressionCodecResolver) { Assert.notNull(compressionCodecResolver, "compressionCodecResolver cannot be null."); this.compressionCodecResolver = compressionCodecResolver; return this; }
/** * Returns a new {@link JwsHeader} instance suitable for digitally signed JWTs (aka 'JWS's). * * @return a new {@link JwsHeader} instance suitable for digitally signed JWTs (aka 'JWS's). * @see JwtBuilder#setHeader(Header) */ public static JwsHeader jwsHeader() { return Classes.newInstance("io.jsonwebtoken.impl.DefaultJwsHeader"); }
@Override public JwtParser setSigningKey(byte[] key) { Assert.notEmpty(key, "signing key cannot be null or empty."); this.keyBytes = key; return this; }
/** * Uncapitalize a <code>String</code>, changing the first letter to * lower case as per {@link Character#toLowerCase(char)}. * No other letters are changed. * @param str the String to uncapitalize, may be <code>null</code> * @return the uncapitalized String, <code>null</code> if null */ public static String uncapitalize(String str) { return changeFirstCharacterCase(str, false); }
@Override public JwtBuilder serializeToJsonWith(Serializer<Map<String,?>> serializer) { Assert.notNull(serializer, "Serializer cannot be null."); this.serializer = serializer; return this; }
@Override public JwtBuilder compressWith(CompressionCodec compressionCodec) { Assert.notNull(compressionCodec, "compressionCodec cannot be null"); this.compressionCodec = compressionCodec; return this; }