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