use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class GroupServiceImpl method addRoles.
public void addRoles(TGroup group, List<TRole> roles) {
Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
Collection<Role> attachedRoles = roles.stream().map(r -> roleRepository.refreshWithOptimisticLocking(r.getId(), r.getVersion())).collect(Collectors.toList());
attachedGroup.addRoles(attachedRoles);
}
use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class GroupServiceImpl method removeRole.
public void removeRole(TGroup group, TRole role) {
Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
attachedGroup.removeRole(attachedRole);
}
use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class ActiveDirectoryLoginModule method addADGroupsToUser.
protected void addADGroupsToUser(LdapContext ldapContext, User user, String userCN) throws NamingException {
SearchControls searchControls = new SearchControls();
searchControls.setReturningAttributes(new String[] { "dn" });
searchControls.setSearchScope(searchScope);
GroupRepository groupRepository = GlobalContext.locate(GroupRepository.class);
String filterGroups = "(&(member=" + userCN + "," + searchBase + ")(objectcategory=group))";
NamingEnumeration results = ldapContext.search(searchBase, filterGroups, searchControls);
while (hasMoreResults(results)) {
String groupCN = ((SearchResult) results.next()).getName();
Group group = groupRepository.findByCN(groupCN);
if (group != null) {
user.addGroup(group);
}
}
}
use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class GroupDatabaseRepositoryTest method findByName_success.
@Test
public void findByName_success() {
Group result = groupDatabaseRepository.findByCN(DUMMY_GROUP_CN);
assertNotNull(result);
assertEquals(DUMMY_GROUP_NAME, result.getName());
}
use of org.simbasecurity.core.domain.Group in project simba-os by cegeka.
the class RuleDatabaseRepositoryTest method setupWithGroups.
private ResourceRule setupWithGroups() {
User user = new UserEntity(USER_VIA_GROUP);
Role role = new RoleEntity("role2");
Group group = new GroupEntity("groupName", "cn");
Policy policy = new PolicyEntity("policy2");
ResourceRule resourceRuleEntity = new ResourceRuleEntity("resrule2");
resourceRuleEntity.setResourceName("resname2");
urlRuleEntityViaGroup = new URLRuleEntity("urlrule2");
persistAndRefresh(user, role, policy, resourceRuleEntity, urlRuleEntityViaGroup);
persistAndRefresh(user, group, role, policy, resourceRuleEntity, urlRuleEntityViaGroup);
policy.addRule(resourceRuleEntity);
policy.addRule(urlRuleEntityViaGroup);
role.addPolicy(policy);
group.addRole(role);
user.addGroup(group);
return resourceRuleEntity;
}
Aggregations