当前位置: 首页>>代码示例>>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;未经允许,请勿转载。