Search in sources :

Example 6 with InternalAuth

use of fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth in project muikku by otavanopisto.

the class InternalAuthDAO method create.

public InternalAuth create(Long userEntityId, String password) {
    InternalAuth internalAuth = new InternalAuth();
    internalAuth.setPassword(password);
    internalAuth.setUserEntityId(userEntityId);
    return persist(internalAuth);
}
Also used : InternalAuth(fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth)

Example 7 with InternalAuth

use of fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth in project muikku by otavanopisto.

the class InternalAuthDAO method findByUserIdAndPassword.

public InternalAuth findByUserIdAndPassword(Long userEntityId, String password) {
    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.and(criteriaBuilder.equal(root.get(InternalAuth_.userEntityId), userEntityId), criteriaBuilder.equal(root.get(InternalAuth_.password), password)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) InternalAuth(fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth)

Aggregations

InternalAuth (fi.otavanopisto.muikku.plugins.internalauth.model.InternalAuth)7 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 EntityManager (javax.persistence.EntityManager)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 AuthenticationResult (fi.otavanopisto.muikku.auth.AuthenticationResult)1