本文整理汇总了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);
}