Search in sources :

Example 21 with ExtMap

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

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

the class InternalAuthz method doLoad.

private void doLoad(ExtMap input) {
    ExtMap context = input.get(Base.InvokeKeys.CONTEXT);
    Properties configuration = context.get(Base.ContextKeys.CONFIGURATION);
    context.mput(Base.ContextKeys.AUTHOR, "The oVirt Project").mput(Base.ContextKeys.EXTENSION_NAME, "Internal Authz (Built-in)").mput(Base.ContextKeys.LICENSE, "ASL 2.0").mput(Base.ContextKeys.HOME_URL, "http://www.ovirt.org").mput(Base.ContextKeys.VERSION, "N/A").mput(Authz.ContextKeys.QUERY_MAX_FILTER_SIZE, Integer.parseInt(configuration.getProperty("config.query.filter.size", "10"))).mput(Base.ContextKeys.BUILD_INTERFACE_VERSION, Base.INTERFACE_VERSION_CURRENT).mput(Authz.ContextKeys.AVAILABLE_NAMESPACES, Collections.singletonList(NAMESPACE));
    adminUser = new ExtMap().mput(Authz.PrincipalRecord.NAMESPACE, NAMESPACE).mput(Authz.PrincipalRecord.NAME, configuration.getProperty("config.authz.user.name", DEFAULT_PRINCIPAL_NAME)).mput(Authz.PrincipalRecord.FIRST_NAME, configuration.getProperty("config.authz.user.name", DEFAULT_PRINCIPAL_NAME)).mput(Authz.PrincipalRecord.ID, configuration.getProperty("config.authz.user.id", DEFAULT_PRINCIPAL_ID)).mput(Authz.PrincipalRecord.PRINCIPAL, configuration.getProperty("config.authz.user.name", DEFAULT_PRINCIPAL_NAME));
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) Properties(java.util.Properties)

Example 23 with ExtMap

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

the class InternalAuthz method doFetchPrincipalRecord.

private void doFetchPrincipalRecord(ExtMap input, ExtMap output) {
    ExtMap authRecord = input.get(Authn.InvokeKeys.AUTH_RECORD);
    String principal = authRecord != null ? authRecord.get(Authn.AuthRecord.PRINCIPAL) : input.get(Authz.InvokeKeys.PRINCIPAL);
    if (principal.equals(adminUser.<String>get(Authz.PrincipalRecord.NAME))) {
        output.put(Authz.InvokeKeys.PRINCIPAL_RECORD, adminUser);
    }
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap)

Example 24 with ExtMap

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

the class AuthzUtils method populateRecords.

public static Collection<ExtMap> populateRecords(final ExtensionProxy extension, final String namespace, final ExtMap input) {
    final Collection<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 25 with ExtMap

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

the class AuthzUtils method fetchPrincipalRecordImpl.

private static ExtMap fetchPrincipalRecordImpl(final ExtensionProxy extension, ExtMap m, boolean resolveGroups, boolean resolveGroupsRecursive) {
    ExtMap ret = null;
    ExtMap output = extension.invoke(m.mput(Base.InvokeKeys.COMMAND, Authz.InvokeCommands.FETCH_PRINCIPAL_RECORD).mput(Authz.InvokeKeys.QUERY_FLAGS, (resolveGroups ? Authz.QueryFlags.RESOLVE_GROUPS : 0) | (resolveGroupsRecursive ? Authz.QueryFlags.RESOLVE_GROUPS_RECURSIVE : 0)));
    if (output.<Integer>get(Authz.InvokeKeys.STATUS) == Authz.Status.SUCCESS) {
        ret = output.get(Authz.InvokeKeys.PRINCIPAL_RECORD);
    }
    return ret;
}
Also used : 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