當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletRequest.isUserInRole方法代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletRequest.isUserInRole方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.isUserInRole方法的具體用法?Java HttpServletRequest.isUserInRole怎麽用?Java HttpServletRequest.isUserInRole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.isUserInRole方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setHeaderLinks

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
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);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:IndexAction.java

示例2: create

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
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");
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:OrganisationAction.java

示例3: enable

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
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");
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:UserAction.java

示例4: verComentario

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@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";
}
 
開發者ID:jeche21,項目名稱:SaleWeb,代碼行數:11,代碼來源:SaleWebController.java

示例5: defaultAfterLogin

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:8,代碼來源:DefaultController.java

示例6: defaultAfterLogin

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@GetMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:8,代碼來源:DefaultController.java

示例7: defaultAfterLogin

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ROLE_ADMIN")) {
        return redirect.apply("/events/");
    }
    return redirect.apply("/");
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:8,代碼來源:DefaultController.java

示例8: doStartTag

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:InsertTag.java

示例9: defaultAfterLogin

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
    if (request.isUserInRole("ADMIN")) {
        return "redirect:/events/";
    }
    return "redirect:/";
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:8,代碼來源:DefaultController.java


注:本文中的javax.servlet.http.HttpServletRequest.isUserInRole方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。