当前位置: 首页>>代码示例>>Java>>正文


Java JWTClaimsSet.getStringClaim方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:vrk-kpa,项目名称:roles-auths-client,代码行数:16,代码来源:JwtUtil.java

示例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());
    }
}
 
开发者ID:vrk-kpa,项目名称:roles-auths-client,代码行数:16,代码来源:JwtUtil.java

示例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());
    }
}
 
开发者ID:vrk-kpa,项目名称:roles-auths-client,代码行数:16,代码来源:JwtUtil.java

示例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);
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:56,代码来源:AuthorizeCodeClaimsSet.java


注:本文中的com.nimbusds.jwt.JWTClaimsSet.getStringClaim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。