Java Code Examples for javax.servlet.http.HttpServletRequest.isUserInRole()

The following are Jave code examples for showing how to use isUserInRole() of the javax.servlet.http.HttpServletRequest class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: IndexAction.java   View Source Code Vote up 6 votes
private static void setHeaderLinks(HttpServletRequest request) {
List<IndexLinkBean> headerLinks = new ArrayList<IndexLinkBean>();
if (request.isUserInRole(Role.AUTHOR)) {
    if (isPedagogicalPlannerAvailable()) {
	headerLinks.add(new IndexLinkBean("index.planner", "javascript:openPedagogicalPlanner()"));
    }
    headerLinks.add(new IndexLinkBean("index.author", "javascript:showAuthoringDialog()"));
}

String customTabText = Configuration.get(ConfigurationKeys.CUSTOM_TAB_TITLE);
String customTabLink = Configuration.get(ConfigurationKeys.CUSTOM_TAB_LINK);
if (customTabLink != null && customTabLink.trim().length() > 0) {
    headerLinks.add(new IndexLinkBean(customTabText, "javascript:openCustom(\"" + customTabLink + "\")"));
}

request.setAttribute("headerLinks", headerLinks);
   }
 
Example 2
Project: lams   File: OrganisationAction.java   View Source Code Vote up 6 votes
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {
OrganisationAction.service = AdminServiceProxy.getService(getServlet().getServletContext());
initLocalesAndStatus();
DynaActionForm orgForm = (DynaActionForm) form;

if (!(request.isUserInRole(Role.SYSADMIN) || OrganisationAction.service.isUserGlobalGroupAdmin())) {
    // only sysadmins and global group admins can create groups
    if (((orgForm.get("typeId") != null) && orgForm.get("typeId").equals(OrganisationType.COURSE_TYPE))
	    || (orgForm.get("typeId") == null)) {
	return error(mapping, request);
    }
}

// creating new organisation
orgForm.set("orgId", null);
Integer parentId = WebUtil.readIntParam(request, "parentId", true);
if (parentId != null) {
    Organisation parentOrg = (Organisation) OrganisationAction.service.findById(Organisation.class, parentId);
    orgForm.set("parentName", parentOrg.getName());
}
request.getSession().setAttribute("locales", OrganisationAction.locales);
request.getSession().setAttribute("status", OrganisationAction.status);
return mapping.findForward("organisation");
   }
 
Example 3
Project: lams   File: UserAction.java   View Source Code Vote up 6 votes
public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {

initServices();

if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
    request.setAttribute("errorName", "UserAction");
    request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
    return mapping.findForward("error");
}

Integer userId = WebUtil.readIntParam(request, "userId", true);
User user = (User) service.findById(User.class, userId);

UserAction.log.debug("enabling user: " + userId);
user.setDisabledFlag(false);
service.saveUser(user);

return mapping.findForward("disabledlist");
   }
 
Example 4
Project: SaleWeb   File: SaleWebController.java   View Source Code Vote up 5 votes
@GetMapping("/articulo/comentario/{id}")
public String verComentario(Model model, @PathVariable long id, HttpServletRequest request, HttpSession sesion){
	
	Comentario comentario = comentario_repository.findOne(id);
	Boolean permitoEliminar = ((request.isUserInRole("ROLE_ADMIN")) || 
								(comentario.getAutor().getEmail().equals((String) sesion.getAttribute("email"))));
	model.addAttribute("botonEliminar", permitoEliminar);
	model.addAttribute("comentario", comentario);
	return "ver_comentario";
}
 
Example 5
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 6
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@GetMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 7
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 8
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return redirect.apply("/events/");
    }
    return redirect.apply("/");
}
 
Example 9
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 10
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 11
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@GetMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 12
Project: lams   File: InsertTag.java   View Source Code Vote up 5 votes
/**
 * Create a new empty context.
 */
public int doStartTag() throws JspException {
	// Check role
	HttpServletRequest request =
		(HttpServletRequest) pageContext.getRequest();

	if (role != null && !request.isUserInRole(role)) {
		return SKIP_BODY;
	}

	// save current context
	this.currentContext = getCurrentContext();
	return EVAL_BODY_INCLUDE;
}
 
Example 13
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 14
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return redirect.apply("/events/");
    }
    return redirect.apply("/");
}
 
Example 15
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@GetMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 16
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 17
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@GetMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 18
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 19
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@GetMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
Example 20
Project: Spring-Security-Third-Edition   File: DefaultController.java   View Source Code Vote up 5 votes
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}