本文整理汇总了Java中com.nimbusds.jwt.JWTClaimsSet.getStringClaim方法的典型用法代码示例。如果您正苦于以下问题:Java JWTClaimsSet.getStringClaim方法的具体用法?Java JWTClaimsSet.getStringClaim怎么用?Java JWTClaimsSet.getStringClaim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nimbusds.jwt.JWTClaimsSet
的用法示例。
在下文中一共展示了JWTClaimsSet.getStringClaim方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAuthorization
import com.nimbusds.jwt.JWTClaimsSet; //导入方法依赖的package包/类
public Authorization getAuthorization(String jwtString, String principalId) throws WebApiClientException {
try {
SignedJWT signedJWT = parseAndVerifyToken(jwtString);
JWTClaimsSet claimsSet = signedJWT.getJWTClaimsSet();
if (claimsSet.getStringClaim(JwtUtil.PRINCIPAL).equalsIgnoreCase(principalId) &&
claimsSet.getSubject().equalsIgnoreCase(SUBJECT_AUTHORIZATION)) {
String responseString = claimsSet.getStringClaim(RESPONSE);
return new Authorization(Authorization.Result.valueOf(responseString));
}
throw new WebApiClientException("Authorization token cannot be verified");
} catch (ParseException e) {
throw new WebApiClientException(e.getMessage());
}
}
示例2: getAuthorizationList
import com.nimbusds.jwt.JWTClaimsSet; //导入方法依赖的package包/类
public AuthorizationList getAuthorizationList(String jwtString, String principalId) throws WebApiClientException {
try {
SignedJWT signedJWT = parseAndVerifyToken(jwtString);
JWTClaimsSet claimsSet = signedJWT.getJWTClaimsSet();
if (claimsSet.getStringClaim(JwtUtil.PRINCIPAL).equalsIgnoreCase(principalId) &&
claimsSet.getSubject().equalsIgnoreCase(SUBJECT_AUTHORIZATION_LIST)) {
String responseString = claimsSet.getStringClaim(RESPONSE);
List<String> roles = objectMapper.readValue(responseString, List.class);
return new AuthorizationList(roles);
}
throw new WebApiClientException("Authorization token cannot be verified");
} catch (ParseException | IOException e) {
throw new WebApiClientException(e.getMessage());
}
}
示例3: getCompanies
import com.nimbusds.jwt.JWTClaimsSet; //导入方法依赖的package包/类
public List<YpaOrganization> getCompanies(String jwtString, String delegateId) throws WebApiClientException {
try {
SignedJWT signedJWT = parseAndVerifyToken(jwtString);
JWTClaimsSet claimsSet = signedJWT.getJWTClaimsSet();
if (claimsSet.getStringClaim(JwtUtil.END_USER).equalsIgnoreCase(delegateId) &&
claimsSet.getSubject().equalsIgnoreCase(SUBJECT_ORG_ROLES)) {
String responseString = claimsSet.getStringClaim(RESPONSE);
List<YpaOrganization> orgRoles = objectMapper.readValue(responseString, new TypeReference<List<YpaOrganization>>(){});
return orgRoles;
}
throw new WebApiClientException("OrganizationList token cannot be verified");
} catch (ParseException | IOException e) {
throw new WebApiClientException(e.getMessage());
}
}
示例4: parse
import com.nimbusds.jwt.JWTClaimsSet; //导入方法依赖的package包/类
/**
* Parses authz code from string (JSON)
*
* @param authorizeCodeClaimsSet
* JSON String representation of the code
* @return AuthorizeCodeClaimsSet instance if parsing is successful.
* @throws ParseException
* if parsing fails for example due to incompatible types.
*/
public static AuthorizeCodeClaimsSet parse(String authorizeCodeClaimsSet) throws ParseException {
JWTClaimsSet acClaimsSet = JWTClaimsSet.parse(authorizeCodeClaimsSet);
// Check existence and type of mandatory fields and values
if (!VALUE_TYPE_AC.equals(acClaimsSet.getClaims().get(KEY_TYPE))) {
throw new ParseException("claim type must have value ac", 0);
}
//Mandatory fields
if (acClaimsSet.getStringClaim(KEY_ISSUER) == null) {
throw new ParseException("claim iss must exist and not be null", 0);
}
if (acClaimsSet.getStringClaim(KEY_USER_PRINCIPAL) == null) {
throw new ParseException("claim sub must exist and not be null", 0);
}
if (acClaimsSet.getStringArrayClaim(KEY_CLIENTID) == null) {
throw new ParseException("claim aud must exist and not be null", 0);
}
if (acClaimsSet.getDateClaim(KEY_EXPIRATION_TIME) == null) {
throw new ParseException("claim exp must exist and not be null", 0);
}
if (acClaimsSet.getDateClaim(KEY_ISSUED_AT) == null) {
throw new ParseException("claim iat must exist and not be null", 0);
}
if (acClaimsSet.getStringClaim(KEY_AC_ID) == null) {
throw new ParseException("claim jti must exist and not be null", 0);
}
if (acClaimsSet.getStringClaim(KEY_ACR) == null) {
throw new ParseException("claim acr must exist and not be null", 0);
}
if (acClaimsSet.getDateClaim(KEY_AUTH_TIME) == null) {
throw new ParseException("claim auth_time must exist and not be null", 0);
}
if (acClaimsSet.getStringClaim(KEY_REDIRECT_URI) == null) {
throw new ParseException("claim redirect_uri must exist and not be null", 0);
}
if (acClaimsSet.getStringClaim(KEY_SCOPE) == null) {
throw new ParseException("claim scope must exist and not be null", 0);
}
//Voluntary fields
if (acClaimsSet.getClaims().containsKey(KEY_CLAIMS)) {
acClaimsSet.getJSONObjectClaim(KEY_CLAIMS);
}
if (acClaimsSet.getClaims().containsKey(KEY_NONCE)) {
acClaimsSet.getStringClaim(KEY_NONCE);
}
return new AuthorizeCodeClaimsSet(acClaimsSet);
}