org.springframework.boot.json.JsonParserFactory Java Examples

The following examples show how to use org.springframework.boot.json.JsonParserFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuth2ClientCredentialsService.java    From flair-registry with Apache License 2.0 6 votes vote down vote up
public String getAccessToken() {
    if (accessToken == null) {
        retrieveNewAccessToken();
    }

    Jwt jwt = JwtHelper.decode(accessToken);
    String claims = jwt.getClaims();
    JsonParser jsonParser = JsonParserFactory.getJsonParser();
    Map<String, Object> claimMap = jsonParser.parseMap(claims);
    Integer exp = (Integer) claimMap.get("exp");
    int now = (int) (System.currentTimeMillis() / 1000L);

    if (exp < now) {
        retrieveNewAccessToken();
    }

    return accessToken;
}
 
Example #2
Source File: Role.java    From fish-admin with MIT License 6 votes vote down vote up
/**
 * 验证是否有访问权限
 * @param entity entity名称
 * @param access 访问权限: read, create, update, destroy
 * @return
 */
public boolean hasPermission(Object entity, Object access) {
    if (Strings.isNullOrEmpty(permissions)) return false;
    Map ps = JsonParserFactory.getJsonParser().parseMap(permissions);

    String entityName;
    if (entity instanceof String) {
        entityName = (String) entity;
    } else {
        entityName = (String) entity;
    }

    String permission;
    if (access instanceof Permission) {
        permission = ((Permission) access).name();
    } else {
        permission = (String) access;
    }

    if (ps.containsKey(entityName)) {
        List<String> methodNames = (List<String>) ps.get(entityName);
        return methodNames.stream().filter(m -> m.equals(permission)).count() > 0;
    }
    return false;
}
 
Example #3
Source File: Role.java    From fish-admin with MIT License 4 votes vote down vote up
@JsonIgnore
public Map getPermissionsMap() {
    return Strings.isNullOrEmpty(permissions) ?
            new HashMap() : JsonParserFactory.getJsonParser().parseMap(permissions);
}
 
Example #4
Source File: GcpCloudFoundryEnvironmentPostProcessorTests.java    From spring-cloud-gcp with Apache License 2.0 4 votes vote down vote up
private String getPrivateKeyDataFromJson(String json, String serviceName) {
	JsonParser parser = JsonParserFactory.getJsonParser();
	Map<String, Object> vcapMap = parser.parseMap(json);
	return ((Map<String, String>) ((Map<String, Object>) ((List<Object>) vcapMap.get(serviceName)).get(0))
			.get("credentials")).get("PrivateKeyData");
}