Search in sources :

Example 31 with ExtMap

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

the class SsoUtils method processGroupMemberships.

private static Set<String> processGroupMemberships(Collection<ExtMap> memberships, Map<String, ExtMap> resolvedGroups) {
    Set<String> membershipIds = new HashSet<>();
    for (ExtMap origRecord : memberships) {
        ExtMap groupRecord = new ExtMap(origRecord);
        membershipIds.add(groupRecord.get(Authz.GroupRecord.ID));
        if (!resolvedGroups.containsKey(groupRecord.<String>get(Authz.GroupRecord.ID))) {
            resolvedGroups.put(groupRecord.get(Authz.GroupRecord.ID), groupRecord);
            groupRecord.put(Authz.GroupRecord.GROUPS, processGroupMemberships(groupRecord.get(Authz.GroupRecord.GROUPS, Collections.emptyList()), resolvedGroups));
        }
    }
    return membershipIds;
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) HashSet(java.util.HashSet)

Example 32 with ExtMap

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

the class TokenCleanupUtility method invokeAuthnLogout.

private static void invokeAuthnLogout(SsoContext ssoContext, SsoSession ssoSession) throws Exception {
    String profileName = ssoSession.getProfile();
    String principalName = ssoSession.getUserId();
    ExtMap authRecord = null;
    ExtensionProxy authn = null;
    try {
        authRecord = ssoSession.getAuthRecord();
        if (StringUtils.isNotEmpty(profileName) && StringUtils.isNotEmpty(principalName)) {
            for (ExtensionProxy authnExtension : ssoContext.getSsoExtensionsManager().getExtensionsByService(Authn.class.getName())) {
                Properties config = authnExtension.getContext().get(Base.ContextKeys.CONFIGURATION);
                if (profileName.equals(config.getProperty(Authn.ConfigKeys.PROFILE_NAME))) {
                    authn = authnExtension;
                    break;
                }
            }
        }
    } catch (Exception ex) {
        throw new RuntimeException(String.format("Unable to invalidate sessions for token: %s", ex.getMessage()));
    } finally {
        if (authn != null && authRecord != null && (authn.getContext().<Long>get(Authn.ContextKeys.CAPABILITIES) & Authn.Capabilities.LOGOUT) != 0) {
            authn.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authn.InvokeCommands.LOGOUT).mput(Authn.InvokeKeys.AUTH_RECORD, authRecord));
        }
    }
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) ExtensionProxy(org.ovirt.engine.core.extensions.mgr.ExtensionProxy) Authn(org.ovirt.engine.api.extensions.aaa.Authn) Properties(java.util.Properties)

Example 33 with ExtMap

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

the class DirectoryUtils method populateRecords.

private static Collection<ExtMap> populateRecords(final ExtensionProxy extension, final String namespace, final ExtMap input) {
    final List<ExtMap> records = new ArrayList<>();
    queryImpl(extension, namespace, input, (queryResults) -> {
        boolean result = true;
        for (ExtMap queryResult : queryResults) {
            if (records.size() < QUERIES_RESULTS_LIMIT) {
                records.add(queryResult);
            } else {
                result = false;
                break;
            }
        }
        return result;
    });
    return records;
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) ArrayList(java.util.ArrayList)

Example 34 with ExtMap

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

the class DirectoryUtils method queryImpl.

private static void queryImpl(final ExtensionProxy extension, final String namespace, final ExtMap input, final QueryResultHandler handler) {
    Object opaque = extension.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authz.InvokeCommands.QUERY_OPEN).mput(Authz.InvokeKeys.NAMESPACE, namespace).mput(input)).get(Authz.InvokeKeys.QUERY_OPAQUE);
    Collection<ExtMap> result = null;
    try {
        do {
            result = extension.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authz.InvokeCommands.QUERY_EXECUTE).mput(Authz.InvokeKeys.QUERY_OPAQUE, opaque).mput(Authz.InvokeKeys.PAGE_SIZE, PAGE_SIZE)).get(Authz.InvokeKeys.QUERY_RESULT);
        } while (result != null && handler.handle(result));
    } finally {
        extension.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authz.InvokeCommands.QUERY_CLOSE).mput(Authz.InvokeKeys.QUERY_OPAQUE, opaque));
    }
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap)

Example 35 with ExtMap

use of org.ovirt.engine.api.extensions.ExtMap 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

ExtMap (org.ovirt.engine.api.extensions.ExtMap)48 Collection (java.util.Collection)15 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)5 Map (java.util.Map)5 IOException (java.io.IOException)4 AuthenticationProfile (org.ovirt.engine.core.aaa.AuthenticationProfile)4 DirectoryGroup (org.ovirt.engine.core.aaa.DirectoryGroup)4 Properties (java.util.Properties)3 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)3 ExtensionProxy (org.ovirt.engine.core.extensions.mgr.ExtensionProxy)3 HashSet (java.util.HashSet)2 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 ServletException (javax.servlet.ServletException)2 ExtKey (org.ovirt.engine.api.extensions.ExtKey)2 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)2 QueryData (org.ovirt.engine.core.aaa.QueryData)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 CreateUserSessionParameters (org.ovirt.engine.core.common.action.CreateUserSessionParameters)2