当前位置: 首页>>代码示例>>Java>>正文


Java Status.FORBIDDEN属性代码示例

本文整理汇总了Java中javax.ws.rs.core.Response.Status.FORBIDDEN属性的典型用法代码示例。如果您正苦于以下问题:Java Status.FORBIDDEN属性的具体用法?Java Status.FORBIDDEN怎么用?Java Status.FORBIDDEN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.ws.rs.core.Response.Status的用法示例。


在下文中一共展示了Status.FORBIDDEN属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toResponse

@Override
public Response toResponse(AccessDeniedException exception) {

    Status status = Status.FORBIDDEN;

    ApiErrorDetails errorDetails = new ApiErrorDetails();
    errorDetails.setStatus(status.getStatusCode());
    errorDetails.setTitle(status.getReasonPhrase());
    errorDetails.setMessage("You don't have enough permissions to perform this action");
    errorDetails.setPath(uriInfo.getAbsolutePath().getPath());

    return Response.status(status).entity(errorDetails).type(MediaType.APPLICATION_JSON).build();
}
 
开发者ID:cassiomolin,项目名称:jersey-jwt-springsecurity,代码行数:13,代码来源:AccessDeniedExceptionMapper.java

示例2: toResponse

@Override
public Response toResponse(AuthenticationException exception) {

    Status status = Status.FORBIDDEN;

    ApiErrorDetails errorDetails = new ApiErrorDetails();
    errorDetails.setStatus(status.getStatusCode());
    errorDetails.setTitle(status.getReasonPhrase());
    errorDetails.setMessage(exception.getMessage());
    errorDetails.setPath(uriInfo.getAbsolutePath().getPath());

    return Response.status(status).entity(errorDetails).type(MediaType.APPLICATION_JSON).build();
}
 
开发者ID:cassiomolin,项目名称:jersey-jwt-springsecurity,代码行数:13,代码来源:AuthenticationExceptionMapper.java

示例3: toResponse

@Override
public Response toResponse(AuthenticationTokenRefreshmentException exception) {

    Status status = Status.FORBIDDEN;

    ApiErrorDetails errorDetails = new ApiErrorDetails();
    errorDetails.setStatus(status.getStatusCode());
    errorDetails.setTitle(status.getReasonPhrase());
    errorDetails.setMessage("The authentication token cannot be refreshed.");
    errorDetails.setPath(uriInfo.getAbsolutePath().getPath());

    return Response.status(status).entity(errorDetails).type(MediaType.APPLICATION_JSON).build();
}
 
开发者ID:cassiomolin,项目名称:jersey-jwt-springsecurity,代码行数:13,代码来源:AuthenticationTokenRefreshmentExceptionMapper.java

示例4: ensureTaxonomy

private Taxonomy ensureTaxonomy(String taxonomyUuid, PrivCheck pc)
{
	final Taxonomy taxonomy = taxonomyService.getByUuid(taxonomyUuid);
	if( taxonomy == null )
	{
		throw new WebApplicationException(Status.NOT_FOUND);
	}
	if( (pc == PrivCheck.VIEW && !taxonomyService.canView(taxonomy))
		|| (pc == PrivCheck.EDIT && !taxonomyService.canEdit(taxonomy))
		|| (pc == PrivCheck.DELETE && !taxonomyService.canDelete(taxonomy)) )
	{
		throw new WebApplicationException(Status.FORBIDDEN);
	}
	return taxonomy;
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:TaxonomyResource.java

示例5: validateCustomer

@POST
@Path("/validate")
@Consumes({"application/x-www-form-urlencoded"})
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid user information")})
public CustomerSessionInfo validateCustomer(@FormParam("sessionId") String sessionId) {
    logger.info("Received customer validation request with session id {}", sessionId);
    CustomerSession customerSession = customerService.validateSession(sessionId);
    if (customerSession != null) {
        logger.info("Found customer session {}", customerSession);
        return new CustomerSessionInfo(customerSession);
    }
    throw new InvocationException(Status.FORBIDDEN, "invalid token");
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:14,代码来源:LoginREST.java

示例6: toResponse

@Override
public Response toResponse(AccessDeniedException exception) {

    Status status = Status.FORBIDDEN;

    ApiErrorDetails errorDetails = new ApiErrorDetails();
    errorDetails.setStatus(status.getStatusCode());
    errorDetails.setTitle(status.getReasonPhrase());
    errorDetails.setMessage("You don't have enough permissions to perform this action.");
    errorDetails.setPath(uriInfo.getAbsolutePath().getPath());

    return Response.status(status).entity(errorDetails).type(MediaType.APPLICATION_JSON).build();
}
 
开发者ID:cassiomolin,项目名称:jersey-jwt,代码行数:13,代码来源:AccessDeniedExceptionMapper.java

示例7: toResponseSerializationException

/**
 * Simulate a serialization issue of thrown exception.
 */
@Test(expected = TechnicalException.class)
public void toResponseSerializationException() {
	final AbstractMapper mapper = new AbstractMapper() {

		@Override
		public Response toResponse(final Response.StatusType status, final Object object) {
			return super.toResponse(Status.FORBIDDEN, new NonSerializableObject());
		}

	};
	mapper.jacksonJsonProvider = new JacksonJsonProvider();
	mapper.toResponse(null, null);
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:16,代码来源:MapperTest.java

示例8: toResponse

@Override
public Response toResponse(AccessDeniedException exception) {
    // get the current user
    NiFiUser user = NiFiUserUtils.getNiFiUser();

    // if the user was authenticated - forbidden, otherwise unauthorized... the user may be null if the
    // AccessDeniedException was thrown from a /access endpoint that isn't subject to the security
    // filter chain. for instance, one that performs kerberos negotiation
    final Status status;
    if (user == null || user.isAnonymous()) {
        status = Status.UNAUTHORIZED;
    } else {
        status = Status.FORBIDDEN;
    }

    final String identity;
    if (user == null) {
        identity = "<no user found>";
    } else {
        identity = user.toString();
    }

    logger.info(String.format("%s does not have permission to access the requested resource. %s Returning %s response.", identity, exception.getMessage(), status));

    if (logger.isDebugEnabled()) {
        logger.debug(StringUtils.EMPTY, exception);
    }

    return Response.status(status)
            .entity(String.format("%s Contact the system administrator.", exception.getMessage()))
            .type("text/plain")
            .build();
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:33,代码来源:AccessDeniedExceptionMapper.java

示例9: ForbiddenException

public ForbiddenException() {
  super(Status.FORBIDDEN);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:3,代码来源:ForbiddenException.java

示例10: toResponse

@Test
public void toResponse() {
	jacksonJsonProvider = new JacksonJsonProvider();
	super.toResponse(Status.FORBIDDEN, null, new NullPointerException());
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:5,代码来源:MapperTest.java

示例11: forbidden

/**
 * Creates a builder for a forbidden request
 * 
 * @return the exception builder
 */
public static ExceptionBuilder forbidden() {
    return new ExceptionBuilder(Status.FORBIDDEN);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:8,代码来源:WebException.java


注:本文中的javax.ws.rs.core.Response.Status.FORBIDDEN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。