use of org.ovirt.engine.core.common.businessentities.aaa.AuthzGroup in project ovirt-engine by oVirt.
the class GetAuthzGroupsByUserIdQuery method getDirectoryUser.
private Collection<AuthzGroup> getDirectoryUser(DbUser dbUser) {
Collection<AuthzGroup> groups = new ArrayList<>();
if (dbUser != null) {
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(new AuthzGroup(dbUser.getDomain(), group.get(GroupRecord.NAMESPACE), group.get(GroupRecord.NAME), group.get(GroupRecord.ID)));
}
}
}
return groups;
}
use of org.ovirt.engine.core.common.businessentities.aaa.AuthzGroup in project ovirt-engine by oVirt.
the class GetPermissionsOnBehalfByAdElementIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
QueryReturnValue returnValue = Backend.getInstance().runInternalQuery(QueryType.GetAuthzGroupsByUserId, getParameters());
Collection<AuthzGroup> authzGroups = returnValue.getReturnValue();
List<Guid> groupsIds = authzGroups.stream().map(g -> dbGroupDao.getByExternalId(g.getAuthz(), g.getId())).filter(Objects::nonNull).map(g -> g.getId()).collect(Collectors.toList());
getQueryReturnValue().setReturnValue(permissionDao.getAllForAdElementAndGroups(getParameters().getId(), getUserID(), groupsIds, getParameters().isFiltered()));
}
use of org.ovirt.engine.core.common.businessentities.aaa.AuthzGroup in project ovirt-engine by oVirt.
the class BackendDomainUserGroupsResource method mapGroups.
private Groups mapGroups(List<AuthzGroup> authzGroups) {
Groups groups = new Groups();
groups.getGroups().addAll(authzGroups.stream().map(g -> map(g)).map(g -> addLinks(g)).collect(Collectors.toList()));
return groups;
}
use of org.ovirt.engine.core.common.businessentities.aaa.AuthzGroup in project ovirt-engine by oVirt.
the class GroupMapper method map.
@Mapping(from = AuthzGroup.class, to = Group.class)
public static Group map(AuthzGroup authzGroup, Group template) {
Group model = template != null ? template : new Group();
model.setId(DirectoryEntryIdUtils.encode(authzGroup.getId()));
model.setName(authzGroup.getName());
model.setNamespace(authzGroup.getNamespace());
if (!StringUtils.isEmpty(authzGroup.getAuthz())) {
Domain dom = new Domain();
dom.setName(authzGroup.getAuthz());
dom.setId(DirectoryEntryIdUtils.encode(dom.getName()));
model.setDomain(dom);
}
return model;
}
Aggregations