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


Java HttpHeaders類代碼示例

本文整理匯總了Java中javax.ws.rs.core.HttpHeaders的典型用法代碼示例。如果您正苦於以下問題:Java HttpHeaders類的具體用法?Java HttpHeaders怎麽用?Java HttpHeaders使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: updateProcessOption

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@PUT
@Path("/{id}/processes/{optionId}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Add ProcessOption", response = ProcessOptionInputModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a ProcessOption was updated", response = ProcessOptionInputModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateProcessOption(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "serviceconfigId for get detail") @PathParam("id") long id,
		@ApiParam(value = "processOptionId for get detail") @PathParam("optionId") long optionId,
		@ApiParam(value = "input model for ProcessOption") @BeanParam ProcessOptionInputModel input);
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:17,代碼來源:ServiceConfigManagement.java

示例2: checkPermissions

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
private void checkPermissions(ContainerRequestContext requestContext, List<Role> allowedRoles) throws Exception {
    // Check if the user contains one of the allowed roles
    // Throw an Exception if the user has not permission to execute the method
    if(allowedRoles.isEmpty())
        return;
    String authorizationHeader
            = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
    String token = authorizationHeader
            .substring(AUTHENTICATION_SCHEME.length()).trim();
    List<String> roles = new ArrayList();
    if (!JWT.decode(token).getClaim("gty").isNull() && JWT.decode(token).getClaim("gty").asString().equals("client-credentials")) {
        roles.add("service");
    } else {
        roles = JWT.decode(token).getClaim("roles").asList(String.class);
    }
    for(String role: roles) {
        if(allowedRoles.contains(Role.valueOf(role)))
            return;
    }
    throw new WebApplicationException(
                Response.status(Response.Status.FORBIDDEN).build());
}
 
開發者ID:ISIS2503,項目名稱:ThermalComfortBack,代碼行數:23,代碼來源:AuthorizationFilter.java

示例3: put

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
/**
 * このパスに新たなファイルを配置する.
 * @param contentType Content-Typeヘッダ
 * @param inputStream リクエストボディ
 * @return Jax-RS Responseオブジェクトト
 */
@WriteAPI
@PUT
public final Response put(
        @HeaderParam(HttpHeaders.CONTENT_TYPE) final String contentType,
        final InputStream inputStream) {

    // アクセス製禦
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.WRITE);

    // 途中のパスが存在しないときは409エラー
    /*
     * A PUT that would result in the creation of a resource without an
     * appropriately scoped parent collection MUST fail with a 409 (Conflict).
     */

    if (!DavCommon.isValidResourceName(this.davRsCmp.getDavCmp().getName())) {
        throw PersoniumCoreException.Dav.RESOURCE_NAME_INVALID;
    }

    if (this.isParentNull) {
        throw PersoniumCoreException.Dav.HAS_NOT_PARENT.params(this.davRsCmp.getParent().getUrl());
    }

    return this.davRsCmp.getDavCmp().putForCreate(contentType, inputStream).build();
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:32,代碼來源:NullResource.java

示例4: testAddBookWithNecessaryFields

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@Test
public void testAddBookWithNecessaryFields() throws Exception {
  Book book = new Book();
  book.setTitle("How to Win Friends & Influence People");
  book.setAuthor("Dale Carnegie");
  book.setIsbn("067142517X");
  book.setPages(299);

  Entity<Book> bookEntity = Entity.entity(book, MediaType.APPLICATION_JSON);
  Response response = target("books")
      .request(MediaType.APPLICATION_JSON)
      .header(HttpHeaders.AUTHORIZATION, authHeaderValue)
      .post(bookEntity);

  assertEquals(201, response.getStatus());
  assertNotNull(response.getHeaderString("Location"));

  Book bookResponse = response.readEntity(Book.class);

  assertEquals("How to Win Friends & Influence People", bookResponse.getTitle());
  assertEquals("Dale Carnegie", bookResponse.getAuthor());
  assertEquals("067142517X", bookResponse.getIsbn());
  assertEquals(299, bookResponse.getPages().intValue());

  assertEquals(204, cleanUp(bookResponse.getId()).getStatus());
}
 
開發者ID:durimkryeziu,項目名稱:jersey-2.x-webapp-for-servlet-container,代碼行數:27,代碼來源:BookResourceIntegrationTest.java

示例5: queryVMInfo

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@ApiOperation(value = "Query Virtual Machine information",
        notes = "Query VM information based on VM UUID, IP, MAC or Flow 6-field-tuple. Request can include all search "
                + "criteria. If found, the respond will include the VM "
                + "information based on the information provided for query. For example, if IP is provided, "
                + "response will include a map entry where the key is the IP and the value is the VM information.<br>",
        response = QueryVmInfoResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/queryVmInfo")
@POST
public Response queryVMInfo(@Context HttpHeaders headers,
        @ApiParam(required = true) QueryVmInfoRequest queryVmInfo) {

    log.info("Query VM info request: " + queryVmInfo);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));

    return this.apiUtil.getResponse(this.queryVmInfoService, queryVmInfo);
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:19,代碼來源:ManagerApis.java

示例6: verifyUPN

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_JWT,
        description = "Verify that the uPN claim is as expected")
public void verifyUPN() throws Exception {
    Reporter.log("Begin verifyUPN\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyUPN";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
            .target(uri)
            .queryParam(Claims.upn.name(), "[email protected]")
            .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

示例7: submitting

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@Override
public Response submitting(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
		User user, ServiceContext serviceContext, long registrationId) {

	BackendAuth auth = new BackendAuthImpl();
	try {

		if (!auth.isAuth(serviceContext)) {
			throw new UnauthenticationException();
		}

		Registration registration = RegistrationLocalServiceUtil.updateSubmitting(registrationId, true);

		return Response.status(200).entity(registration).build();
	} catch (Exception e) {
		return processException(e);
	}
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:19,代碼來源:RegistrationManagementImpl.java

示例8: onFinishItem

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@Override
public void onFinishItem(
	JSONObjectBuilder pageJSONObjectBuilder,
	JSONObjectBuilder itemJSONObjectBuilder, T model, Class<T> modelClass,
	HttpHeaders httpHeaders) {

	Optional<Representor<T, Object>> optional =
		representableManager.getRepresentorOptional(modelClass);

	optional.map(
		Representor::getTypes
	).ifPresent(
		types -> pageJSONObjectBuilder.nestedField(
			"_embedded", types.get(0)
		).arrayValue(
		).add(
			itemJSONObjectBuilder
		)
	);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:21,代碼來源:HALPageMessageMapper.java

示例9: deleteFormbyRegId

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@Override
public Response deleteFormbyRegId(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
		User user, ServiceContext serviceContext, long id, String referenceUid) {
	BackendAuth auth = new BackendAuthImpl();

	try {
		if (!auth.isAuth(serviceContext)) {
			throw new UnauthenticationException();
		}
		long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
		RegistrationFormActions action = new RegistrationFormActionsImpl();

		action.deleteRegistrationForm(groupId, id, referenceUid);

		return Response.status(HttpURLConnection.HTTP_NO_CONTENT).build();

	} catch (Exception e) {
		return processException(e);
	}

}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:22,代碼來源:RegistrationFormManagementImpl.java

示例10: verifyExpiration

import javax.ws.rs.core.HttpHeaders; //導入依賴的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

示例11: addRegistrationByRegistrationId

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@Override
public Response addRegistrationByRegistrationId(HttpServletRequest request, HttpHeaders header, Company company,
		Locale locale, User user, ServiceContext serviceContext, long registrationId, String author, String payload,
		String content) {
	// TODO Auto-generated method stub
	BackendAuth auth = new BackendAuthImpl();
	long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
	try {
		if(!auth.isAuth(serviceContext)){
			throw new UnauthenticationException();
		}
		RegistrationLogActions action = new RegistrationLogActionsImpl();
		RegistrationLog registrationLog = action.addRegistrationLogById(groupId, registrationId, author, content, payload, serviceContext);
		
		RegistrationLogModel result = RegistrationLogUtils.mappingToRegistrationLogModel(registrationLog);
		
		return Response.status(200).entity(result).build();
		
	} catch (Exception e) {
		// TODO: handle exception
		return processException(e);
	}
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:24,代碼來源:RegistrationLogManagementImpl.java

示例12: updatePaymentFileApproval

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@PUT
@Path("/{id}/payments/{referenceUid}/approval")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update DossierFile")
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updatePaymentFileApproval(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, 
		@ApiParam(value = "id of dossier", required = true) @PathParam("id") String id,
		@ApiParam(value = "reference of paymentFile", required = true) @PathParam("referenceUid") String referenceUid,
		@ApiParam(value = "Attachment files") @Multipart("file") Attachment file,
		@ApiParam(value = "Metadata of PaymentFile") @Multipart("approveDatetime") String approveDatetime,
		@ApiParam(value = "Metadata of PaymentFile") @Multipart("accountUserName") String accountUserName,
		@ApiParam(value = "Metadata of PaymentFile") @Multipart("govAgencyTaxNo") String govAgencyTaxNo,
		@ApiParam(value = "Metadata of PaymentFile") @Multipart("invoiceTemplateNo") String invoiceTemplateNo,
		@ApiParam(value = "Metadata of PaymentFile") @Multipart("invoiceIssueNo") String invoiceIssueNo,
		@ApiParam(value = "Metadata of PaymentFile") @Multipart("invoiceNo") String invoiceNo);
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:23,代碼來源:PaymentFileManagement.java

示例13: verifyInjectedUPN

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected upn claim is as expected")
public void verifyInjectedUPN() throws Exception {
    Reporter.log("Begin verifyInjectedUPN\n");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedUPN";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.upn.name(), "[email protected]")
        .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

示例14: userAgent

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
/**
 * RtHub return Request with UserAgent.
 * @throws Exception If fails
 */
@Test
public void userAgent() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple("hello, world!")
        ).start();
    new RtHub(
        container.home()
    ).entry().fetch();
    container.stop();
    MatcherAssert.assertThat(
        container.take().headers(),
        Matchers.hasEntry(
            Matchers.equalTo(HttpHeaders.USER_AGENT),
            Matchers.hasItem(
                String.format(
                    "jb-hub-api-client %s %s %s",
                    Manifests.read("Hub-Version"),
                    Manifests.read("Hub-Build"),
                    Manifests.read("Hub-Date")
                )
            )
        )
    );
}
 
開發者ID:smallcreep,項目名稱:jb-hub-client,代碼行數:30,代碼來源:RtHubTest.java

示例15: createSecutiryGroupInterface

import javax.ws.rs.core.HttpHeaders; //導入依賴的package包/類
@ApiOperation(value = "Creates a Traffic Policy Mapping",
        notes = "Creates a Traffic Policy Mapping owned by Virtual System provided",
        response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{vsId}/securityGroupInterfaces")
@POST
public Response createSecutiryGroupInterface(@Context HttpHeaders headers,
        @ApiParam(value = "The Virtual System Id") @PathParam("vsId") Long vsId,
        @ApiParam(required = true) SecurityGroupInterfaceDto sgiDto) {
    logger.info("Creating Security Group Interface ...");
    this.userContext.setUser(OscAuthFilter.getUsername(headers));
    this.apiUtil.setParentIdOrThrow(sgiDto, vsId, "Traffic Policy Mapping");
    return this.apiUtil.getResponseForBaseRequest(this.addSecurityGroupInterfaceService,
            new BaseRequest<SecurityGroupInterfaceDto>(sgiDto));
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:17,代碼來源:VirtualSystemApis.java


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