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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations