use of fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima 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.entities.ecandidat.CompteMinima in project esup-ecandidat by EsupPortail.
the class CandidatRest method valideMail.
/**
* valide le mail
*/
@RequestMapping(value = "/mail/{numDossierOpiEncode}", method = RequestMethod.GET)
public String valideMail(@PathVariable String numDossierOpiEncode) {
String numDossierOpi = null;
String mode = "";
try {
byte[] numDossierOpiByte = Base64.getUrlDecoder().decode(numDossierOpiEncode);
numDossierOpi = new String(numDossierOpiByte);
if (numDossierOpi != null) {
CompteMinima cptMin = candidatController.searchCptMinByNumDossier(numDossierOpi);
mode = "";
if (cptMin != null) {
if (cptMin.getTemValidMailCptMin()) {
mode = ConstanteUtils.REST_VALID_ALREADY_VALID;
} else {
cptMin.setTemValidMailCptMin(true);
candidatController.simpleSaveCptMin(cptMin);
mode = ConstanteUtils.REST_VALID_SUCCESS;
// userController.validSecurityUserMail(cptMin, true);
}
} else {
mode = ConstanteUtils.REST_VALID_CPT_NULL;
}
}
} catch (Exception e) {
mode = ConstanteUtils.REST_VALID_ERROR;
}
String path = loadBalancingController.getApplicationPath(true) + "#!" + CandidatCompteMinimaView.NAME + "/" + mode;
return "redirect:" + path;
}
use of fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima in project esup-ecandidat by EsupPortail.
the class CandidatRest method valideDossier.
/**
* valide le compte
*/
@RequestMapping(value = "/dossier/{numDossierOpiEncode}", method = RequestMethod.GET)
public String valideDossier(@PathVariable String numDossierOpiEncode) {
String numDossierOpi = null;
String mode = "";
try {
byte[] numDossierOpiByte = Base64.getUrlDecoder().decode(numDossierOpiEncode);
numDossierOpi = new String(numDossierOpiByte);
CompteMinima cptMin = candidatController.searchCptMinByNumDossier(numDossierOpi);
if (cptMin != null) {
if (cptMin.getTemValidCptMin()) {
mode = ConstanteUtils.REST_VALID_ALREADY_VALID;
} else {
cptMin.setTemValidCptMin(true);
cptMin.setTemValidMailCptMin(true);
candidatController.simpleSaveCptMin(cptMin);
mode = ConstanteUtils.REST_VALID_SUCCESS;
// userController.validSecurityUserCptMin();
}
} else {
mode = ConstanteUtils.REST_VALID_CPT_NULL;
}
} catch (Exception e) {
mode = ConstanteUtils.REST_VALID_ERROR;
}
String path = loadBalancingController.getApplicationPath(true) + "#!" + CandidatCompteMinimaView.NAME + "/" + mode;
return "redirect:" + path;
}
use of fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima in project esup-ecandidat by EsupPortail.
the class CandidatureCtrCandController method openCandidat.
/**
* Ouvre le dossier d'un candidat
* @param candidature
*/
public void openCandidat(final Candidature candidature) {
final CompteMinima cpt = candidature.getCandidat().getCompteMinima();
userController.setNoDossierNomCandidat(cpt);
MainUI.getCurrent().buildMenuGestCand(false);
}
use of fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima in project esup-ecandidat by EsupPortail.
the class CandidatController method initPasswordOrActivationCode.
/**
* Initialise le pwd du compte
* @param eMail
* @return true si tout se passe bien
*/
public Boolean initPasswordOrActivationCode(final String eMail, final String mode) {
// Generateur de mot de passe
final PasswordHashService passwordHashUtils = PasswordHashService.getCurrentImplementation();
final CompteMinima cptMin = searchCptMinByEMail(eMail);
if (cptMin == null) {
Notification.show(applicationContext.getMessage("compteMinima.id.oublie.mail.err", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return false;
}
final String pwd = passwordHashUtils.generateRandomPassword(ConstanteUtils.GEN_SIZE, ConstanteUtils.GEN_PWD);
try {
cptMin.setPwdCptMin(passwordHashUtils.createHash(pwd));
cptMin.setTypGenCptMin(passwordHashUtils.getType());
} catch (final CustomException e) {
Notification.show(applicationContext.getMessage("compteMinima.pwd.error", null, UI.getCurrent().getLocale()), Type.ERROR_MESSAGE);
return false;
}
compteMinimaRepository.save(cptMin);
if (mode.equals(ConstanteUtils.FORGOT_MODE_ID_OUBLIE)) {
final CptMinMailBean mailBean = new CptMinMailBean(cptMin.getPrenomCptMin(), cptMin.getNomCptMin(), cptMin.getNumDossierOpiCptMin(), pwd, null, campagneController.getLibelleCampagne(cptMin.getCampagne(), getCodLangueCptMin(cptMin)), null);
mailController.sendMailByCod(cptMin.getMailPersoCptMin(), NomenclatureUtils.MAIL_CPT_MIN_ID_OUBLIE, mailBean, null, getCodLangueCptMin(cptMin));
Notification.show(applicationContext.getMessage("compteMinima.id.oublie.success", null, UI.getCurrent().getLocale()), Type.HUMANIZED_MESSAGE);
} else {
final CptMinMailBean mailBean = new CptMinMailBean(cptMin.getPrenomCptMin(), cptMin.getNomCptMin(), cptMin.getNumDossierOpiCptMin(), pwd, getLienValidation(cptMin.getNumDossierOpiCptMin()), campagneController.getLibelleCampagne(cptMin.getCampagne(), getCodLangueCptMin(cptMin)), formatterDate.format(cptMin.getDatFinValidCptMin()));
mailController.sendMailByCod(cptMin.getMailPersoCptMin(), NomenclatureUtils.MAIL_CPT_MIN, mailBean, null, getCodLangueCptMin(cptMin));
Notification.show(applicationContext.getMessage("compteMinima.code.oublie.success", null, UI.getCurrent().getLocale()), Type.HUMANIZED_MESSAGE);
}
return true;
}
Aggregations