use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DirectoryUtils method mapPrincipalRecordToDbUser.
public DbUser mapPrincipalRecordToDbUser(String authz, ExtMap principal) {
principal = principal.clone();
flatGroups(principal);
DbUser dbUser = dbUserDao.getByExternalId(authz, principal.get(PrincipalRecord.ID));
Guid userId = dbUser != null ? dbUser.getId() : Guid.newGuid();
dbUser = new DbUser(mapPrincipalRecordToDirectoryUser(authz, principal));
dbUser.setId(userId);
Set<Guid> groupIds = new HashSet<>();
Set<String> groupsNames = new HashSet<>();
for (ExtMap group : principal.<Collection<ExtMap>>get(PrincipalRecord.GROUPS, Collections.<ExtMap>emptyList())) {
DbGroup dbGroup = dbGroupDao.getByExternalId(authz, group.get(GroupRecord.ID));
if (dbGroup != null) {
groupIds.add(dbGroup.getId());
groupsNames.add(dbGroup.getName());
}
}
dbUser.setGroupIds(groupIds);
dbUser.setGroupNames(groupsNames);
return dbUser;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendGroupsResource method mapDbGroupCollection.
private Groups mapDbGroupCollection(List<DbGroup> entities) {
Groups collection = new Groups();
for (DbGroup entity : entities) {
Group group = map(entity);
group = populate(group, entity);
group = addLinks(group, BaseResource.class);
collection.getGroups().add(group);
}
return collection;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendGroupsResource method add.
@Override
public Response add(Group group) {
List<String> authzProvidersNames = getBackendCollection(String.class, QueryType.GetDomainList, new QueryParametersBase());
validateParameters(group, "name");
if (AuthzUtils.getAuthzNameFromEntityName(group.getName(), authzProvidersNames) == null) {
validateParameters(group, "domain.id|name");
}
String directoryName = getAuthzProviderName(group, authzProvidersNames);
DirectoryGroup directoryGroup = findDirectoryGroup(directoryName, group);
if (directoryGroup == null) {
return Response.status(Status.BAD_REQUEST).entity("No such group: " + group.getName() + " in directory " + directoryName).build();
}
AddGroupParameters parameters = new AddGroupParameters();
parameters.setGroupToAdd(new DbGroup(directoryGroup));
QueryIdResolver<Guid> resolver = new QueryIdResolver<>(QueryType.GetDbGroupById, IdQueryParameters.class);
return performCreate(ActionType.AddGroup, parameters, resolver, BaseResource.class);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DbGroupDaoTest method testUpdateDoesntChangeExternalId.
/**
* Ensures that update cycle doesn't change the external identifier.
*/
@Test
public void testUpdateDoesntChangeExternalId() {
DbGroup groupBefore = dao.get(existingGroup.getId());
dao.update(groupBefore);
DbGroup groupAfter = dao.get(existingGroup.getId());
assertEquals(groupBefore.getExternalId(), groupAfter.getExternalId());
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DbGroupDaoTest method testGetByExternalId.
/**
* Ensures that retrieving an group by external id works as expected.
*/
@Test
public void testGetByExternalId() {
DbGroup result = dao.getByExternalId("rhel", "a");
assertNotNull(result);
}
Aggregations