io.jsonwebtoken.lang.Assert#hasText ( )源码实例Demo

下面列出了io.jsonwebtoken.lang.Assert#hasText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: DefaultJwtBuilder.java
@Override
public JwtBuilder claim(String name, Object value) {
    Assert.hasText(name, "Claim property name cannot be null or empty.");
    if (this.claims == null) {
        if (value != null) {
            ensureClaims().put(name, value);
        }
    } else {
        if (value == null) {
            this.claims.remove(name);
        } else {
            this.claims.put(name, value);
        }
    }

    return this;
}
 
源代码2 项目: juiser   文件: ForwardedUserFilter.java
public ForwardedUserFilter(String headerName,
                           Function<HttpServletRequest, User> userFactory,
                           Collection<String> requestAttributeNames) {
    Assert.hasText(headerName, "headerName cannot be null or empty.");
    Assert.notNull(userFactory, "userFactory function cannot be null.");

    this.headerName = headerName;
    this.userFactory = userFactory;

    //always ensure that the fully qualified interface name is accessible:
    LinkedHashSet<String> set = new LinkedHashSet<>();
    set.add(User.class.getName());
    if (!Collections.isEmpty(requestAttributeNames)) {
        set.addAll(requestAttributeNames);
    }
    this.requestAttributeNames = set;
}
 
源代码3 项目: juiser   文件: RequestHeaderUserFactory.java
@Override
public User apply(HttpServletRequest request) {
    String value = request.getHeader(headerName);
    Assert.hasText(value, "header value cannot be null or empty.");
    User user;
    try {
        user = headerValueToUser.apply(value);
    } catch (Exception e) {
        String msg = "Unable to determine request User based on " + headerName + " header value [" + value +
            "] when invoking headerValue-to-User conversion function: " + e.getMessage();
        throw new IllegalStateException(msg, e);
    }

    Assert.state(user != null, "User instance returned from headerValue-to-User conversion " +
        "function cannot be null.");

    return user;
}
 
源代码4 项目: jjwt   文件: DefaultJwtBuilder.java
@Override
public JwtBuilder claim(String name, Object value) {
    Assert.hasText(name, "Claim property name cannot be null or empty.");
    if (this.claims == null) {
        if (value != null) {
            ensureClaims().put(name, value);
        }
    } else {
        if (value == null) {
            this.claims.remove(name);
        } else {
            this.claims.put(name, value);
        }
    }

    return this;
}
 
源代码5 项目: lams   文件: DefaultJwtParser.java
@Override
public JwtParser require(String claimName, Object value) {
    Assert.hasText(claimName, "claim name cannot be null or empty.");
    Assert.notNull(value, "The value cannot be null for claim name: " + claimName);
    expectedClaims.put(claimName, value);
    return this;
}
 
源代码6 项目: tutorials   文件: SecretService.java
public void setSecrets(Map<String, String> secrets) {
    Assert.notNull(secrets);
    Assert.hasText(secrets.get(SignatureAlgorithm.HS256.getValue()));
    Assert.hasText(secrets.get(SignatureAlgorithm.HS384.getValue()));
    Assert.hasText(secrets.get(SignatureAlgorithm.HS512.getValue()));

    this.secrets = secrets;
}
 
源代码7 项目: juiser   文件: ImmutablePhone.java
public ImmutablePhone(String number, String name, String description, boolean verified) {
    Assert.hasText(number, "number argument cannot be null or empty.");
    this.number = number;
    this.digitString = digitsOnly(number);
    this.name = name;
    this.description = description;
    this.verified = verified;
}
 
private Mono<String> organizationId() {
	String org = this.runtimeEnvironmentInfo.getPlatformSpecificInfo().get(CloudFoundryPlatformSpecificInfo.ORG);
	Assert.hasText(org,"Missing runtimeEnvironmentInfo : 'org' required.");
	ListOrganizationsRequest listOrganizationsRequest =  ListOrganizationsRequest.builder()
			.name(org).build();
	return this.client.organizations().list(listOrganizationsRequest)
			.doOnError(logError("Failed to list organizations"))
			.map(listOrganizationsResponse -> listOrganizationsResponse.getResources().get(0).getMetadata().getId())
			.cache(aValue -> Duration.ofMillis(Long.MAX_VALUE), aValue -> Duration.ZERO, () -> Duration.ZERO);
}
 
private Mono<String> spaceId() {
	String space = this.runtimeEnvironmentInfo.getPlatformSpecificInfo().get(CloudFoundryPlatformSpecificInfo.SPACE);
	Assert.hasText(space,"Missing runtimeEnvironmentInfo : 'space' required.");
	ListSpacesRequest listSpacesRequest = ListSpacesRequest.builder()
			.name(space).build();
	return this.client.spaces().list(listSpacesRequest)
			.doOnError(logError("Failed to list spaces"))
			.map(listSpacesResponse -> listSpacesResponse.getResources().get(0).getMetadata().getId())
			.cache(aValue -> Duration.ofMillis(Long.MAX_VALUE), aValue -> Duration.ZERO, () -> Duration.ZERO);
}
 
源代码10 项目: jjwt   文件: DefaultJwtParser.java
@Override
public JwtParser require(String claimName, Object value) {
    Assert.hasText(claimName, "claim name cannot be null or empty.");
    Assert.notNull(value, "The value cannot be null for claim name: " + claimName);
    expectedClaims.put(claimName, value);
    return this;
}
 
源代码11 项目: jjwt   文件: DefaultCompressionCodecResolver.java
private CompressionCodec byName(String name) {
    Assert.hasText(name, "'name' must not be empty");

    CompressionCodec codec = codecs.get(name.toUpperCase());
    if (codec == null) {
        throw new CompressionException(String.format(MISSING_COMPRESSION_MESSAGE, name));
    }

    return codec;
}
 
源代码12 项目: jjwt   文件: DefaultJwtBuilder.java
@Override
public JwtBuilder signWith(SignatureAlgorithm alg, String base64EncodedSecretKey) throws InvalidKeyException {
    Assert.hasText(base64EncodedSecretKey, "base64-encoded secret key cannot be null or empty.");
    Assert.isTrue(alg.isHmac(), "Base64-encoded key bytes may only be specified for HMAC signatures.  If using RSA or Elliptic Curve, use the signWith(SignatureAlgorithm, Key) method instead.");
    byte[] bytes = Decoders.BASE64.decode(base64EncodedSecretKey);
    return signWith(alg, bytes);
}
 
源代码13 项目: jjwt   文件: DefaultJwtParserBuilder.java
@Override
public JwtParserBuilder require(String claimName, Object value) {
    Assert.hasText(claimName, "claim name cannot be null or empty.");
    Assert.notNull(value, "The value cannot be null for claim name: " + claimName);
    expectedClaims.put(claimName, value);
    return this;
}
 
源代码14 项目: lams   文件: AbstractTextCodec.java
@Override
public String encode(String data) {
    Assert.hasText(data, "String argument to encode cannot be null or empty.");
    byte[] bytes = data.getBytes(UTF8);
    return encode(bytes);
}
 
源代码15 项目: lams   文件: DefaultJwtParser.java
@Override
public JwtParser setSigningKey(String base64EncodedKeyBytes) {
    Assert.hasText(base64EncodedKeyBytes, "signing key cannot be null or empty.");
    this.keyBytes = TextCodec.BASE64.decode(base64EncodedKeyBytes);
    return this;
}
 
源代码16 项目: juiser   文件: RequestHeaderUserFactory.java
public RequestHeaderUserFactory(String headerName, Function<String, User> headerValueToUserConverter) {
    Assert.hasText(headerName, "headerName argument cannot be null or empty.");
    Assert.notNull(headerValueToUserConverter, "headerValueToUserConverter function cannot be null.");
    this.headerName = headerName;
    this.headerValueToUser = headerValueToUserConverter;
}
 
源代码17 项目: juiser   文件: DefaultResource.java
public DefaultResource(InputStream is, String name) {
    Assert.notNull(is, "InputStream cannot be null.");
    Assert.hasText(name, "String name argument cannot be null or empty.");
    this.is = is;
    this.name = name;
}
 
源代码18 项目: jjwt   文件: AbstractTextCodec.java
@Override
public String encode(String data) {
    Assert.hasText(data, "String argument to encode cannot be null or empty.");
    byte[] bytes = data.getBytes(UTF8);
    return encode(bytes);
}
 
源代码19 项目: jjwt   文件: DefaultJwtParser.java
@Override
public JwtParser setSigningKey(String base64EncodedSecretKey) {
    Assert.hasText(base64EncodedSecretKey, "signing key cannot be null or empty.");
    this.keyBytes = Decoders.BASE64.decode(base64EncodedSecretKey);
    return this;
}
 
源代码20 项目: jjwt   文件: DefaultJwtParserBuilder.java
@Override
public JwtParserBuilder setSigningKey(String base64EncodedSecretKey) {
    Assert.hasText(base64EncodedSecretKey, "signing key cannot be null or empty.");
    this.keyBytes = Decoders.BASE64.decode(base64EncodedSecretKey);
    return this;
}