Java Code Examples for org.springframework.boot.json.JsonParserFactory

The following examples show how to use org.springframework.boot.json.JsonParserFactory. These examples are extracted from open source projects. 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
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 Project: fish-admin   Source File: Role.java    License: 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 Project: fish-admin   Source File: Role.java    License: MIT License 4 votes vote down vote up
@JsonIgnore
public Map getPermissionsMap() {
    return Strings.isNullOrEmpty(permissions) ?
            new HashMap() : JsonParserFactory.getJsonParser().parseMap(permissions);
}
 
Example 4
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");
}