use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class ExtensionProxy method invoke.
public ExtMap invoke(ExtMap input, boolean allowUnsupported, boolean allowFail) {
ExtMap output = new ExtMap();
invoke(input, output);
String message = output.get(Base.InvokeKeys.MESSAGE);
switch(output.<Integer>get(Base.InvokeKeys.RESULT, Base.InvokeResult.FAILED)) {
case Base.InvokeResult.SUCCESS:
break;
case Base.InvokeResult.UNSUPPORTED:
if (!allowUnsupported) {
throw new ExtensionInvokeCommandUnsupportedException(message == null ? "Unsupported command" : message, input, output);
}
break;
case Base.InvokeResult.FAILED:
default:
if (!allowFail) {
throw new ExtensionInvokeCommandFailedException(message == null ? "Invoke failed" : message, input, output, output.get(ExtensionsManager.CAUSE_OUTPUT_KEY));
}
break;
}
return output;
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class SsoOAuthServiceUtils method getTokenInfo.
public static Map<String, Object> getTokenInfo(String token, String scope) {
try {
HttpPost request = createPost("/oauth/token-info");
setClientIdSecretBasicAuthHeader(request);
List<BasicNameValuePair> form = new ArrayList<>(2);
form.add(new BasicNameValuePair("token", token));
if (StringUtils.isNotEmpty(scope)) {
form.add(new BasicNameValuePair("scope", scope));
}
request.setEntity(new UrlEncodedFormEntity(form, StandardCharsets.UTF_8));
Map<String, Object> jsonData = getResponse(request);
Map<String, Object> ovirtData = (Map<String, Object>) jsonData.get("ovirt");
if (ovirtData != null) {
Collection<ExtMap> groupIds = (Collection<ExtMap>) ovirtData.get("group_ids");
if (groupIds != null) {
ovirtData.put("group_ids", SsoOAuthServiceUtils.processGroupMembershipsFromJson(groupIds));
}
}
return jsonData;
} catch (Exception ex) {
return buildMapWithError("server_error", ex.getMessage());
}
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class NegotiationFilter method cacheNegotiatingProfiles.
private synchronized void cacheNegotiatingProfiles() {
schemes = new ArrayList<>();
profiles = new ArrayList<>();
for (AuthenticationProfile profile : AuthenticationProfileRepository.getInstance().getProfiles()) {
ExtMap authnContext = profile.getAuthn().getContext();
if ((authnContext.<Long>get(Authn.ContextKeys.CAPABILITIES).longValue() & caps) != 0) {
profiles.add(profile);
schemes.addAll(authnContext.<Collection<String>>get(Authn.ContextKeys.HTTP_AUTHENTICATION_SCHEME, Collections.<String>emptyList()));
}
}
Collections.sort(profiles, Comparator.comparing(AuthenticationProfile::getNegotiationPriority));
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class AAAServiceImpl method acctReport.
private void acctReport(int reason, String authzName, ExtMap authRecord, ExtMap principalRecord, String user, String msg) {
String displayUser = null;
if (displayUser == null && principalRecord != null) {
displayUser = principalRecord.get(Authz.PrincipalRecord.NAME);
}
if (displayUser == null && authRecord != null) {
displayUser = authRecord.get(Authn.AuthRecord.PRINCIPAL);
}
if (displayUser == null) {
displayUser = user;
}
String displayMessage = String.format(msg, displayUser);
List<ExtensionProxy> acctExtensions = getExtensionsManager().getExtensionsByService(Acct.class.getName());
if (acctExtensions != null) {
ExtMap input = new ExtMap().mput(Acct.InvokeKeys.REASON, reason).mput(Base.InvokeKeys.COMMAND, Acct.InvokeCommands.REPORT).mput(Acct.InvokeKeys.PRINCIPAL_RECORD, new ExtMap().mput(Acct.PrincipalRecord.AUTHZ_NAME, authzName).mput(Acct.PrincipalRecord.AUTH_RECORD, authRecord).mput(Acct.PrincipalRecord.PRINCIPAL_RECORD, principalRecord).mput(Acct.PrincipalRecord.USER, displayUser).mput(Acct.InvokeKeys.MESSAGE, String.format(displayMessage, displayUser)));
for (ExtensionProxy proxy : acctExtensions) {
log.info("API: -->Acct.InvokeCommands.REPORT extension={}, reason={}, user='{}', message='{}'", proxy.getContext().get(Base.ContextKeys.INSTANCE_NAME), getFieldNameByValue(Acct.ReportReason.class, reason), displayUser, displayMessage);
proxy.invoke(input);
log.info("API: <--Acct.InvokeCommands.REPORT");
}
}
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class CreateUserSessionCommand method flatGroups.
private static void flatGroups(Collection<ExtMap> groupIds, Map<String, ExtMap> accumulator) {
for (ExtMap group : groupIds) {
if (!accumulator.containsKey(group.<String>get(Authz.GroupRecord.ID))) {
accumulator.put(group.get(Authz.GroupRecord.ID), group);
flatGroups(group, Authz.GroupRecord.GROUPS, accumulator);
}
}
}
Aggregations