org.springframework.boot.json.JsonParser Java Examples

The following examples show how to use org.springframework.boot.json.JsonParser. 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: AccountingServiceClientApplication.java    From Hands-On-High-Performance-with-Spring-5 with MIT License 5 votes vote down vote up
@GetMapping("/account")
public String getAccountName(@RequestParam("id") Long id) {
	ResponseEntity<String> responseEntity = new RestTemplate().getForEntity(accountingServiceUrl + "/" + id,
			String.class);
	JsonParser parser = new BasicJsonParser();
	Map<String, Object> responseMap = parser.parseMap(responseEntity.getBody());
	return (String) responseMap.get("accountName");
}
 
Example #3
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");
}