當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。