Search in sources :

Example 1 with CompteMinima

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();
}
Also used : CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) MainUI(fr.univlorraine.ecandidat.MainUI) SecurityUser(fr.univlorraine.ecandidat.services.security.SecurityUser) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken)

Example 2 with CompteMinima

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;
}
Also used : CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with CompteMinima

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;
}
Also used : CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with CompteMinima

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);
}
Also used : CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima)

Example 5 with CompteMinima

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;
}
Also used : CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) CptMinMailBean(fr.univlorraine.ecandidat.utils.bean.mail.CptMinMailBean) PasswordHashService(fr.univlorraine.ecandidat.services.security.PasswordHashService) CustomException(fr.univlorraine.ecandidat.utils.CustomException)

Aggregations

CompteMinima (fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima)15 Candidat (fr.univlorraine.ecandidat.entities.ecandidat.Candidat)4 Formation (fr.univlorraine.ecandidat.entities.ecandidat.Formation)4 Campagne (fr.univlorraine.ecandidat.entities.ecandidat.Campagne)3 ExportDossierCandidat (fr.univlorraine.ecandidat.utils.bean.export.ExportDossierCandidat)3 ExportLettreCandidat (fr.univlorraine.ecandidat.utils.bean.export.ExportLettreCandidat)3 InputStream (java.io.InputStream)3 Candidature (fr.univlorraine.ecandidat.entities.ecandidat.Candidature)2 CentreCandidature (fr.univlorraine.ecandidat.entities.ecandidat.CentreCandidature)2 Commission (fr.univlorraine.ecandidat.entities.ecandidat.Commission)2 TypeDecisionCandidature (fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature)2 SecurityCommission (fr.univlorraine.ecandidat.services.security.SecurityCommission)2 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 LocalDateTime (java.time.LocalDateTime)2 ArrayList (java.util.ArrayList)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Options (fr.opensagres.xdocreport.converter.Options)1 XDocConverterException (fr.opensagres.xdocreport.converter.XDocConverterException)1 XDocReportException (fr.opensagres.xdocreport.core.XDocReportException)1