Search in sources :

Example 21 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project nhin-d by DirectProject.

the class DomainController method updateBundleDirection.

@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/updateBundleDirection", method = RequestMethod.POST)
public ModelAndView updateBundleDirection(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, @RequestParam(required = true) String domainName, @RequestParam(required = true) String bundle, @RequestParam(required = true) String direction, @RequestParam(required = true) String directionValue, HttpSession session, Model model) {
    Collection<TrustBundleDomainReltn> bundles = null;
    try {
        bundles = bundleService.getTrustBundlesByDomain(domainName, false);
    } catch (ServiceException ex) {
        Logger.getLogger(DomainController.class.getName()).log(Level.SEVERE, null, ex);
    }
    for (TrustBundleDomainReltn bundleReltn : bundles) {
        if (bundleReltn.getId() == Long.parseLong(bundle)) {
            if (direction.toLowerCase().equals("incoming")) {
                if (Integer.parseInt(directionValue) == 1) {
                    bundleReltn.setIncoming(true);
                } else {
                    bundleReltn.setIncoming(false);
                }
            } else {
                if (Integer.parseInt(directionValue) == 1) {
                    bundleReltn.setOutgoing(true);
                } else {
                    bundleReltn.setOutgoing(false);
                }
            }
        }
    }
    final ModelAndView mav = new ModelAndView();
    mav.setViewName("updateBundleDirection");
    return mav;
}
Also used : ServiceException(org.nhindirect.common.rest.exceptions.ServiceException) ConfigurationServiceException(org.nhindirect.config.service.ConfigurationServiceException) ModelAndView(org.springframework.web.servlet.ModelAndView) TrustBundleDomainReltn(org.nhindirect.config.model.TrustBundleDomainReltn) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 22 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project SI2016_TIM6 by SoftverInzenjeringETFSA.

the class PrijavaController method prijaviIspit.

@PreAuthorize("hasAnyRole('ROLE_STUDENT')")
@PostMapping(path = "/prijavi")
public void prijaviIspit(@ModelAttribute("prijava") Prijava p, Principal principal) throws Exception {
    Student s = studentService.findByUsername(principal.getName());
    prijavaService.SavePrijava(p, s);
}
Also used : Student(ba.isss.models.Student) PostMapping(org.springframework.web.bind.annotation.PostMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 23 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project SI2016_TIM6 by SoftverInzenjeringETFSA.

the class PrijavaController method odjaviIspit.

@PreAuthorize("hasAnyRole('ROLE_STUDENT')")
@RequestMapping(path = "/odjavi", method = RequestMethod.POST)
@ResponseBody
public void odjaviIspit(@ModelAttribute("odjava") Prijava p, Principal principal) throws Exception {
    Student s = studentService.findByUsername(principal.getName());
    prijavaService.DeletePrijava(p, s);
}
Also used : Student(ba.isss.models.Student) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 24 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.

the class DeckController method edit.

@RequestMapping(value = "/card/{id}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView edit(@PathVariable("id") Long id) {
    ModelAndView model = new ModelAndView("editarCarta");
    model.addObject("card", cardService.getById(id));
    return model;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 25 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.

the class DeckController method update.

@PostMapping(value = "/card/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView update(@PathVariable("id") Long id, @RequestParam("photo") MultipartFile photoFile, @RequestParam("name") String name, @RequestParam("type") String type) {
    String cardSrc = "";
    try {
        if (photoFile.getBytes().length != 0) {
            cardSrc = photosFile.createFile(photoFile);
        } else {
            cardSrc = cardService.getById(id).getCardSrc();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    CardRequest cardRequest = new CardRequest(name, type, cardSrc);
    Long themeId = (Long) session.getAttribute("theme");
    cardService.update(id, cardRequest);
    return listAll(themeId);
}
Also used : CardRequest(br.fatecsp.engsoft.domain.CardRequest) IOException(java.io.IOException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)188 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)174 ModelAndView (org.springframework.web.servlet.ModelAndView)51 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)39 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)36 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)34 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)32 IOException (java.io.IOException)29 InputStream (java.io.InputStream)23 ArrayList (java.util.ArrayList)23 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)23 ConfigurationServiceException (org.nhindirect.config.service.ConfigurationServiceException)21 Date (java.util.Date)15 Grid (org.hisp.dhis.common.Grid)14 SearchDomainForm (org.nhindirect.config.ui.form.SearchDomainForm)14 ApiOperation (io.swagger.annotations.ApiOperation)13 ApiResponses (io.swagger.annotations.ApiResponses)13 Configuration (org.hisp.dhis.configuration.Configuration)13 HttpHeaders (org.springframework.http.HttpHeaders)13 List (java.util.List)12