Example usage for org.springframework.http HttpStatus FORBIDDEN

List of usage examples for org.springframework.http HttpStatus FORBIDDEN

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus FORBIDDEN.

Prototype

HttpStatus FORBIDDEN

To view the source code for org.springframework.http HttpStatus FORBIDDEN.

Click Source Link

Document

403 Forbidden .

Usage

From source file:de.sainth.recipe.backend.security.SecurityTokenAdapter.java

private AuthenticationEntryPoint getAuthenticationEntryPoint() {
    return (request, response, authException) -> response.sendError(HttpStatus.FORBIDDEN.value(),
            authException.getMessage());
}

From source file:ca.hec.tenjin.tool.controller.ImportController.java

@ExceptionHandler(DeniedAccessException.class)
@ResponseStatus(value = HttpStatus.FORBIDDEN)
public @ResponseBody Object handlePermissionException(DeniedAccessException ex) {
    return null;//from  www. j  a v a  2 s . c  o m
}

From source file:com.redblackit.war.AppSecurityRestControllerTest.java

/**
 * Test PUT method for human page about (should get 403)
 * {@link com.redblackit.web.controller.AdminRestController#getVersion()}
 * with https./*from   www .  j  av  a2  s .co m*/
 */
@Test
public void testPutAbout() {
    helper.doPutForHttpStatusCodeException(inaccessibleUrl, "About", null, "inaccessible URL for REST",
            HttpStatus.FORBIDDEN);
}

From source file:de.petendi.ethereum.secure.proxy.controller.SecureController.java

@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/{fingerprint}")
public ResponseEntity<EncryptedMessage> post(@PathVariable("fingerprint") String fingerPrint,
        @RequestBody EncryptedMessage encryptedMessage) {

    IO.UnencryptedResponse unencryptedResponse = new IO.UnencryptedResponse() {
        @Override//w w w .  j  a  v a  2  s  .  c  o m
        public byte[] getUnencryptedResponse(byte[] bytes, String s, String s1) {
            return SecureController.this.dispatch(bytes).getBytes();
        }
    };
    try {
        EncryptedMessage encrypted = seccoco.io().dispatch(fingerPrint, encryptedMessage, unencryptedResponse);
        return new ResponseEntity<EncryptedMessage>(encrypted, HttpStatus.OK);
    } catch (IO.RequestException e) {
        HttpStatus status;
        if (e instanceof IO.CertificateNotFoundException) {
            status = HttpStatus.FORBIDDEN;
        } else if (e instanceof IO.SignatureCheckFailedException) {
            status = HttpStatus.UNAUTHORIZED;
        } else if (e instanceof IO.InvalidInputException) {
            status = HttpStatus.BAD_REQUEST;
        } else {
            status = HttpStatus.INTERNAL_SERVER_ERROR;
        }
        return new ResponseEntity<EncryptedMessage>(status);
    }
}

From source file:org.smigo.comment.CommentHandler.java

public HttpStatus removeComment(int id, AuthenticatedUser user) {
    List<Comment> comments = commentDao.getComments(user.getUsername());
    boolean isReceiver = comments.stream().anyMatch(comment -> comment.getId() == id);
    if (user.isModerator() || isReceiver) {
        commentDao.deleteComment(id);/*from  w  ww  . j  av  a  2s  .co  m*/
        return HttpStatus.OK;
    }
    return HttpStatus.FORBIDDEN;
}

From source file:app.api.swagger.SwaggerConfig.java

private List<ResponseMessage> defaultGetResponses() {
    final List<ResponseMessage> results = new ArrayList<ResponseMessage>();
    results.add(response(HttpStatus.FORBIDDEN, null));
    results.add(response(HttpStatus.UNAUTHORIZED, null));
    results.add(response(HttpStatus.NOT_FOUND, null));
    return results;
}

From source file:org.esupportail.papercut.web.PayBoxCallbackController.java

/** 
 * Manage callback response from paybox - url like :  
 * /*from   w  w w  . j av  a  2 s . co m*/
 * /payboxcallback?montant=200&reference=bonamvin@univrouen@200-2013-08-23-17-08-18-394&auto=XXXXXX&erreur=00000&idtrans=3608021&signature=CPqq18Un24NL0llB3E3G9kbKI4ztlkoL%2BSRTnMMrWlPBTVNTsn%2B%2FxA0YMSQOGGnU0wm45HYh%2F2RHoZGG3THzj7xKSY6upNJcnKrfFmzfTgA5FTFA3dyM27RgKmLcCeH48FRNoZPjVsKk0G2npvaP%2FY5pkSvn%2BQUl34DkmJkTejs%3D
 *
 * @param uiModel
 * @return empty page
 */
@RequestMapping("/payboxcallback")
@ResponseBody
public ResponseEntity<String> index(@RequestParam String montant, @RequestParam String reference,
        @RequestParam(required = false) String auto, @RequestParam String erreur, @RequestParam String idtrans,
        @RequestParam String signature, HttpServletRequest request) {

    String paperCutContext = reference.split("@")[1];
    String ip = request.getRemoteAddr();
    String queryString = request.getQueryString();

    if (esupPaperCutServices.get(paperCutContext).payboxCallback(montant, reference, auto, erreur, idtrans,
            signature, queryString, ip, null)) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "text/html; charset=utf-8");
        return new ResponseEntity<String>("", headers, HttpStatus.OK);
    } else {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "text/html; charset=utf-8");
        return new ResponseEntity<String>("", headers, HttpStatus.FORBIDDEN);
    }
}

From source file:com.chevres.rss.restapi.controller.UserController.java

@CrossOrigin
@RequestMapping(path = "/user/{username}", method = RequestMethod.GET)
@ResponseBody/* www .j a v a 2 s  .  c om*/
public ResponseEntity<String> getUser(@RequestHeader(value = "User-token") String userToken,
        @PathVariable String username) {

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
    UserDAO userDAO = context.getBean(UserDAO.class);
    UserAuthDAO userAuthDAO = context.getBean(UserAuthDAO.class);

    UserAuth userAuth = userAuthDAO.findByToken(userToken);
    if (userAuth == null) {
        context.close();
        return new ResponseEntity(new ErrorMessageResponse("invalid_token"), HttpStatus.BAD_REQUEST);
    }

    User user = userDAO.findByUsername(username);
    if (user == null) {
        context.close();
        return new ResponseEntity(HttpStatus.NOT_FOUND);
    }

    boolean isAdmin = userDAO.isAdmin(userAuth.getIdUser());
    if (!isAdmin && (userAuth.getIdUser() != user.getId())) {
        return new ResponseEntity(new ErrorMessageResponse("admin_required"), HttpStatus.FORBIDDEN);
    }

    context.close();

    return new ResponseEntity(new SuccessGetUserResponse(user.getUsername(), user.getType()), HttpStatus.OK);
}

From source file:de.sainth.recipe.backend.security.SecurityTokenAdapter.java

private AccessDeniedHandler getAccessDeniedHandler() {
    return (request, response, accessDeniedException) -> response.sendError(HttpStatus.FORBIDDEN.value(),
            accessDeniedException.getMessage());
}

From source file:io.fourfinanceit.homework.controller.LoanControler.java

@RequestMapping(value = "/loan", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<LoanApplication> createLoanApplication(@RequestBody LoanApplication loanApplication,
        HttpServletRequest request) {//from   ww  w. ja v  a2s.c om

    loanApplication.setIpAddress(ipAddressDefiner.getIpAddress(request));

    LoanApplication savedLoanApplication = loanApplicationRepository.save(loanApplication);
    if (savedLoanApplication.getStatus() == LoanApplicationStatusEnum.ACTIVE.getStatus()) {
        return new ResponseEntity<LoanApplication>(savedLoanApplication, HttpStatus.CREATED);
    } else {
        return new ResponseEntity<LoanApplication>(savedLoanApplication, HttpStatus.FORBIDDEN);
    }
}