本文整理匯總了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();
}
示例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();
}
示例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;
}
示例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");
}
示例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();
}
示例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);
}
示例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();
}
示例9: ForbiddenException
public ForbiddenException() {
super(Status.FORBIDDEN);
}
示例10: toResponse
@Test
public void toResponse() {
jacksonJsonProvider = new JacksonJsonProvider();
super.toResponse(Status.FORBIDDEN, null, new NullPointerException());
}
示例11: forbidden
/**
* Creates a builder for a forbidden request
*
* @return the exception builder
*/
public static ExceptionBuilder forbidden() {
return new ExceptionBuilder(Status.FORBIDDEN);
}