Search in sources :

Example 1 with PseudonymImpl

use of org.olat.modules.fo.model.PseudonymImpl in project openolat by klemens.

the class ForumManager method createProtectedPseudonym.

public Pseudonym createProtectedPseudonym(String pseudonym, String password) {
    PseudonymImpl pseudo = new PseudonymImpl();
    pseudo.setCreationDate(new Date());
    pseudo.setPseudonym(pseudonym);
    Algorithm algorithm = loginModule.getDefaultHashAlgorithm();
    String salt = algorithm.isSalted() ? Encoder.getSalt() : null;
    String newCredentials = Encoder.encrypt(password, salt, algorithm);
    pseudo.setSalt(salt);
    pseudo.setCredential(newCredentials);
    pseudo.setAlgorithm(algorithm.name());
    dbInstance.getCurrentEntityManager().persist(pseudo);
    return pseudo;
}
Also used : PseudonymImpl(org.olat.modules.fo.model.PseudonymImpl) Algorithm(org.olat.core.util.Encoder.Algorithm) Date(java.util.Date)

Example 2 with PseudonymImpl

use of org.olat.modules.fo.model.PseudonymImpl in project OpenOLAT by OpenOLAT.

the class ForumManager method createProtectedPseudonym.

public Pseudonym createProtectedPseudonym(String pseudonym, String password) {
    PseudonymImpl pseudo = new PseudonymImpl();
    pseudo.setCreationDate(new Date());
    pseudo.setPseudonym(pseudonym);
    Algorithm algorithm = loginModule.getDefaultHashAlgorithm();
    String salt = algorithm.isSalted() ? Encoder.getSalt() : null;
    String newCredentials = Encoder.encrypt(password, salt, algorithm);
    pseudo.setSalt(salt);
    pseudo.setCredential(newCredentials);
    pseudo.setAlgorithm(algorithm.name());
    dbInstance.getCurrentEntityManager().persist(pseudo);
    return pseudo;
}
Also used : PseudonymImpl(org.olat.modules.fo.model.PseudonymImpl) Algorithm(org.olat.core.util.Encoder.Algorithm) Date(java.util.Date)

Aggregations

Date (java.util.Date)2 Algorithm (org.olat.core.util.Encoder.Algorithm)2 PseudonymImpl (org.olat.modules.fo.model.PseudonymImpl)2