/** * Gets the specified claims (registered or custom) as a * {@link java.util.List} list of strings. * * @param name The name of the claim. Must not be {@code null}. * * @return The value of the claim, {@code null} if not specified. * * @throws ParseException If the claim value is not of the required * type. */ public List<String> getStringListClaim(final String name) throws ParseException { String[] stringArray = getStringArrayClaim(name); if (stringArray == null) { return null; } return Collections.unmodifiableList(Arrays.asList(stringArray)); }
@Override public String[] getAudienceClaims() { String[] claims = null; try { claims = jwt.getJWTClaimsSet().getStringArrayClaim(JWT.AUDIENCE); } catch (ParseException e) { log.unableToParseToken(e); } return claims; }
@Override public String[] getAudienceClaims() { String[] claims = null; try { claims = jwt.getJWTClaimsSet().getStringArrayClaim(JWT.AUDIENCE); } catch (ParseException e) { log.unableToParseToken(e); } return claims; }
public static Collection<Principal> deserialize(String token) { JWTClaimsSet claimSet = EncryptedTokenSerializer.deserialize(token, getSecretKey()); try { Collection<Principal> preparedPrincipals = new ArrayList<>(); SimplePrincipal principal = new SimplePrincipal(claimSet.getStringClaim("principal")); preparedPrincipals.add(principal); Group callerGroup = new SimpleGroup("CallerPrincipal"); preparedPrincipals.add(callerGroup); callerGroup.addMember(principal); Group rolesGroup = new SimpleGroup("Roles"); preparedPrincipals.add(rolesGroup); for (Object object : claimSet.getStringArrayClaim("roles")) { if (object instanceof String) { rolesGroup.addMember(new SimplePrincipal((String) object)); } } return preparedPrincipals; } catch (ParseException e) { throw new OAuthException("expected valid roles and principal in cookie", null); } }