/** * 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 ClientApiKey(String id, String secret) { if (!Strings.hasText(id)) { throw new IllegalArgumentException("API key id cannot be null or empty."); } if (!Strings.hasText(secret)) { throw new IllegalArgumentException("API key secret cannot be null or empty."); } this.id = id; this.secret = secret; }
private static void append(StringBuilder sb, String value) { if (Strings.hasText(value)) { sb.append(value); } }
protected boolean hasContentType(String requestContentType, String requiredContentType) { if (!Strings.hasText(requiredContentType) || !Strings.hasText(requestContentType)) { return false; } StringTokenizer tokenizer = new StringTokenizer(requestContentType, ";"); while (tokenizer.hasMoreTokens()) { if (requiredContentType.equalsIgnoreCase(tokenizer.nextToken())) { return true; } } return false; }
/** * 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() : ""); }
private static String getSpringBootString() { String springBootStarter = getFullEntryStringUsingManifest(RAPID_PROTOTYPING_SPRING_BOOT_CLASS, RAPID_PROTOTYPING_SPRING_BOOT_ID); if (Strings.hasText(springBootStarter)) { return springBootStarter; } return ""; }
private boolean isOktaEnabled() { boolean oktaEnabled = false; String oktaEnabledString = config.get("okta.enabled"); if (Strings.hasText(oktaEnabledString)) { oktaEnabled = Boolean.valueOf(oktaEnabledString); } return oktaEnabled; } }
private static String getIntegrationString() { String integrationString; integrationString = getFullEntryStringUsingPomProperties(INTEGRATION_SHIRO_CLASS, INTEGRATION_SHIRO_ID); if(Strings.hasText(integrationString)) { return integrationString; } integrationString = getFullEntryStringUsingPomProperties(INTEGRATION_SPRING_SECURITY_CLASS, INTEGRATION_SPRING_SECURITY_ID); if(Strings.hasText(integrationString)) { return integrationString; } return ""; }
public CreateProviderRequest build() { final String providerId = getConcreteProviderId(); Assert.state(Strings.hasText(providerId), "The providerId property is missing."); Assert.state(Strings.hasText(encodedX509SigningCert), "The encodedX509SigningCert property is missing."); Assert.state(Strings.hasText(requestSignatureAlgorithm), "The requestSignatureAlgorithm property is missing."); Assert.state(Strings.hasText(ssoLoginUrl), "The ssoLoginUrl property is missing."); Assert.state(Strings.hasText(ssoLogoutUrl), "The ssoLogoutUrl property is missing."); Map<String, Object> properties = new LinkedHashMap<String, Object>(); properties.put("providerId", providerId); return doBuild(Collections.unmodifiableMap(properties)); } }
public CreateProviderRequest build() { Assert.state(Strings.hasText(this.clientId), "clientId is a required property. It must be provided before building."); Assert.state(Strings.hasText(this.clientSecret), "clientSecret is a required property. It must be provided before building."); final String providerId = getConcreteProviderId(); Assert.state(Strings.hasText(providerId), "The providerId property is missing."); Map<String, Object> properties = new LinkedHashMap<>(); properties.put("providerId", providerId); return doBuild(Collections.unmodifiableMap(properties)); }
/** * @since 1.2.0 */ @Override public List<String> getAllowedCorsHaders() { String allowedHeaders = get(STORMPATH_WEB_CORS_ALLOWED_HEADERS); if(Strings.hasText(allowedHeaders)) { return Arrays.asList(Strings.split(allowedHeaders)); } return Collections.emptyList(); }
/** * @since 1.2.0 */ @Override public List<String> getAllowedCorsMethods() { String allowedMethods = get(STORMPATH_WEB_CORS_ALLOWED_METHODS); if(Strings.hasText(allowedMethods)) { return Arrays.asList(Strings.split(allowedMethods)); } return Collections.emptyList(); }
/** * @since 1.2.0 */ @Override public List<String> getAllowedCorsOrigins() { String allowedOrigins = get(STORMPATH_WEB_CORS_ALLOWED_ORIGINS); if(Strings.hasText(allowedOrigins)) { return Arrays.asList(Strings.split(allowedOrigins)); } return Collections.emptyList(); }
@Override public ProviderAccountRequest build() { final String providerId = getConcreteProviderId(); Assert.state(Strings.hasText(providerId), "The providerId property is missing."); Map<String, Object> properties = new LinkedHashMap<>(); properties.put("providerId", providerId); return doBuild(Collections.unmodifiableMap(properties)); }
protected void applyBaseUrl(ClientBuilder builder) { String baseUrl = config.get(STORMPATH_BASEURL); if (Strings.hasText(baseUrl)) { builder.setBaseUrl(baseUrl); } }
@Override protected StaticResourceFilter createInstance(ServletContext servletContext, Config config) throws Exception { StaticResourceFilter filter = new StaticResourceFilter(); String defaultFilterName = config.get("stormpath.web.assets.defaultServletName"); if (Strings.hasText(defaultFilterName)) { filter.setDefaultServletName(defaultFilterName); } filter.init(servletContext); return filter; } }
@Override public Object run() { String value = getHeaderValue(); if (Strings.hasText(value)) { String headerName = getHeaderName(); getRequestContext().addZuulRequestHeader(headerName, value); } return null; }
protected AuthenticationRequest createAuthenticationRequest(Authentication authentication) { String username = (String) authentication.getPrincipal(); String password = (String) authentication.getCredentials(); if (!Strings.hasText(username)) { throw new AuthenticationServiceException("Login and password required"); } return UsernamePasswordRequests.builder().setUsernameOrEmail(username).setPassword(password).build(); }
@Override public byte[] resolveSigningKeyBytes(JwsHeader header, Claims claims) { String keyId = header.getKeyId(); if (Strings.hasText(keyId) && !clientApiKey.getId().equals(keyId)) { String url = dataStore.getBaseUrl() + "/apiKeys/" + keyId; ApiKey apiKey = dataStore.getResource(url, ApiKey.class); return Strings.getBytesUtf8(apiKey.getSecret()); } return Strings.getBytesUtf8(clientApiKey.getSecret()); } }).parseClaimsJws(token);
@Override public byte[] resolveSigningKeyBytes(JwsHeader header, Claims claims) { String keyId = header.getKeyId(); if (Strings.hasText(keyId) && !clientApiKey.getId().equals(keyId)) { String url = dataStore.getBaseUrl() + "/apiKeys/" + keyId; ApiKey apiKey = dataStore.getResource(url, ApiKey.class); return Strings.getBytesUtf8(apiKey.getSecret()); } return Strings.getBytesUtf8(clientApiKey.getSecret()); } }).parseClaimsJws(token);