use of fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth in project muikku by otavanopisto.
the class InternalAuthDAO method findByUserId.
public InternalAuth findByUserId(Long userEntityId) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<InternalAuth> criteria = criteriaBuilder.createQuery(InternalAuth.class);
Root<InternalAuth> root = criteria.from(InternalAuth.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(InternalAuth_.userEntityId), userEntityId));
return getSingleResult(entityManager.createQuery(criteria));
}
use of fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth in project muikku by otavanopisto.
the class InternalAuthDAO method updatePassword.
public void updatePassword(UserEntity user, String passwordHash, String newPasswordHash) {
InternalAuth internalAuth = findByUserIdAndPassword(user.getId(), passwordHash);
internalAuth.setPassword(newPasswordHash);
persist(internalAuth);
}
use of fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth in project muikku by otavanopisto.
the class InternalAuthController method confirmUserPassword.
public boolean confirmUserPassword(UserEntity user, String password) {
String passwordHash = DigestUtils.md5Hex(password);
InternalAuth internalAuth = internalAuthDAO.findByUserIdAndPassword(user.getId(), passwordHash);
return internalAuth != null;
}
use of fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth in project muikku by otavanopisto.
the class InternalAuthController method findInternalAuthByEmailAndPassword.
public InternalAuth findInternalAuthByEmailAndPassword(String email, String password) {
String passwordHash = DigestUtils.md5Hex(password);
UserEntity userEntity = userEntityController.findUserEntityByEmailAddress(email);
if (userEntity != null) {
InternalAuth internalAuth = internalAuthDAO.findByUserIdAndPassword(userEntity.getId(), passwordHash);
return internalAuth;
}
return null;
}
use of fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth in project muikku by otavanopisto.
the class InternalAuthenticationStrategy method processLogin.
@Override
public AuthenticationResult processLogin(AuthSource authSource, Map<String, String[]> requestParameters) {
String email = StringUtils.lowerCase(getFirstRequestParameter(requestParameters, "email"));
String password = getFirstRequestParameter(requestParameters, "password");
InternalAuth internalAuth = internalLoginController.findInternalAuthByEmailAndPassword(email, password);
if (internalAuth != null) {
UserEntity userEntity = userEntityController.findUserEntityById(internalAuth.getUserEntityId());
if (userEntity != null) {
return processLogin(authSource, requestParameters, DigestUtils.md5Hex("INTERNAL-" + internalAuth.getId()), Arrays.asList(email), null, null);
}
}
return new AuthenticationResult(Status.INVALID_CREDENTIALS);
}
Aggregations