public ActionForward transferEnrollments( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final DynaActionForm dynaActionForm = (DynaActionForm) form; final String selectedStudentCurricularPlanIdString = (String) dynaActionForm.get("selectedStudentCurricularPlanId"); final String selectedCurriculumGroupID = (String) dynaActionForm.get("selectedCurriculumGroupID"); final String[] enrollmentStringIDsToTransfer = (String[]) dynaActionForm.get("enrollmentIDsToTransfer"); if (isPresent(selectedStudentCurricularPlanIdString) && enrollmentStringIDsToTransfer != null && enrollmentStringIDsToTransfer.length > 0) { final User userView = Authenticate.getUser(); TransferEnrollments.run( selectedStudentCurricularPlanIdString, enrollmentStringIDsToTransfer, selectedCurriculumGroupID); } return show(mapping, form, request, response); }
public ActionForward showTeacherCredits( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NumberFormatException, FenixServiceException, ParseException { DynaActionForm teacherCreditsForm = (DynaActionForm) form; ExecutionSemester executionSemester = FenixFramework.getDomainObject((String) teacherCreditsForm.get("executionPeriodId")); Teacher requestedTeacher = FenixFramework.getDomainObject((String) teacherCreditsForm.get("teacherId")); User userView = Authenticate.getUser(); Teacher loggedTeacher = userView.getPerson().getTeacher(); if (requestedTeacher == null || loggedTeacher != requestedTeacher) { ActionMessages actionMessages = new ActionMessages(); actionMessages.add("", new ActionMessage("message.invalid.teacher")); saveMessages(request, actionMessages); return mapping.findForward("teacher-not-found"); } showLinks(request, executionSemester, RoleType.DEPARTMENT_MEMBER); getAllTeacherCredits(request, executionSemester, requestedTeacher); return mapping.findForward("show-teacher-credits"); }
private SupportRequestBean userInfoContextAppend( HttpServletRequest request, final StringBuilder exceptionInfo) { exceptionInfo.append("[UserLoggedIn] "); SupportRequestBean requestBean; String user; User userView = Authenticate.getUser(); if (userView != null) { user = userView.getUsername(); requestBean = SupportRequestBean.generateExceptionBean(userView.getPerson()); MenuFunctionality selectedFunctionality = BennuPortalDispatcher.getSelectedFunctionality(request); if (selectedFunctionality != null) { requestBean.setSelectedFunctionality(selectedFunctionality); } setUserName(user); Set<RoleType> roles = new HashSet<RoleType>(); for (Role role : userView.getPerson().getPersonRolesSet()) { roles.add(role.getRoleType()); } setUserRoles(roles); } else { user = "******"; requestBean = SupportRequestBean.generateExceptionBean(null); } exceptionInfo.append(user + "\n"); return requestBean; }
private Spreadsheet buildReport( final Degree degree, final SortedSet<SecondCycleIndividualCandidacyProcess> name) { final Spreadsheet spreadsheet = new Spreadsheet(degree.getSigla(), getHeader()); for (final SecondCycleIndividualCandidacyProcess process : name) { if (!process.canExecuteActivity(Authenticate.getUser())) { continue; } final Row row = spreadsheet.addRow(); row.setCell(process.getPersonalDetails().getName()); row.setCell(process.getPrecedentDegreeInformation().getConclusionGrade()); row.setCell(process.getCandidacyProfessionalExperience()); row.setCell(process.getPrecedentDegreeInformation().getDegreeAndInstitutionName()); row.setCell(process.getCandidacyAffinity()); row.setCell(process.getCandidacyDegreeNature()); row.setCell(process.getCandidacyGrade()); row.setCell( process.getCandidacyInterviewGrade() != null ? process.getCandidacyInterviewGrade() : " "); row.setCell(process.getCandidacySeriesGrade()); if (process.isCandidacyAccepted() || process.isCandidacyRejected()) { row.setCell( BundleUtil.getString( Bundle.ENUMERATION, process.getCandidacyState().getQualifiedName())); } else { row.setCell(" "); } } return spreadsheet; }
public void execute(Summary summary, Professorship professorshipLogged) throws NotAuthorizedException { try { User userViewLogged = Authenticate.getUser(); boolean executionCourseResponsibleLogged = professorshipLogged.isResponsibleFor(); if (userViewLogged == null || userViewLogged.getPerson().getPersonRolesSet() == null || professorshipLogged == null) { throw new NotAuthorizedException("error.summary.not.authorized"); } if (executionCourseResponsibleLogged && (summary.getProfessorship() != null && (!summary.getProfessorship().equals(professorshipLogged)))) { throw new NotAuthorizedException("error.summary.not.authorized"); } else if (!executionCourseResponsibleLogged && (summary.getProfessorship() == null || (!summary.getProfessorship().equals(professorshipLogged)))) { throw new NotAuthorizedException("error.summary.not.authorized"); } } catch (RuntimeException ex) { throw new NotAuthorizedException("error.summary.not.authorized"); } }
private void renderCMSPage( final HttpServletRequest req, HttpServletResponse res, Site sites, String pageSlug) throws ServletException, IOException, PebbleException { if (pageSlug.startsWith("/")) { pageSlug = pageSlug.substring(1); } String[] parts = pageSlug.split("/"); String pageName = parts[0]; Page page; if (Strings.isNullOrEmpty(pageName) && sites.getInitialPage() != null) { page = sites.getInitialPage(); } else { page = sites .getPagesSet() .stream() .filter(p -> pageName.equals(p.getSlug())) .findAny() .orElse(null); } if (page == null || page.getTemplate() == null) { errorPage(req, res, sites, 404); } else if (!page.isPublished() || !page.getCanViewGroup().isMember(Authenticate.getUser())) { errorPage(req, res, sites, 404); } else { try { renderPage(req, pageSlug, res, sites, page, parts); } catch (ResourceNotFoundException e) { errorPage(req, res, sites, 404); } } }
@Override protected void process(final ActivityInformation<MissionProcess> activityInformation) { final User user = Authenticate.getUser(); final Person person = user.getPerson(); final MissionProcess missionProcess = activityInformation.getProcess(); missionProcess.unAllocateFunds(person); }
@Atomic public void createNewPeriod() { final User userView = Authenticate.getUser(); if (userView != null && RoleType.MANAGER.isMember(userView.getPerson().getUser())) { if (title != null && title.hasContent() && start != null && end != null) { new GenericApplicationPeriod(title, description, start, end); } } }
public static boolean getGrantAccess() { final User user = Authenticate.getUser(); if (user != null) { final int year = Year.now().getValue(); final CgdCard card = findCardFor(user, year, false); return card != null && card.getAllowSendDetails(); } return false; }
protected void putStudentCurricularInformationInRequest( final HttpServletRequest request, final Integer studentNumber, final DegreeType degreeType) throws FenixServiceException { final User userView = Authenticate.getUser(); final List infoStudentCurricularPlans = ReadStudentCurricularInformation.run(studentNumber, degreeType); request.setAttribute("infoStudentCurricularPlans", infoStudentCurricularPlans); }
public ActionForward backToShowInformation( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { final Person person = Authenticate.getUser().getPerson(); request.setAttribute("personBean", new PersonBean(person)); EmergencyContactBean emergencyContactBean = new EmergencyContactBean(person); request.setAttribute("emergencyContactBean", emergencyContactBean); return mapping.findForward("visualizePersonalInformation"); }
/** * Method setExecutionContext. * * @param request */ private InfoExecutionPeriod setExecutionContext(HttpServletRequest request) throws Exception { InfoExecutionPeriod infoExecutionPeriod = (InfoExecutionPeriod) request.getAttribute(PresentationConstants.INFO_EXECUTION_PERIOD_KEY); if (infoExecutionPeriod == null) { User userView = Authenticate.getUser(); infoExecutionPeriod = ReadCurrentExecutionPeriod.run(); request.setAttribute(PresentationConstants.INFO_EXECUTION_PERIOD_KEY, infoExecutionPeriod); } return infoExecutionPeriod; }
public static Set<Sender> getAvailableSenders() { final User userView = Authenticate.getUser(); final Set<Sender> senders = new TreeSet<Sender>(Sender.COMPARATOR_BY_FROM_NAME); for (final Sender sender : Bennu.getInstance().getUtilEmailSendersSet()) { if (sender.getMembers().isMember(userView) || (userView != null && userView.getPerson().hasRole(RoleType.MANAGER))) { senders.add(sender); } } return senders; }
@Override protected User doAuthentication(ActionForm form, HttpServletRequest request) { final CasConfig casConfig = CoreConfiguration.casConfig(); if (casConfig != null && casConfig.isCasEnabled()) { throw AuthorizationException.authenticationFailed(); } final AuthenticationForm authenticationForm = (AuthenticationForm) form; final String username = authenticationForm.getUsername(); final String password = authenticationForm.getPassword(); return Authenticate.login(request.getSession(true), username, password); }
private Map<String, Object> makeRequestWrapper(HttpServletRequest req) { HashMap<String, Object> result = new HashMap<String, Object>(); result.put("user", new UserWrap(Authenticate.getUser())); result.put("method", req.getMethod()); result.put("protocol", req.getProtocol()); result.put("url", getFullURL(req)); result.put("contentType", req.getContentType()); result.put("contextPath", req.getContextPath()); return result; }
private boolean isVisible(PartyContact contact) { boolean publicSpace = true; // because this is a homepage. When this logic is exported to a more proper place // remember to pass this as an argument. if (!Authenticate.isLogged() && publicSpace && contact.getVisibleToPublic().booleanValue()) { return true; } if (Authenticate.isLogged()) { User user = Authenticate.getUser(); Person reader = user.getPerson(); if (reader.hasRole(RoleType.CONTACT_ADMIN).booleanValue() || reader.hasRole(RoleType.MANAGER).booleanValue() || reader.hasRole(RoleType.DIRECTIVE_COUNCIL).booleanValue()) { return true; } if (reader.hasRole(RoleType.EMPLOYEE).booleanValue() && contact.getVisibleToEmployees().booleanValue()) { return true; } if (reader.hasRole(RoleType.TEACHER).booleanValue() && contact.getVisibleToTeachers().booleanValue()) { return true; } if (reader.hasRole(RoleType.STUDENT).booleanValue() && contact.getVisibleToStudents().booleanValue()) { return true; } if (reader.hasRole(RoleType.ALUMNI).booleanValue() && contact.getVisibleToAlumni().booleanValue()) { return true; } if (contact.getVisibleToPublic()) { return true; } } return false; }
@Atomic public static CgdCard setGrantAccess(final boolean allowAccess) { final User user = Authenticate.getUser(); if (user != null) { final int year = Year.now().getValue(); final CgdCard card = findCardFor(user, year, allowAccess); if (card != null) { card.setAllowSendDetails(allowAccess); if (allowAccess) { return card; } } } return null; }
public void execute(String executionDegreeID, List<SituationName> situationNames) throws NotAuthorizedException { User id = Authenticate.getUser(); if ((id != null && id.getPerson().getPersonRolesSet() != null && !containsRoleType(id.getPerson().getPersonRolesSet())) || (id != null && id.getPerson().getPersonRolesSet() != null && !hasPrivilege(id, executionDegreeID)) || (id == null) || (id.getPerson().getPersonRolesSet() == null)) { throw new NotAuthorizedException(); } }
@Override public final void run() { log = createExecutionLog(); SchedulerSystem.getLogRepository().newExecution(log); try { innerAtomicRun(); updateLog(log.withSuccess()); } catch (Throwable t) { t.printStackTrace(); updateLog(log.withError(t)); } finally { resetLoggers(); Authenticate.unmock(); } }
public static boolean eval(Person contactPerson) { if (hasRole(RoleType.OPERATOR) || hasRole(RoleType.MANAGER) || isSelfPerson(contactPerson) || hasRole(RoleType.PERSONNEL_SECTION)) { return true; } if (contactPerson.getStudent() != null && !contactPerson.hasRole(RoleType.GRANT_OWNER) && !contactPerson.hasRole(RoleType.EMPLOYEE)) { return AcademicAuthorizationGroup.get(AcademicOperationType.EDIT_STUDENT_PERSONAL_DATA) .isMember(Authenticate.getUser()); } return false; }
public ActionForward deleteEnrollment( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final String enrollmentIdString = request.getParameter("enrollmentId"); final String studentNumberString = request.getParameter("studentNumber"); final String degreeTypeString = request.getParameter("degreeType"); final Integer studentNumber = Integer.valueOf(studentNumberString); final DegreeType degreeType = DegreeType.valueOf(degreeTypeString); final User userView = Authenticate.getUser(); DeleteEnrollment.run(studentNumber, degreeType, enrollmentIdString); return show(mapping, form, request, response); }
public SortedSet<OutboundMobilityCandidacyContestGroup> getCandidacyContestGroupSet( final OutboundMobilityCandidacyPeriod period) { final User user = Authenticate.getUser(); if (AcademicAuthorizationGroup.get(AcademicOperationType.MANAGE_MOBILITY_OUTBOUND) .isMember(user)) { return period.getOutboundMobilityCandidacyContestGroupSet(); } final SortedSet<OutboundMobilityCandidacyContestGroup> result = new TreeSet<OutboundMobilityCandidacyContestGroup>(); if (user != null && user.getPerson() != null) { for (final OutboundMobilityCandidacyContestGroup group : user.getPerson().getOutboundMobilityCandidacyContestGroupSet()) { if (hasContestForPeriod(period, group)) { result.add(group); } } } return result; }
public static boolean hasAvailableSender() { final User userView = Authenticate.getUser(); if (userView != null) { if (userView.getPerson().hasRole(RoleType.MANAGER)) { return true; } final Person person = userView.getPerson(); if (person != null && !person.getMessagesSet().isEmpty()) { return true; } for (final Sender sender : Bennu.getInstance().getUtilEmailSendersSet()) { if (sender.allows(userView)) { return true; } } } return false; }
public ActionForward createStudentCurricularPlan( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final DynaActionForm dynaActionForm = (DynaActionForm) form; final String studentNumberString = (String) dynaActionForm.get("number"); final String degreeTypeString = (String) dynaActionForm.get("degreeType"); final String studentCurricularPlanStateString = (String) dynaActionForm.get("studentCurricularPlanState"); final String degreeCurricularPlanIdString = (String) dynaActionForm.get("degreeCurricularPlanId"); final String startDateString = (String) dynaActionForm.get("startDate"); if (isPresent(studentNumberString) && isPresent(degreeTypeString) && isPresent(studentCurricularPlanStateString) && isPresent(degreeCurricularPlanIdString) && isPresent(startDateString)) { final Integer studentNumber = new Integer(studentNumberString); final DegreeType degreeType = DegreeType.valueOf(degreeTypeString); final StudentCurricularPlanState studentCurricularPlanState = StudentCurricularPlanState.valueOf(studentCurricularPlanStateString); final Date startDate = simpleDateFormat.parse(startDateString); final User userView = Authenticate.getUser(); CreateStudentCurricularPlan.run( studentNumber, degreeType, studentCurricularPlanState, degreeCurricularPlanIdString, startDate); } return show(mapping, form, request, response); }
@Override public boolean evaluate(Context context) { User user = Authenticate.getUser(); if (RoleType.SCIENTIFIC_COUNCIL.isMember(user)) { return true; } final DegreeCurricularPlan parentDegreeCurricularPlan = context.getParentCourseGroup().getParentDegreeCurricularPlan(); if (!parentDegreeCurricularPlan.isBolonhaDegree()) { return true; } if (AcademicAuthorizationGroup.get(AcademicOperationType.MANAGE_DEGREE_CURRICULAR_PLANS) .isMember(user) || RoleType.MANAGER.isMember(user) || RoleType.OPERATOR.isMember(user)) { return true; } return parentDegreeCurricularPlan.getCurricularPlanMembersGroup().isMember(user); }
public void handleRequest( Site site, HttpServletRequest req, HttpServletResponse res, String pageSlug) throws IOException, ServletException { if (site.getCanViewGroup().isMember(Authenticate.getUser())) { if (site.getPublished()) { try { String baseUrl = "/" + site.getBaseUrl(); if (pageSlug.startsWith(baseUrl)) { pageSlug = pageSlug.substring(baseUrl.length()); } if (pageSlug.endsWith("/") && !req.getRequestURI().equals(req.getContextPath() + "/")) { handleLeadingSlash(req, res, site); } else if (pageSlug.startsWith("/static/")) { handleStaticResource(req, res, site, pageSlug); } else if (pageSlug.startsWith("/rss")) { handleRSS(req, res, site, pageSlug); } else { renderCMSPage(req, res, site, pageSlug); } } catch (Exception e) { logger.error("Exception while rendering CMS page " + req.getRequestURI(), e); if (res.isCommitted()) { return; } res.reset(); res.resetBuffer(); errorPage(req, res, site, 500); } } else { res.sendError(404); } } else { res.sendError(404); return; } }
@Override public void showLoginPage(HttpServletRequest req, HttpServletResponse resp, String callback) throws IOException, ServletException { if (Authenticate.isLogged()) { if (Strings.isNullOrEmpty(callback)) { resp.sendRedirect(req.getContextPath() + "/login.do"); } else { resp.sendRedirect(callback); } } else { CasConfig casConfig = CoreConfiguration.casConfig(); if (Strings.isNullOrEmpty(callback)) { callback = casConfig.getCasServiceUrl(); } String casLoginUrl = casConfig.getCasLoginUrl(callback); if (FenixEduIstIntegrationConfiguration.barraLogin()) { casLoginUrl = FenixEduIstIntegrationConfiguration.getConfiguration().barraLoginUrl() + "?next=" + casLoginUrl; } resp.sendRedirect(casLoginUrl); } }
public ActionForward showYearInformation( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { User userView = Authenticate.getUser(); YearViewBean searchFormBean = (YearViewBean) getRenderedObject("searchFormBean"); RenderUtils.invalidateViewState(); if (searchFormBean == null || searchFormBean.getExecutionYear() == null) { String degreeCurricularPlanID = null; DegreeCurricularPlan degreeCurricularPlan = null; if (request.getParameter("degreeCurricularPlanID") != null) { degreeCurricularPlanID = request.getParameter("degreeCurricularPlanID"); request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanID); degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); } searchFormBean = new YearViewBean(degreeCurricularPlan); request.setAttribute("searchFormBean", searchFormBean); return mapping.findForward("xYearEntry"); } /* * YearViewBean yearViewBean = new * YearViewBean(searchFormBean.getDegreeCurricularPlan()); * yearViewBean.setExecutionYear(searchFormBean.getExecutionYear()); * yearViewBean.setEnrolments(); */ request.setAttribute("dcpEId", searchFormBean.getDegreeCurricularPlan().getExternalId()); request.setAttribute("eyEId", searchFormBean.getExecutionYear().getExternalId()); /* * Inar totalInar = generateINAR(yearViewBean); * request.setAttribute("totalInar", totalInar); * * int years = * yearViewBean.getDegreeCurricularPlan().getDegree().getDegreeType * ().getYears(); request.setAttribute("#years", years); * * Map<CurricularYear, Inar> mapInarByYear = * generateInarByCurricularYear(yearViewBean); for (int i = 1; i <= * years; i++) { Inar value = * mapInarByYear.get(CurricularYear.readByYear(i)); String label = * "InarFor" + i + "Year"; request.setAttribute(label, value); } * * Map<CurricularYear, String> mapAveragebyYear = * generateAverageByCurricularYear(yearViewBean); List averageByYear = * new LinkedList(mapAveragebyYear.entrySet()); * request.setAttribute("averageByYear", averageByYear); * * // @Deprecated // if(<3 == true) {you.marry(me) ? super.happy() : * null;} if (yearViewBean.hasBranchesByType(BranchType.MAJOR)) { * Map<BranchCourseGroup, Inar> mapInarByBranches = * generateInarByBranch(yearViewBean, BranchType.MAJOR); * yearViewBean.setHasMajorBranches(true); * yearViewBean.setMajorBranches( * yearViewBean.getDegreeCurricularPlan().getBranchesByType * (BranchType.MAJOR)); * yearViewBean.setInarByMajorBranches(mapInarByBranches); * * Map<BranchCourseGroup, String> mapAverageByBranches = * generateAverageByBranch(yearViewBean, BranchType.MAJOR); * yearViewBean.setAverageByMajorBranches(mapAverageByBranches); } * * if (yearViewBean.hasBranchesByType(BranchType.MINOR)) { * Map<BranchCourseGroup, Inar> mapInarByBranches = * generateInarByBranch(yearViewBean, BranchType.MINOR); * yearViewBean.setHasMinorBranches(true); * yearViewBean.setMinorBranches( * yearViewBean.getDegreeCurricularPlan().getBranchesByType * (BranchType.MINOR)); * yearViewBean.setInarByMinorBranches(mapInarByBranches); * * Map<BranchCourseGroup, String> mapAverageByBranches = * generateAverageByBranch(yearViewBean, BranchType.MINOR); * yearViewBean.setAverageByMinorBranches(mapAverageByBranches); } * * String resumedQUC = generateQUCResults(yearViewBean); * yearViewBean.setResumedQUC(resumedQUC); * * request.setAttribute("yearViewBean", yearViewBean); */ request.setAttribute("searchFormBean", searchFormBean); return mapping.findForward("xYearDisplay"); }
private void logout() { Authenticate.unmock(); }
private void login(User user) { if (user == null) { throw newApplicationError(Status.BAD_REQUEST, "no user found"); } Authenticate.mock(user); }