UaaTokenUtils { public static boolean isUserToken(Map<String, Object> claims) { if (claims.get(GRANT_TYPE)!=null) { return !GRANT_TYPE_CLIENT_CREDENTIALS.equals(claims.get(GRANT_TYPE)); } if (claims.get(SUB)!=null) { if (claims.get(SUB).equals(claims.get(USER_ID))) { return true; } else if (claims.get(SUB).equals(claims.get(CID))) { return false; } } return true; } private  UaaTokenUtils(); static String getRevocationHash(List<String> salts); static int murmurhash3x8632(byte[] data, int offset, int len, int seed); static Set<String> retainAutoApprovedScopes(Collection<String> requestedScopes, Set<String> autoApprovedScopes); static boolean isUserToken(Map<String, Object> claims); static String getRevocableTokenSignature(ClientDetails client, String clientSecret, UaaUser user); static String getRevocableTokenSignature(UaaUser user, String tokenSalt, String clientId, String clientSecret); static String constructToken(Map<String, Object> header, Map<String, Object> claims, Signer signer); static boolean isJwtToken(String token); static String constructTokenEndpointUrl(String issuer, IdentityZone identityZone); static boolean hasRequiredUserAuthorities(Collection<String> requiredGroups, Collection<? extends GrantedAuthority> userGroups); static boolean hasRequiredUserGroups(Collection<String> requiredGroups, Collection<String> userGroups); static Map<String, Object> getClaims(String jwtToken); static final Pattern jwtPattern; }
@Test public void is_user_token() { Map<String, Object> claims = new HashMap(); assertTrue(isUserToken(claims)); for (String grantType : Arrays.asList(GRANT_TYPE_PASSWORD, GRANT_TYPE_IMPLICIT, GRANT_TYPE_AUTHORIZATION_CODE)) { claims.put(GRANT_TYPE, grantType); assertTrue(isUserToken(claims)); } claims.put(GRANT_TYPE, "client_credentials"); assertFalse(isUserToken(claims)); claims.clear(); claims.put(ClaimConstants.USER_ID, "id"); assertTrue(isUserToken(claims)); claims.clear(); claims.put(SUB, "someClientId"); claims.put(CID, "someClientId"); assertFalse(isUserToken(claims)); }