当前位置: 首页>>代码示例>>Java>>正文


Java SecurityContextHolderAwareRequestWrapper.isUserInRole方法代码示例

本文整理汇总了Java中org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.isUserInRole方法的典型用法代码示例。如果您正苦于以下问题:Java SecurityContextHolderAwareRequestWrapper.isUserInRole方法的具体用法?Java SecurityContextHolderAwareRequestWrapper.isUserInRole怎么用?Java SecurityContextHolderAwareRequestWrapper.isUserInRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper的用法示例。


在下文中一共展示了SecurityContextHolderAwareRequestWrapper.isUserInRole方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: manageProblemI18N

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/manageproblemI18N.xhtml", method = RequestMethod.POST)
public String manageProblemI18N(Model model, SecurityContextHolderAwareRequestWrapper requestWrapper, Principal principal, HttpServletRequest request, Problem problem, BindingResult result) {
    Integer uid = problemDAO.integer("select.uid.by.username", getUsername(principal));
    if (!(requestWrapper.isUserInRole(Roles.ROLE_ADMIN) || requestWrapper.isUserInRole(Roles.ROLE_SUPER_PSETTER) || (problemDAO.bool("is.psetter.problem", uid, problem.getPid()) && requestWrapper
            .isUserInRole(Roles.ROLE_PSETTER)))) {
        return "/admin/adminproblems";
    }

    if (result.hasErrors()) {
        model.addAttribute(problem);
        return "/admin/manageproblemI18N";
    }

    problemDAO.updateProblemI18N(problem);

    problemDAO.log("editing problem I18N " + problem.getPid(), getUsername(principal));
    return "redirect:/24h/problem.xhtml?pid=" + problem.getPid();
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:19,代码来源:ProblemController.java

示例2: BestSolutions

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/24h/bestsolutions.xhtml", method = RequestMethod.GET)
public String BestSolutions(Locale locale, Principal principal,
		SecurityContextHolderAwareRequestWrapper requestWrapper,
		PagingOptions options, Model model, @RequestParam Integer pid) {
	Problem problem = problemDAO.getStatistics(locale.getLanguage(), pid);
	if (requestWrapper.isUserInRole(Roles.ROLE_USER)) {
		int uid = submissionDAO.integer("select.uid.by.username",
				getUsername(principal));
		problem.setSolved(problemDAO.bool("issolved.byuser", uid,
				problem.getPid()));
		if (problem.isSolved()) {
			problem.setLocked(problemDAO.isLocked(uid, problem.getPid()));
		}
	}
	model.addAttribute("problem", problem);
	return "/24h/bestsolutions";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:18,代码来源:SubmissionController.java

示例3: testBestSolutions

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/tables/bestsolutions.xhtml", method = RequestMethod.GET)
public String testBestSolutions(Locale locale, Principal principal,
		SecurityContextHolderAwareRequestWrapper requestWrapper,
		PagingOptions options, Model model, @RequestParam Integer pid) {
	Problem problem = problemDAO.getStatistics(locale.getLanguage(), pid);
	if (requestWrapper.isUserInRole(Roles.ROLE_USER)) {
		int uid = submissionDAO.integer("select.uid.by.username",
				getUsername(principal));
		problem.setSolved(problemDAO.bool("issolved.byuser", uid,
				problem.getPid()));
		if (problem.isSolved()) {
			problem.setLocked(problemDAO.isLocked(uid, problem.getPid()));
		}
	}
	int found = submissionDAO.countBestSolutions(pid);
	if (found != 0) {

		IPaginatedList<SubmissionJudge> submissions = submissionDAO
				.bestSolutions(pid, found, options, requestWrapper, problem);

		model.addAttribute("submissions", submissions);

	}
	return "/tables/bestsolutions";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:26,代码来源:SubmissionController.java

示例4: SourceView

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/24h/submission.xhtml", method = RequestMethod.GET)
public String SourceView(Principal principal,
		SecurityContextHolderAwareRequestWrapper requestWrapper,
		Model model, @RequestParam("id") Integer id) {
	try {
		if (!canAccessSubmission(principal, requestWrapper, id)) {
			return "/error/cancel";
		} else {
			SubmissionJudge submission = submissionDAO.getSourceCode(id);
			int uid = submissionDAO.integer("select.uid.by.username",
					getUsername(principal));
			if (!requestWrapper.isUserInRole(Roles.ROLE_ADMIN)
					&& !(submission.getUsername()
							.equals(getUsername(principal)))
					&& !(problemDAO.bool("issolved.byuser", uid,
							submission.getPid()) && problemDAO.isLocked(
							uid, submission.getPid()))) {
				throw new EmptyResultDataAccessException(0);
			}
			model.addAttribute("submission", submission);
		}
	} catch (EmptyResultDataAccessException ex) {
		return "/error/accessdenied";
	}
	return "/24h/submission";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:27,代码来源:SubmissionController.java

示例5: unfreezeContest

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/unlock.xhtml", method = RequestMethod.GET)
public String unfreezeContest(Model model,
                              SecurityContextHolderAwareRequestWrapper requestWrapper,
                              @RequestParam("cid") Integer cid) throws IOException {
    Contest contest = contestDAO.loadContest(cid);
    if (requestWrapper.isUserInRole(Roles.ROLE_ADMIN) && contest.isPast()) {
        // se cambian las banderas block y unfreeze auto del contest a
        // valores complementarios
        contestDAO.dml("update.freeze.blocked.contest", false, true, cid);
        contestDAO.repointContest(contest, false);
    }
    return "redirect:/contest/cscoreboard.xhtml?cid=" + cid;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:14,代码来源:ContestController.java

示例6: freezeContest

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/lock.xhtml", method = RequestMethod.GET)
public String freezeContest(Model model,
                            SecurityContextHolderAwareRequestWrapper requestWrapper,
                            @RequestParam("cid") Integer cid) throws IOException {
    Contest contest = contestDAO.loadContest(cid);
    if (requestWrapper.isUserInRole(Roles.ROLE_ADMIN) && contest.isPast()) {
        // se cambian las banderas block y unfreeze auto del contest a
        // valores complementarios
        contestDAO.freezeContest(contest);
    }
    return "redirect:/contest/cscoreboard.xhtml?cid=" + cid;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:13,代码来源:ContestController.java

示例7: canAccessSubmission

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
private boolean canAccessSubmission(Principal principal,
		SecurityContextHolderAwareRequestWrapper requestWrapper,
		int submit_id) {
	if (requestWrapper.isUserInRole(Roles.ROLE_ADMIN)) {
		return true;
	}
	if (principal == null) {
		return false;
	}
	return submissionDAO.bool("can.access.submission");
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:12,代码来源:SubmissionController.java

示例8: SourceDownload

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/24h/downloadsource.xhtml", method = RequestMethod.GET)
public String SourceDownload(Principal principal,
		SecurityContextHolderAwareRequestWrapper requestWrapper,
		HttpServletResponse response, Model model,
		@RequestParam("sid") Integer id) throws Exception {
	try {
		if (!canAccessSubmission(principal, requestWrapper, id)) {
			return "/error/cancel";
		} else {
			SubmissionJudge submission = submissionDAO.getSourceCode(id);
			int uid = submissionDAO.integer("select.uid.by.username",
					getUsername(principal));
			if (!requestWrapper.isUserInRole(Roles.ROLE_ADMIN)
					&& !(submission.getUsername()
							.equals(getUsername(principal)))
					&& !(problemDAO.bool("issolved.byuser", uid,
							submission.getPid()) && problemDAO.isLocked(
							uid, submission.getPid()))) {
				throw new EmptyResultDataAccessException(0);
			}
			response.setContentType(Config.getProperty("language.mime."
					+ submission.getLang()));
			response.setHeader("Content-disposition", "inline; filename="
					+ submission.getFilename());
			response.getOutputStream().write(
					submission.getCode().getBytes());
			response.getOutputStream().flush();
			return null;
		}
	} catch (EmptyResultDataAccessException ex) {
		return "/error/accessdenied";
	}
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:34,代码来源:SubmissionController.java

示例9: tablesGlobalContestScoreboartd

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@Deprecated
@RequestMapping(value = "/tables/globalcontestscoreboard.xhtml", method = RequestMethod.GET)
public String tablesGlobalContestScoreboartd(Locale locale, SecurityContextHolderAwareRequestWrapper requestWrapper, Model model, Principal principal, PagingOptions options,
		@RequestParam("cid") Integer cid) {

	Contest contest = contestDAO.loadContest(cid);
	if (contest.getStyle() == 4) {
		contest.setStyle(3);
	}
	if ((contest.isRunning() || contest.isPast()) && !contest.isRepointing()) {
		if (contest.isShow_scoreboard() || (principal != null && requestWrapper.isUserInRole(Roles.ROLE_ADMIN))) {
			contest.setShow_status(false);
			if (contest.isShow_scoreboard_out() || (principal != null && requestWrapper.isUserInRole(Roles.ROLE_ADMIN))
					|| (!contest.isShow_scoreboard_out() && principal != null && contestDAO.isInContest(cid, contestDAO.integer("users.uid", getUsername(principal))))) {
				contest.setShow_status(true);
				switch (contest.getStyle()) {
				case 1: {
					break;
				}
				case 3:
					IPaginatedList<User> users = contestDAO.getFreeContestRanking(cid, options);
					model.addAttribute("users", users);
					break;
				}
			}
		}
	}
	model.addAttribute("contest", contest);

	return "/tables/globalcontestscoreboard";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:32,代码来源:ContestScoreboardsController.java

示例10: manageProblem

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/manageproblem.xhtml", method = RequestMethod.POST)
public String manageProblem(Model model, SecurityContextHolderAwareRequestWrapper requestWrapper, Principal principal, HttpServletRequest request, Problem problem, BindingResult result, RedirectAttributes redirectAttributes) {

    // adicionar. el resto es modificar.
    if (problem.getPid() == null || problem.getPid() == 0) {
        String data = addProblem(model, principal, request, problem, result);
        //chequeo que haya insertado correctamente y valla a redireccionar para el listar para mostrar los flash
        if (data.equals("redirect:/admin/adminproblems.xhtml")) {
            redirectAttributes.addFlashAttribute("message", Notification.getSuccesfullCreate());
        }
        return data;
    }

    Integer uid = contestDAO.integer("select.uid.by.username", getUsername(principal));
    if (!(requestWrapper.isUserInRole(Roles.ROLE_ADMIN) || requestWrapper.isUserInRole(Roles.ROLE_SUPER_PSETTER) || (problemDAO.bool("is.psetter.problem", uid, problem.getPid()) && requestWrapper
            .isUserInRole(Roles.ROLE_PSETTER)))) {
        return "/admin/adminproblems";
    }

    validator.validate(problem, result);
    if (result.hasErrors()) {
        problemDAO.fillProblemLanguages(problem);
        problem.initLanguages();
        model.addAttribute("languages", utilDAO.getEnabledProgramingLanguages());
        model.addAttribute("contests", contestDAO.getComingAndRunningContests());
        model.addAttribute("sources", problemDAO.getProblemSources());
        model.addAttribute("psetters", utilDAO.objects("select.psetters.pid", User.class, problem.getPid()));
        model.addAttribute(problem);
        /*model.addAttribute("showpsetters", (requestWrapper.isUserInRole(Roles.ROLE_ADMIN) && requestWrapper.isUserInRole(Roles.ROLE_ADMIN)) || principal.getName().equals(problem.getUsername()));
        model.addAttribute("create", false);*/
        return "/admin/manageproblem";
    }

    if (!problem.isMultidata()) {
        problem.setCasetimelimit(problem.getTime());
    }

    problemDAO.updateProblem(problem);
    problemDAO.clearProgrammingLanguages(problem.getPid());
    if (problem.getLanguageids() != null) {
        for (int i = 0; i < problem.getLanguageids().length; i++) {
            problemDAO.insertProblemLanguage(problem.getPid(), problem.getLanguageids()[i]);
        }
    }
    // solo los admins pueden asignar nuevos problemsetters
    if (requestWrapper.isUserInRole(Roles.ROLE_ADMIN) || requestWrapper.isUserInRole(Roles.ROLE_SUPER_PSETTER) || (requestWrapper.isUserInRole(Roles.ROLE_PSETTER) && principal.getName().equals(problemDAO.creatorUsernameByPid(problem.getPid())))) {
        problemDAO.clearPsetters(problem.getPid());
        if (problem.getPsettersids() != null) {
            for (int i = 0; i < problem.getPsettersids().length; i++) {
                problemDAO.dml("insert.psetter.pid", problem.getPsettersids()[i], problem.getPid());
            }
        }
    }

    if (problem.getContest() != 0) {
        int pOrder = contestDAO.integer("contest.problem.order", problem.getContest());
        contestDAO.insertProblemContest(problem.getPid(), problem.getContest(), 1, pOrder + 1);
    }

    if (problem.getLimits() != null) {
        problemDAO.clearLimits(problem.getPid());
        for (Limits limits : problem.getLimits()) {
            limits.setProblemId(problem.getPid());
            problemDAO.insertLimit(limits);
        }
    }
    handleFiles(problem, request);

    problemDAO.log("editing problem " + problem.getPid(), getUsername(principal));
    //return "redirect:/24h/problem.xhtml?pid=" + problem.getPid();
    redirectAttributes.addFlashAttribute("message", Notification.getSuccesfullUpdate());
    return "redirect:/admin/adminproblems.xhtml";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:74,代码来源:ProblemController.java

示例11: SubmitController

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@RequestMapping(value = "/24h/submit.xhtml", method = RequestMethod.GET)
public String SubmitController(
		Principal principal,
		SecurityContextHolderAwareRequestWrapper requestWrapper,
		Model model,
		@RequestParam(required = false, value = "pid") Integer pid,
		@RequestParam(required = false, defaultValue = "0", value = "sid") Integer sid) {
	SubmissionJudge submit = new SubmissionJudge();
	Language language = userDAO
			.getProgrammingLanguageByUsername(getUsername(principal));
	submit.setPid(pid == null ? 0 : pid);
	if (sid != 0) {
		SubmissionJudge submission = submissionDAO.getSourceCode(sid);
		int uid = userDAO.integer("select.uid.by.username",
				getUsername(principal));
		if (!requestWrapper.isUserInRole(Roles.ROLE_ADMIN)
				&& !(submission.getUsername()
						.equals(getUsername(principal)))
				&& !(problemDAO.bool("issolved.byuser", uid,
						submission.getPid()) && problemDAO.isLocked(uid,
						submission.getPid()))) {
		} else {
			submit.setCode(submission.getCode());
			submit.setPid(submission.getPid());
			submit.setLid(submission.getLid());
			submit.setKey(submission.getKey());
		}

	} else {
		submit.setLid(language.getLid());
		submit.setKey(language.getKey());
	}
	List<Language> languages = new LinkedList<Language>();

	try {
		if (problemDAO.exists(submit.getPid())) {
			languages.addAll(utilDAO.getEnabledLanguagesByProblem(submit
					.getPid()));
		} else {
			languages.addAll(utilDAO.getEnabledLanguagesByProblem(null));
		}
	} catch (EmptyResultDataAccessException e) {
	}
	submit.setLanguages(languages);
	model.addAttribute("languages", languages);
	if (getUsername(principal) != null) {
		model.addAttribute("enableadveditor",
				userDAO.bool("is.adved.enable", getUsername(principal)));
	}
	model.addAttribute("submit", submit);
	return "/24h/submit";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:53,代码来源:SubmissionController.java

示例12: GlobalContestScoreboartd

import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper; //导入方法依赖的package包/类
@Deprecated
@RequestMapping(value = "/contest/globalcontestscoreboard.xhtml", method = RequestMethod.GET)
public String GlobalContestScoreboartd(Locale locale, SecurityContextHolderAwareRequestWrapper requestWrapper, Model model, Principal principal, PagingOptions options,
		@RequestParam("cid") Integer cid, @RequestParam(required = false, value = "ungroup") String ungroup) {

	Contest contest = contestDAO.loadContest(cid);
	if (contest.isComing()) {
		return "redirect:/contest/contestview.xhtml?cid=" + cid;
	}
	if (contest.getStyle() == 4) {
		contest.setStyle(3);
	}
	if ((contest.isRunning() || contest.isPast()) && !contest.isRepointing()) {
		if (contest.isShow_scoreboard() || (principal != null && requestWrapper.isUserInRole(Roles.ROLE_ADMIN))) {
			contest.setShow_status(false);
			if (contest.isShow_scoreboard_out() || (principal != null && requestWrapper.isUserInRole(Roles.ROLE_ADMIN))
					|| (!contest.isShow_scoreboard_out() && principal != null && contestDAO.isInContest(cid, contestDAO.integer("users.uid", getUsername(principal))))) {
				contest.setShow_status(true);
				switch (contest.getStyle()) {
				case 1: {
					List<Problem> problems = problemDAO.getContestProblems(locale.getLanguage(), cid);
					int[] ids = new int[] { 1213, 1200, 1199, 1192, 1196, 1214, 1212, 1204, 1193, 1178, 1206, 1202, 1211, 1195, 1208, 1187, 1209, 1198, 1210, 1205, 1191, 1207, 1194 };
					List<Integer> cids = new LinkedList<Integer>();
					for (int i = 0; i < ids.length; i++) {
						int j = ids[i];
						cids.add(j);
					}
					int[] minimums = contestDAO.getGlobalRankingAcmMinimun(cids);
					int min = minimums[0];
					for (int i = 1; i < minimums.length; i++) {
						if (minimums[i] < min) {
							min = minimums[i];
						}
					}

					IACMScoreboard iacmscoreboard = contestDAO.getGlobalRankingAcm(cids, ungroup != null, problems);
					for (int i = 0; i < problems.size(); i++) {
						problems.get(i).stats();
					}

					if (ungroup != null) {
						setMedals(iacmscoreboard.getUsers(), contest, 0);
						model.addAttribute("users", iacmscoreboard.getUsers());
					} else {
						model.addAttribute("group", true);
						for (int i = 0; i < iacmscoreboard.getGroups().size(); i++) {
							setMedals(iacmscoreboard.getGroups().get(i).getUsers(), contest, 0);
						}
						model.addAttribute("groups", iacmscoreboard.getGroups());
					}
					model.addAttribute("problems", problems);
					break;
				}
				case 3:
					IPaginatedList<User> users = contestDAO.getFreeContestRanking(cid, options);
					model.addAttribute("users", users);
					break;
				}
			}
		}
	}
	model.addAttribute("contest", contest);

	return "/contest/globalcontestscoreboard";
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:66,代码来源:ContestScoreboardsController.java


注:本文中的org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.isUserInRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。