use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class GroupDatabaseRepositoryTest method find.
@Test
public void find() {
UserEntity user = new UserEntity("Jan");
user.addGroup(group);
persistAndRefresh(user);
Collection<Group> result = groupDatabaseRepository.find(user);
assertThat(result).containsOnly(group);
}
use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class GroupServiceImpl method addRole.
public void addRole(TGroup group, TRole role) {
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
attachedGroup.addRole(attachedRole);
}
use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class GroupDatabaseRepository method findByCN.
@SuppressWarnings("unchecked")
@Override
public Group findByCN(String cn) {
Query query = entityManager.createQuery("SELECT g FROM GroupEntity g WHERE g.cn = :cn").setParameter("cn", cn);
List<Group> resultList = query.getResultList();
if (resultList.size() == 0) {
return null;
} else if (resultList.size() == 1) {
return resultList.get(0);
}
throw new IllegalStateException("Multiple users found for username: '" + cn + "'");
}
Aggregations