Search in sources :

Example 1 with ExtKey

use of org.ovirt.engine.api.extensions.ExtKey in project ovirt-engine by oVirt.

the class InternalAuthz method doQueryOpenImpl.

private boolean doQueryOpenImpl(ExtMap filter) {
    boolean found = false;
    if (filter.<Integer>get(Authz.QueryFilterRecord.OPERATOR) == Authz.QueryFilterOperator.EQ) {
        ExtKey extKey = filter.get(Authz.QueryFilterRecord.KEY);
        if (extKey.equals(Authz.PrincipalRecord.NAME)) {
            String name = filter.get(Authz.PrincipalRecord.NAME);
            found = adminUser.<String>get(Authz.PrincipalRecord.NAME).matches(name.replace("*", ".*"));
        } else if (extKey.equals(Authz.PrincipalRecord.ID)) {
            found = filter.<String>get(Authz.PrincipalRecord.ID).equals(adminUser.<String>get(Authz.PrincipalRecord.ID));
        } else {
            found = false;
        }
    } else {
        for (ExtMap currentFilter : filter.<Collection<ExtMap>>get(Authz.QueryFilterRecord.FILTER)) {
            found = found || doQueryOpenImpl(currentFilter);
        }
    }
    return found;
}
Also used : ExtKey(org.ovirt.engine.api.extensions.ExtKey) ExtMap(org.ovirt.engine.api.extensions.ExtMap) Collection(java.util.Collection)

Example 2 with ExtKey

use of org.ovirt.engine.api.extensions.ExtKey in project ovirt-engine by oVirt.

the class SearchParsingUtils method generateQueryMap.

public static ExtMap generateQueryMap(Collection<String> ids, ExtUUID queryEntity) {
    ExtMap result = new ExtMap().mput(Authz.InvokeKeys.QUERY_ENTITY, queryEntity);
    ExtKey key = queryEntity.equals(Authz.QueryEntity.GROUP) ? Authz.GroupRecord.ID : Authz.PrincipalRecord.ID;
    List<ExtMap> filter = ids.stream().map((id) -> createMapForKeyAndValue(key, id)).collect(Collectors.toList());
    result.mput(QueryFilterRecord.OPERATOR, QueryFilterOperator.OR).mput(QueryFilterRecord.FILTER, filter);
    return result;
}
Also used : ExtKey(org.ovirt.engine.api.extensions.ExtKey) Arrays(java.util.Arrays) ExtUUID(org.ovirt.engine.api.extensions.ExtUUID) Authz(org.ovirt.engine.api.extensions.aaa.Authz) ExtMap(org.ovirt.engine.api.extensions.ExtMap) Collection(java.util.Collection) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) QueryFilterRecord(org.ovirt.engine.api.extensions.aaa.Authz.QueryFilterRecord) Map(java.util.Map) QueryFilterOperator(org.ovirt.engine.api.extensions.aaa.Authz.QueryFilterOperator) ExtKey(org.ovirt.engine.api.extensions.ExtKey) ExtMap(org.ovirt.engine.api.extensions.ExtMap)

Aggregations

Collection (java.util.Collection)2 ExtKey (org.ovirt.engine.api.extensions.ExtKey)2 ExtMap (org.ovirt.engine.api.extensions.ExtMap)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 ExtUUID (org.ovirt.engine.api.extensions.ExtUUID)1 Authz (org.ovirt.engine.api.extensions.aaa.Authz)1 QueryFilterOperator (org.ovirt.engine.api.extensions.aaa.Authz.QueryFilterOperator)1 QueryFilterRecord (org.ovirt.engine.api.extensions.aaa.Authz.QueryFilterRecord)1