Java Code Examples for org.eclipse.jetty.http.HttpStatus#UNAUTHORIZED_401

The following examples show how to use org.eclipse.jetty.http.HttpStatus#UNAUTHORIZED_401 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JwtFilterTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public boolean matches(Object o) {
    if (o instanceof HaltException) {
        HaltException haltException = (HaltException) o;
        return haltException.statusCode() == HttpStatus.UNAUTHORIZED_401;
    }
    return false;
}
 
Example 2
Source File: UserMailboxesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@GET
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path")
})
@ApiOperation(value = "Listing all mailboxes of user.")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "The list of mailboxes", response = String.class),
        @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform", response = String.class),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineGetUserMailboxes() {
    service.get(USER_MAILBOXES_BASE, (request, response) -> {
        response.status(HttpStatus.OK_200);
        try {
            return userMailboxesService.listMailboxes(getUsernameParam(request));
        } catch (IllegalStateException e) {
            LOGGER.info("Invalid get on user mailboxes", e);
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.NOT_FOUND_404)
                .type(ErrorType.NOT_FOUND)
                .message("Invalid get on user mailboxes")
                .cause(e)
                .haltError();
        }
    }, jsonTransformer);
}
 
Example 3
Source File: UserMailboxesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path")
})
@ApiOperation(value = "Deleting user mailboxes.")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The user does not have any mailbox", response = String.class),
        @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform"),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteUserMailboxes() {
    service.delete(USER_MAILBOXES_BASE, (request, response) -> {
        try {
            userMailboxesService.deleteMailboxes(getUsernameParam(request));
            return Responses.returnNoContent(response);
        } catch (IllegalStateException e) {
            LOGGER.info("Invalid delete on user mailboxes", e);
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.NOT_FOUND_404)
                .type(ErrorType.NOT_FOUND)
                .message("Invalid delete on user mailboxes")
                .cause(e)
                .haltError();
        }
    });
}