use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method checkEmail.
/**
* Checks if a mail is already taken by someone else
*
* @param email - email to check
* @param type - user {@link Type} to check
* @param domainId - domain to check
* @param id - id of current user to allow self update
* @return <code>true</code> in case email is allowed
*/
public boolean checkEmail(String email, Type type, Long domainId, Long id) {
log.debug("checkEmail: email = {}, id = {}", email, id);
User u = getByEmail(email, type, domainId);
return u == null || u.getId().equals(id);
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method getAllBackupUsers.
public List<User> getAllBackupUsers() {
OpenJPAEntityManager oem = OpenJPAPersistence.cast(em);
boolean qrce = oem.getFetchPlan().getQueryResultCacheEnabled();
try {
// update in cache during update
oem.getFetchPlan().setQueryResultCacheEnabled(false);
TypedQuery<User> q = oem.createNamedQuery("getAllUsers", User.class);
@SuppressWarnings("unchecked") OpenJPAQuery<User> kq = OpenJPAPersistence.cast(q);
kq.getFetchPlan().addFetchGroups("backupexport", "groupUsers");
return kq.getResultList();
} finally {
oem.getFetchPlan().setQueryResultCacheEnabled(qrce);
}
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method get.
private User get(Long id, boolean force) {
User u = null;
if (id != null && id.longValue() > 0) {
OpenJPAEntityManager oem = OpenJPAPersistence.cast(em);
boolean qrce = oem.getFetchPlan().getQueryResultCacheEnabled();
try {
// update in cache during update
oem.getFetchPlan().setQueryResultCacheEnabled(false);
TypedQuery<User> q = oem.createNamedQuery("getUserById", User.class).setParameter("id", id);
@SuppressWarnings("unchecked") OpenJPAQuery<User> kq = OpenJPAPersistence.cast(q);
kq.getFetchPlan().addFetchGroup("groupUsers");
if (force) {
kq.getFetchPlan().addFetchGroup("backupexport");
}
List<User> list = kq.getResultList();
u = list.size() == 1 ? list.get(0) : null;
} finally {
oem.getFetchPlan().setQueryResultCacheEnabled(qrce);
}
} else {
log.info("[get]: No user id given");
}
return u;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method verifyPassword.
/**
* Returns true if the password is correct
*
* @param userId - id of the user to check
* @param password - password to check
* @return <code>true</code> if entered password is correct
*/
public boolean verifyPassword(Long userId, String password) {
List<String> l = em.createNamedQuery("getPassword", String.class).setParameter(PARAM_USER_ID, userId).getResultList();
if (l == null || l.size() != 1) {
return false;
}
String hash = l.get(0);
ICrypt crypt = CryptProvider.get();
if (crypt.verify(password, hash)) {
return true;
}
if (crypt.fallback(password, hash)) {
log.warn("Password for user with ID {} crypted with outdated Crypt, updating ...", userId);
try {
User u = updatePassword(userId, password, userId);
log.warn("Password for user {} updated successfully", u);
return true;
} catch (NoSuchAlgorithmException e) {
log.error("Unexpected exception while updating password");
}
}
return false;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserDao method getRights.
public Set<Right> getRights(Long id) {
Set<Right> rights = new HashSet<>();
if (id == null) {
return rights;
}
// For direct access of linked users
if (id.longValue() < 0) {
rights.add(Right.Room);
return rights;
}
User u = get(id);
if (u != null) {
return u.getRights();
}
return rights;
}
Aggregations