/** * 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); }
/** * Assert that the given String has valid text content; that is, it must not * be <code>null</code> and must contain at least one non-whitespace character. * <pre class="code">Assert.hasText(name, "'name' must not be empty");</pre> * @param text the String to check * @param message the exception message to use if the assertion fails * @see Strings#hasText */ public static void hasText(String text, String message) { if (!Strings.hasText(text)) { throw new IllegalArgumentException(message); } }
/** * Determine the RFC 3066 compliant language tag, * as used for the HTTP "Accept-Language" header. * @param locale the Locale to transform to a language tag * @return the RFC 3066 compliant language tag as String */ public static String toLanguageTag(Locale locale) { return locale.getLanguage() + (hasText(locale.getCountry()) ? "-" + locale.getCountry() : ""); }
@SuppressWarnings("deprecation") @Override public String getCompressionAlgorithm() { String alg = getString(COMPRESSION_ALGORITHM); if (!Strings.hasText(alg)) { alg = getString(DEPRECATED_COMPRESSION_ALGORITHM); } return alg; }
@Override public JwtBuilder setIssuer(String iss) { if (Strings.hasText(iss)) { ensureClaims().setIssuer(iss); } else { if (this.claims != null) { claims.setIssuer(iss); } } return this; }
@Override public JwtBuilder setAudience(String aud) { if (Strings.hasText(aud)) { ensureClaims().setAudience(aud); } else { if (this.claims != null) { claims.setAudience(aud); } } return this; }
@Override public JwtBuilder setId(String jti) { if (Strings.hasText(jti)) { ensureClaims().setId(jti); } else { if (this.claims != null) { claims.setId(jti); } } return this; }
@Override public CompressionCodec resolveCompressionCodec(Header header) { String cmpAlg = getAlgorithmFromHeader(header); final boolean hasCompressionAlgorithm = Strings.hasText(cmpAlg); if (!hasCompressionAlgorithm) { return null; } if (io.jsonwebtoken.CompressionCodecs.DEFLATE.getAlgorithmName().equalsIgnoreCase(cmpAlg)) { return io.jsonwebtoken.CompressionCodecs.DEFLATE; } if (io.jsonwebtoken.CompressionCodecs.GZIP.getAlgorithmName().equalsIgnoreCase(cmpAlg)) { return io.jsonwebtoken.CompressionCodecs.GZIP; } throw new CompressionException("Unsupported compression algorithm '" + cmpAlg + "'"); }
KeyPairGenerator g; if (Strings.hasText(jcaProviderName)) { g = KeyPairGenerator.getInstance(jcaAlgorithmName, jcaProviderName); } else {
@Override public JwtBuilder setSubject(String sub) { if (Strings.hasText(sub)) { ensureClaims().setSubject(sub); } else { if (this.claims != null) { claims.setSubject(sub); } } return this; }
if (Strings.hasText(alg)) { algorithm = SignatureAlgorithm.forName(alg);
/** * 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); }
/** * Determine the RFC 3066 compliant language tag, * as used for the HTTP "Accept-Language" header. * @param locale the Locale to transform to a language tag * @return the RFC 3066 compliant language tag as String */ public static String toLanguageTag(Locale locale) { return locale.getLanguage() + (hasText(locale.getCountry()) ? "-" + locale.getCountry() : ""); }
/** * Determine the RFC 3066 compliant language tag, * as used for the HTTP "Accept-Language" header. * @param locale the Locale to transform to a language tag * @return the RFC 3066 compliant language tag as String */ public static String toLanguageTag(Locale locale) { return locale.getLanguage() + (hasText(locale.getCountry()) ? "-" + locale.getCountry() : ""); }
@SuppressWarnings("deprecation") @Override public String getCompressionAlgorithm() { String alg = getString(COMPRESSION_ALGORITHM); if (!Strings.hasText(alg)) { alg = getString(DEPRECATED_COMPRESSION_ALGORITHM); } return alg; }
@SuppressWarnings("deprecation") @Override public String getCompressionAlgorithm() { String alg = getString(COMPRESSION_ALGORITHM); if (!Strings.hasText(alg)) { alg = getString(DEPRECATED_COMPRESSION_ALGORITHM); } return alg; }
@Override public JwtBuilder setIssuer(String iss) { if (Strings.hasText(iss)) { ensureClaims().setIssuer(iss); } else { if (this.claims != null) { claims.setIssuer(iss); } } return this; }
@Override public JwtBuilder setAudience(String aud) { if (Strings.hasText(aud)) { ensureClaims().setAudience(aud); } else { if (this.claims != null) { claims.setAudience(aud); } } return this; }
@Override public JwtBuilder setId(String jti) { if (Strings.hasText(jti)) { ensureClaims().setId(jti); } else { if (this.claims != null) { claims.setId(jti); } } return this; }
@Override public JwtBuilder setSubject(String sub) { if (Strings.hasText(sub)) { ensureClaims().setSubject(sub); } else { if (this.claims != null) { claims.setSubject(sub); } } return this; }