@Override public void fill(Uebergabeblatt bbzr, Collection<FetchPlan> plans) { if (log.isDebugEnabled()) log.debug("Entering BbzrServiceImpl:fill()"); if (plans.contains(FetchPlan.BBZR_HEADER) || plans.contains(FetchPlan.UEB_HEADER_SENDER) || plans.contains(FetchPlan.UEB_HEADER_EMPFAENGER)) { Hibernate.initialize(bbzr.getHeader()); if (plans.contains(FetchPlan.UEB_HEADER_SENDER) && bbzr.getHeader() != null) Hibernate.initialize(bbzr.getHeader().getSender()); if (plans.contains(FetchPlan.UEB_HEADER_EMPFAENGER) && bbzr.getHeader() != null) { Header h = bbzr.getHeader(); Hibernate.initialize(h.getEmpfaenger()); } } if (plans.contains(FetchPlan.BBZR_BAUMASSNAHMEN)) { Hibernate.initialize(bbzr.getMassnahmen()); for (Massnahme m : bbzr.getMassnahmen()) { if (m == null) continue; if (plans.contains(FetchPlan.ZVF_MN_VERSION)) { Hibernate.initialize(m.getVersion()); } if (plans.contains(FetchPlan.ZVF_MN_STRECKEN)) { Hibernate.initialize(m.getStrecke()); if (plans.contains(FetchPlan.ZVF_MN_STRECKE_STRECKEVZG)) { StreckeService streckeService = EasyServiceFactory.getInstance().createStreckeService(); streckeService.fill(m.getStrecke(), plans); } } if (plans.contains(FetchPlan.ZVF_MN_BBPSTRECKE)) { Hibernate.initialize(m.getBbp()); } if (plans.contains(FetchPlan.ZVF_MN_ALLG_REGELUNGEN)) { Hibernate.initialize(m.getAllgregelungen()); } if (plans.contains(FetchPlan.BBZR_MN_ZUEGE)) { Hibernate.initialize(m.getZug()); if (m.getZug() != null) { // uebergabeblattspezifische fetchplans entfernen FetchPlan[] newFetchPlans = new FetchPlan[0]; List<FetchPlan> newPlans = new ArrayList<FetchPlan>(plans); newPlans.remove(FetchPlan.UEB_MN_ZUEGE); newPlans.remove(FetchPlan.UEB_KNOTENZEITEN); newPlans.remove(FetchPlan.UEB_BEARBEITUNGSSTATUS); newFetchPlans = newPlans.toArray(newFetchPlans); ZugService zugService = EasyServiceFactory.getInstance().createZugService(); zugService.fill(m.getZug(), newFetchPlans); } } } } }
@Override public Authentication attemptAuthentication(HttpServletRequest request) throws AuthenticationException { // Fahrplanjahr wird beim Einloggen festgelegt und gilt fuer die gesamte Session if (request.getParameter("fahrplanjahr") != null) request .getSession() .setAttribute( "session_fahrplanjahr", FrontendHelper.castStringToInteger(request.getParameter("fahrplanjahr"))); String username = obtainUsername(request); String password = obtainPassword(request); String newPassword = request.getParameter("newpassword"); String confirmPassword = request.getParameter("confirmpassword"); List<String> loginErrors = new ArrayList<String>(); if (username == null) { username = ""; } if (password == null) { password = ""; } if (newPassword != null) { if (confirmPassword == null || !newPassword.equals(confirmPassword)) loginErrors.add("error.user.password.diff"); else { SecurityAdministrationService administrationService = EasyServiceFactory.getInstance().createSecurityAdministrationService(); SecurityService securityService = EasyServiceFactory.getInstance().createSecurityService(); TqmUser tqmUser = (TqmUser) securityService.loadUserByUsername(username); if (tqmUser != null) { // Wenn wir keinen Benutzer finden, fehlt das login ohnehin fehl try { administrationService.changePassword(tqmUser, password, newPassword); password = newPassword; } catch (SecurityException e) { loginErrors.add("error.security.password.BAD_PASSWORD"); e.printStackTrace(); } catch (PasswordException e) { switch (e.getDescription()) { case EMPTY_PASSWORD: loginErrors.add("error.security.password.EMPTY_PASSWORD"); break; case PASSWORD_TO_SHORT: loginErrors.add("error.security.password.PASSWORD_TO_SHORT"); break; case REUSED_PASSWORD: loginErrors.add("error.security.password.REUSED_PASSWORD"); break; case TRIVIAL_PASSWORD: loginErrors.add("error.security.password.TRIVIAL_PASSWORD"); break; case UNSAFE_PASSWORD: loginErrors.add("error.security.password.UNSAFE_PASSWORD"); break; } e.printStackTrace(); } } } } // Fehlermeldungen werden in Session geschrieben request.getSession().setAttribute("loginErrors", loginErrors); UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password); // Place the last username attempted into HttpSession for views request.getSession().setAttribute(ACEGI_SECURITY_LAST_USERNAME_KEY, username); // Allow subclasses to set the "details" property setDetails(request, authRequest); return this.getAuthenticationManager().authenticate(authRequest); }