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;
}
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));
}
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);
}
}
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;
}
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;
}
Aggregations