本文整理匯總了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);
}