本文整理匯總了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);
}
示例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");
}
示例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");
}
示例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";
}
示例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:/";
}
示例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:/";
}
示例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("/");
}
示例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;
}
示例9: defaultAfterLogin
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping("/default")
public String defaultAfterLogin(HttpServletRequest request) {
if (request.isUserInRole("ADMIN")) {
return "redirect:/events/";
}
return "redirect:/";
}