use of net.minidev.json.JSONObject in project ddf by codice.
the class GeoJsonQueryResponseTransformer method convertToJSON.
private JSONObject convertToJSON(Result result) throws CatalogTransformerException {
JSONObject rootObject = new JSONObject();
addNonNullObject(rootObject, "distance", result.getDistanceInMeters());
addNonNullObject(rootObject, "relevance", result.getRelevanceScore());
addNonNullObject(rootObject, "metacard", createGeoJSON(result.getMetacard()));
return rootObject;
}
use of net.minidev.json.JSONObject in project ddf by codice.
the class OAuthPluginTest method getRefreshTokenBuilder.
private JWTCreator.Builder getRefreshTokenBuilder() {
String[] audience = { "master-realm", "account" };
JSONObject realmAccess = new JSONObject();
realmAccess.put("roles", ImmutableList.of("create-realm", "offline_access", "admin", "uma_authorization"));
return JWT.create().withJWTId(UUID.randomUUID().toString()).withExpiresAt(new Date(Instant.now().plus(Duration.ofDays(3)).toEpochMilli())).withNotBefore(new Date(0)).withIssuedAt(new Date()).withIssuer("http://localhost:8080/auth/realms/master").withAudience("http://localhost:8080/auth/realms/master").withArrayClaim("aud", audience).withSubject("subject").withClaim("typ", "Refresh").withClaim(AZP, DDF_CLIENT).withClaim("auth_time", 0).withClaim("realm_access", realmAccess.toString()).withClaim("scope", "openid profile email");
}
use of net.minidev.json.JSONObject in project ddf by codice.
the class OAuthPluginTest method getResponse.
private InputStream getResponse(String accessToken) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("access_token", accessToken);
jsonObject.put("token_type", "bearer");
jsonObject.put("refresh_token", getRefreshTokenBuilder().sign(validAlgorithm));
jsonObject.put("expires_in", 60);
jsonObject.put("scope", "openid profile email");
return new ByteArrayInputStream(jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8));
}
use of net.minidev.json.JSONObject in project ddf by codice.
the class GeoCoderServiceImpl method doQuery.
JSONObject doQuery(String query) {
GeoCoder geoCoder = geoCoderFactory.getService();
GeoResult geoResult = null;
if (geoCoder != null) {
geoResult = geoCoder.getLocation(query);
}
JSONObject jsonObject = new JSONObject();
JSONArray resourceSets = new JSONArray();
JSONObject resourceSet = new JSONObject();
jsonObject.put("resourceSets", resourceSets);
resourceSets.add(resourceSet);
JSONArray resources = new JSONArray();
resourceSet.put("resources", resources);
if (geoResult != null) {
transformGeoResult(geoResult, resources);
}
return jsonObject;
}
use of net.minidev.json.JSONObject in project ddf by codice.
the class GeoJsonQueryResponseTransformerTest method testGoodResponse.
@Test
public void testGoodResponse() throws CatalogTransformerException, IOException, ParseException {
final int resultCount = 3;
final int hitCount = 12;
SourceResponse sourceResponse = setupResponse(resultCount, hitCount);
JSONObject obj = transform(sourceResponse);
verifyResponse(obj, resultCount, hitCount);
}
Aggregations