use of org.ovirt.engine.core.aaa.DirectoryGroup in project ovirt-engine by oVirt.
the class BackendDomainGroupsResource method mapGroups.
private Groups mapGroups(List<DirectoryGroup> entities) {
Groups collection = new Groups();
for (DirectoryGroup entity : entities) {
Group group = map(entity);
group = populate(group, entity);
group = addLinks(group, true);
collection.getGroups().add(group);
}
return collection;
}
use of org.ovirt.engine.core.aaa.DirectoryGroup in project ovirt-engine by oVirt.
the class GroupMapper method map.
@Mapping(from = DirectoryGroup.class, to = Group.class)
public static Group map(DirectoryGroup entity, Group template) {
Group model = template != null ? template : new Group();
model.setName(entity.getName());
if (!StringUtils.isEmpty(entity.getDirectoryName())) {
Domain dom = new Domain();
dom.setName(entity.getDirectoryName());
dom.setId(DirectoryEntryIdUtils.encode(dom.getName()));
model.setDomain(dom);
}
model.setId(DirectoryEntryIdUtils.encode(entity.getId()));
model.setNamespace(entity.getNamespace());
return model;
}
use of org.ovirt.engine.core.aaa.DirectoryGroup in project ovirt-engine by oVirt.
the class DirectoryUtils method mapPrincipalRecordToDirectoryUser.
public DirectoryUser mapPrincipalRecordToDirectoryUser(final String authzName, final ExtMap principalRecord) {
DirectoryUser directoryUser = null;
if (principalRecord != null) {
directoryUser = new DirectoryUser(authzName, principalRecord.get(Authz.PrincipalRecord.NAMESPACE), principalRecord.get(Authz.PrincipalRecord.ID), principalRecord.get(Authz.PrincipalRecord.NAME), principalRecord.get(Authz.PrincipalRecord.PRINCIPAL), principalRecord.get(Authz.PrincipalRecord.DISPLAY_NAME));
directoryUser.setDepartment(principalRecord.get(Authz.PrincipalRecord.DEPARTMENT));
directoryUser.setFirstName(principalRecord.get(Authz.PrincipalRecord.FIRST_NAME));
directoryUser.setLastName(principalRecord.get(Authz.PrincipalRecord.LAST_NAME));
directoryUser.setEmail(principalRecord.get(Authz.PrincipalRecord.EMAIL));
directoryUser.setTitle(principalRecord.get(Authz.PrincipalRecord.TITLE));
directoryUser.setPrincipal(principalRecord.get(Authz.PrincipalRecord.PRINCIPAL));
List<DirectoryGroup> directoryGroups = new ArrayList<>();
Collection<ExtMap> groups = principalRecord.get(Authz.PrincipalRecord.GROUPS);
if (groups != null) {
for (ExtMap group : groups) {
directoryGroups.add(mapGroupRecordToDirectoryGroup(authzName, group));
}
}
directoryUser.setGroups(directoryGroups);
}
return directoryUser;
}
use of org.ovirt.engine.core.aaa.DirectoryGroup in project ovirt-engine by oVirt.
the class GetDirectoryGroupsForUserQuery method getDirectoryUser.
private Collection<DirectoryGroup> getDirectoryUser(DbUser dbUser) {
Collection<DirectoryGroup> groups = new ArrayList<>();
Map<String, Object> response = SsoOAuthServiceUtils.findPrincipalsByIds(getSessionDataContainer().getSsoAccessToken(getParameters().getSessionId()), dbUser.getDomain(), dbUser.getNamespace(), Arrays.asList(dbUser.getExternalId()), true, true);
Collection<ExtMap> principalRecords = Collections.emptyList();
if (response.containsKey("result")) {
principalRecords = (Collection<ExtMap>) response.get("result");
}
if (!principalRecords.isEmpty()) {
ExtMap principalRecord = principalRecords.iterator().next();
directoryUtils.flatGroups(principalRecord);
for (ExtMap group : principalRecord.<Collection<ExtMap>>get(PrincipalRecord.GROUPS, Collections.<ExtMap>emptyList())) {
groups.add(directoryUtils.mapGroupRecordToDirectoryGroup(dbUser.getDomain(), group));
}
}
return groups;
}
Aggregations