當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonReader.readObject方法代碼示例

本文整理匯總了Java中javax.json.JsonReader.readObject方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonReader.readObject方法的具體用法?Java JsonReader.readObject怎麽用?Java JsonReader.readObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.json.JsonReader的用法示例。


在下文中一共展示了JsonReader.readObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyInjectedJTI2

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected jti claim is as expected")
public void verifyInjectedJTI2() throws Exception {
    Reporter.log("Begin verifyInjectedJTI\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedJTI";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.jti.name(), "a-123")
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:19,代碼來源:ProviderInjectionTest.java

示例2: testLogin

import javax.json.JsonReader; //導入方法依賴的package包/類
@Test
public void testLogin() {
	try {
		String authUrl = String.format(AUTH_URL_BASE, port);
		JsonObject request = Json.createObjectBuilder()
				.add("id", DEFAULT_ID)
				.add("key", DEFAULT_KEY)
				.build();

		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		HttpEntity<String> entity = new HttpEntity<>(request.toString(), headers);
		RestTemplate rest = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
		ResponseEntity<String> response = rest.exchange(authUrl, HttpMethod.POST, entity, String.class);

		assertEquals(200, response.getStatusCodeValue());
		JsonReader reader = Json.createReader(new StringReader(response.getBody()));
		JsonObject o = reader.readObject();
		String token = o.getString("token");
		assertTrue(!StringUtils.isEmpty(token));
		logger.info(token);
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		fail(e.getMessage());
	}
}
 
開發者ID:kinota,項目名稱:kinota-server,代碼行數:27,代碼來源:AgentLoginTest.java

示例3: verifyInjectedIssuedAt

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI,
    description = "Verify that the injected iat claim is as expected")
public void verifyInjectedIssuedAt() throws Exception {
    Reporter.log("Begin verifyInjectedIssuedAt\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedIssuedAt";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.iat.name(), iatClaim)
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:19,代碼來源:ClaimValueInjectionTest.java

示例4: verifyExpiration

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_JWT,
        description = "Verify that the exp claim is as expected")
public void verifyExpiration() throws Exception {
    Reporter.log("Begin verifyExpiration\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyExpiration";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
            .target(uri)
            .queryParam(Claims.exp.name(), expClaim)
            .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:19,代碼來源:RequiredClaimsTest.java

示例5: verifyInjectedAuthTime2

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
    description = "Verify that the injected auth_time is as expected from Token2")
public void verifyInjectedAuthTime2() throws Exception {
    Reporter.log("Begin verifyInjectedAuthTime2\n");
    HashMap<String, Long> timeClaims = new HashMap<>();
    String token2 = TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
    Long authTimeClaim = timeClaims.get(Claims.auth_time.name());
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedAuthTime";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token2).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:21,代碼來源:JsonValueInjectionTest.java

示例6: verifyInjectedRawToken2

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
    description = "Verify that the injected raw token claim is as expected from Token2")
public void verifyInjectedRawToken2() throws Exception {
    Reporter.log("Begin verifyInjectedRawToken2\n");
    String token2 = TokenUtils.generateTokenString("/Token2.json");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedRawToken";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.raw_token.name(), token2)
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token2).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:20,代碼來源:JsonValueInjectionTest.java

示例7: verifyInjectedOptionalAuthTime

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected raw token claim is as expected")
public void verifyInjectedOptionalAuthTime() throws Exception {
    Reporter.log("Begin verifyInjectedOptionalAuthTime\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedOptionalAuthTime";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:18,代碼來源:ProviderInjectionTest.java

示例8: verifyInjectedCustomIntegerArray

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
    description = "Verify that the injected customIntegerArray claim is as expected")
public void verifyInjectedCustomIntegerArray() throws Exception {
    Reporter.log("Begin verifyInjectedCustomIntegerArray\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedCustomIntegerArray";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam("value", 0, 1, 2, 3)
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:19,代碼來源:JsonValueInjectionTest.java

示例9: verifyInjectedAudience2

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected aud claim is as expected")
public void verifyInjectedAudience2() throws Exception {
    Reporter.log("Begin verifyInjectedAudience\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedAudience";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.aud.name(), "s6BhdRkqt3")
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:19,代碼來源:ProviderInjectionTest.java

示例10: verifyInjectedIssuedAt2

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_JSON,
    description = "Verify that the injected iat claim is as expected from Token2")
public void verifyInjectedIssuedAt2() throws Exception {
    Reporter.log("Begin verifyInjectedIssuedAt2\n");
    HashMap<String, Long> timeClaims = new HashMap<>();
    String token2 = TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
    Long iatClaim = timeClaims.get(Claims.auth_time.name());
    Long authTimeClaim = timeClaims.get(Claims.auth_time.name());
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedIssuedAt";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.iat.name(), iatClaim)
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token2).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:23,代碼來源:JsonValueInjectionTest.java

示例11: verifyInjectedGroups

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected groups claim is as expected")
public void verifyInjectedGroups() throws Exception {
    Reporter.log("Begin verifyInjectedGroups\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedGroups";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.groups.name(), new String[]{
                "Echoer", "Tester", "group1", "group2"})
            .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:20,代碼來源:PrimitiveInjectionTest.java

示例12: verifyInjectedCustomString

import javax.json.JsonReader; //導入方法依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected customString claim is as expected")
public void verifyInjectedCustomString() throws Exception {
    Reporter.log("Begin verifyInjectedCustomString\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedCustomString";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam("value", "customStringValue")
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
開發者ID:eclipse,項目名稱:microprofile-jwt-auth,代碼行數:19,代碼來源:PrimitiveInjectionTest.java

示例13: processData

import javax.json.JsonReader; //導入方法依賴的package包/類
@Override
public void processData(List<String> jsonData) {
    for (Iterator<String> iterator = jsonData.iterator(); iterator.hasNext();) {
        String jsonStr = iterator.next();
        JsonReader jsonReader = Json.createReader(new StringReader(jsonStr));
        try {
            JsonObject jsonObject = jsonReader.readObject();
            String topicName = jsonObject.getString("topic", null);
            if (topicName != null) {
                if (topicName.equals("http")) {
                    JsonObject payload = jsonObject.getJsonObject("payload");
                    long requestTime = payload.getJsonNumber("time").longValue();
                    long requestDuration = payload.getJsonNumber("duration").longValue();
                    String requestUrl = payload.getString("url", "");

                    synchronized (aggregateHttpData) {
                        aggregateHttpData.aggregate(requestTime, requestDuration, requestUrl);
                    }
                } else {
                    emit(jsonObject.toString());
                }
            }
        } catch (JsonException je) {
            // Skip this object, log the exception and keep trying with
            // the rest of the list
            je.printStackTrace();
        }
    }
    emitHttp();
}
 
開發者ID:RuntimeTools,項目名稱:javametrics,代碼行數:31,代碼來源:DataHandler.java

示例14: parseSuccessfulAnalysisResults

import javax.json.JsonReader; //導入方法依賴的package包/類
private DeltaAnalysisResult parseSuccessfulAnalysisResults(HttpResponse rawResponse, Commits commits) throws IOException {
    final HttpEntity responseBody = rawResponse.getEntity();

    if (responseBody == null) {
        throw new RuntimeException("Internal error: The delta analysis was a success but failed to parse the returned results");
    }

    final JsonReader reader = Json.createReader(responseBody.getContent());
    final JsonObject delta = reader.readObject();

    return new DeltaAnalysisResult(commits, delta);
}
 
開發者ID:empear-analytics,項目名稱:codescene-jenkins-plugin,代碼行數:13,代碼來源:DeltaAnalysis.java

示例15: read

import javax.json.JsonReader; //導入方法依賴的package包/類
public void read(String data) {
	JsonReader reader = Json.createReader(new StringReader(data));
	JsonObject nets = reader.readObject();
	networks = new HashMap<String, NetworkModel>();
	Iterator<?> iter = nets.keySet().iterator();
	while (iter.hasNext()) {
		String key = (String) iter.next();
		NetworkModel net = new NetworkModel(key);
		NetworkData netData = new NetworkData(key);
		netData.read(nets.getJsonObject(key));
		net.setData(netData);
		networks.put(key, net);
	}
}
 
開發者ID:privacyint,項目名稱:thornsec-core,代碼行數:15,代碼來源:ThornsecModel.java


注:本文中的javax.json.JsonReader.readObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。