use of fr.univlorraine.ecandidat.MainUI in project esup-ecandidat by EsupPortail.
the class UserController method connectCandidatInterne.
/**
* Connexion d'un candidat
* @param username
* login
* @param password
* mot de passe
*/
public void connectCandidatInterne(final String username, final String password) {
if (loadBalancingController.isLoadBalancingGestionnaireMode()) {
return;
}
final CompteMinima cptMin = candidatController.searchCptMinByNumDossier(username);
if (cptMin != null) {
if (!validPwdCandidat(password, cptMin)) {
return;
}
if (!cptMin.getTemValidCptMin() || !cptMin.getTemValidMailCptMin()) {
Notification.show(applicationContext.getMessage("compteMinima.connect.valid.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
} else {
Notification.show(applicationContext.getMessage("compteMinima.connect.user.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
final SecurityUser user = constructSecurityUserCandidat(username, cptMin);
if (user == null) {
return;
}
// authentication
final UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(user, username, user.getAuthorities());
final Authentication authentication = authenticationManagerCandidat.authenticate(authRequest);
/* Se désinscrit de la réception de notifications */
uiController.unregisterUiCandidat(MainUI.getCurrent());
final SecurityContext context = SecurityContextHolder.createEmptyContext();
context.setAuthentication(authentication);
SecurityContextHolder.setContext(context);
UI.getCurrent().getSession().getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, context);
final MainUI current = (MainUI) UI.getCurrent();
uiController.registerUiCandidat(current);
i18nController.initLanguageUI(true);
current.navigateToAccueilView();
}
use of fr.univlorraine.ecandidat.MainUI in project esup-ecandidat by EsupPortail.
the class AdminView method confirmKillUI.
/**
* Confirme la fermeture d'une UI
* @param uiItem l'UI a kill
*/
public void confirmKillUI(SessionPresentation uiItem) {
ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("admin.uiList.confirmKillUI", null, UI.getCurrent().getLocale()));
confirmWindow.addBtnOuiListener(e -> {
MainUI ui = uiController.getUI(uiItem);
if (ui != null) {
uiController.killUI(ui);
} else {
Notification.show(applicationContext.getMessage("admin.uiList.confirmKillUI.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
}
removeElement(uiItem);
});
UI.getCurrent().addWindow(confirmWindow);
}
use of fr.univlorraine.ecandidat.MainUI in project esup-ecandidat by EsupPortail.
the class I18nController method changeLangueUI.
/**
* Change la langue de l'UI
*
* @param codeLangue
* le code langage de la locale
* @param forceToReloadMenu
* si le menu doit être forcé à être rechargé-->cas du candidat en
* connexion interne
* @return true si la langue a été& changée
*/
private Boolean changeLangueUI(final String codeLangue, final Boolean forceToReloadMenu) {
if (codeLangue == null || UI.getCurrent() == null) {
return false;
}
Locale locale = UI.getCurrent().getLocale();
if (forceToReloadMenu || locale == null || locale.getLanguage() == null || (codeLangue != null && !codeLangue.equals(locale.getLanguage()))) {
SecurityUserCandidat user = userController.getSecurityUserCandidat();
if (user != null) {
user.setCodLangue(codeLangue);
}
((MainUI) UI.getCurrent()).setLocale(new Locale(codeLangue));
((MainUI) UI.getCurrent()).configReconnectDialogMessages();
((MainUI) UI.getCurrent()).constructMainMenu();
return true;
}
return false;
}
use of fr.univlorraine.ecandidat.MainUI in project esup-ecandidat by EsupPortail.
the class UiController method getUser.
/* Tuer des UIs, sessions et utilisateurs */
/**
* @param user
* @return un user
*/
public UserDetails getUser(final SessionPresentation user) {
for (MainUI ui : getUis()) {
try {
VaadinSession session = ui.getSession();
if (session == null || session.getSession() == null) {
return null;
}
SecurityContext securityContext = (SecurityContext) session.getSession().getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
if (securityContext == null || securityContext.getAuthentication() == null) {
return null;
} else {
UserDetails details = (UserDetails) securityContext.getAuthentication().getPrincipal();
if (details != null && details.getUsername().equals(user.getId())) {
return details;
}
}
} catch (Exception e) {
}
}
return null;
}
Aggregations