use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method getInactiveUsersDetails.
@Override
public List<UserDetail> getInactiveUsersDetails() {
List<UserDetail> userDetails = new ArrayList<UserDetail>();
List<User> users = hibernateTemplate.execute(new HibernateCallback<List<User>>() {
@SuppressWarnings("unchecked")
@Override
public List<User> doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(User.class).createCriteria("userIndices").add(Restrictions.eq("id.type", UserIndexTypes.USERNAME));
List<User> users = criteria.list();
return users;
}
});
if (!users.isEmpty()) {
for (User user : users) {
UserBean bean = userService.getUserAsBean(user);
if (bean.isDisabled()) {
if (!user.getUserIndices().isEmpty()) {
UserDetail userDetail = buildUserDetail(user);
userDetails.add(userDetail);
}
}
}
}
log.debug("Returning user details");
return userDetails;
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method getActiveUsersDetails.
@Override
public List<UserDetail> getActiveUsersDetails() {
List<UserDetail> userDetails = new ArrayList<UserDetail>();
List<User> users = hibernateTemplate.execute(new HibernateCallback<List<User>>() {
@SuppressWarnings("unchecked")
@Override
public List<User> doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(User.class).createCriteria("userIndices").add(Restrictions.eq("id.type", UserIndexTypes.USERNAME));
List<User> users = criteria.list();
return users;
}
});
if (!users.isEmpty()) {
for (User user : users) {
UserBean bean = userService.getUserAsBean(user);
if (!bean.isDisabled()) {
if (!user.getUserIndices().isEmpty()) {
UserDetail userDetail = buildUserDetail(user);
userDetails.add(userDetail);
}
}
}
}
log.debug("Returning user details");
return userDetails;
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class TemporaryPasswordServiceImpl method getTemporaryPasswordForUser.
@Override
public String getTemporaryPasswordForUser(String username) {
String newpass = getTemporaryPassword();
UserDetail detail = _userManagementService.getUserDetail(username);
_log.warn("got userdetail for name: " + username);
detail.setPassword(newpass);
_userManagementService.updateUser(detail);
setTemporaryPassword(username, true);
return newpass;
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImplTest method testUpdateNonExistingUser.
@Test
public void testUpdateNonExistingUser() {
UserDetail userDetail = mock(UserDetail.class);
when(userDetail.getId()).thenReturn(1);
when(userDetail.getUsername()).thenReturn("admin2");
when(userDao.getUserForId(1)).thenReturn(null);
boolean success = service.updateUser(userDetail);
assertFalse("Unable to update non existing user", success);
verify(passwordEncoder, times(0)).encodePassword("password", "admin2");
verify(userDao, times(0)).saveOrUpdateUser(user);
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImplTest method testDeactivateNonExistingUser.
@Test
public void testDeactivateNonExistingUser() {
UserDetail userDetail = mock(UserDetail.class);
when(userDetail.getId()).thenReturn(1);
when(userDetail.getUsername()).thenReturn("admin2");
when(userDao.getUserForId(1)).thenReturn(null);
boolean success = service.deactivateUser(userDetail);
assertFalse("Unable to delete non existing user", success);
verify(userDao, times(0)).deleteUserIndex(isA(UserIndex.class));
verify(userDao, times(0)).saveOrUpdateUser(user);
}
Aggregations