Search in sources :

Example 6 with DirectoryGroup

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;
}
Also used : Group(org.ovirt.engine.api.model.Group) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) Groups(org.ovirt.engine.api.model.Groups)

Example 7 with DirectoryGroup

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;
}
Also used : Group(org.ovirt.engine.api.model.Group) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) AuthzGroup(org.ovirt.engine.core.common.businessentities.aaa.AuthzGroup) Domain(org.ovirt.engine.api.model.Domain)

Example 8 with DirectoryGroup

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;
}
Also used : DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) ExtMap(org.ovirt.engine.api.extensions.ExtMap) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) ArrayList(java.util.ArrayList)

Example 9 with DirectoryGroup

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;
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) ArrayList(java.util.ArrayList) Collection(java.util.Collection)

Aggregations

DirectoryGroup (org.ovirt.engine.core.aaa.DirectoryGroup)9 Collection (java.util.Collection)4 ExtMap (org.ovirt.engine.api.extensions.ExtMap)4 ArrayList (java.util.ArrayList)3 Group (org.ovirt.engine.api.model.Group)3 Domain (org.ovirt.engine.api.model.Domain)2 Groups (org.ovirt.engine.api.model.Groups)2 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)2 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)2 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)2 User (org.ovirt.engine.api.model.User)1 QueryData (org.ovirt.engine.core.aaa.QueryData)1 AddGroupParameters (org.ovirt.engine.core.common.action.AddGroupParameters)1 Queryable (org.ovirt.engine.core.common.businessentities.Queryable)1 AuthzGroup (org.ovirt.engine.core.common.businessentities.aaa.AuthzGroup)1 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)1 Guid (org.ovirt.engine.core.compat.Guid)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1