Search in sources :

Example 1 with ExtensionProxy

use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.

the class SsoContext method createProfiles.

private void createProfiles() {
    // Get the extensions that correspond to authn (authentication) service.
    // For each extension - get the relevant authn extension.
    Map<String, AuthenticationProfile> results = new HashMap<>();
    for (ExtensionProxy authnExtension : ssoExtensionsManager.getExtensionsByService(Authn.class.getName())) {
        try {
            String mapperName = authnExtension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION).getProperty(Authn.ConfigKeys.MAPPING_PLUGIN);
            String authzName = authnExtension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION).getProperty(Authn.ConfigKeys.AUTHZ_PLUGIN);
            AuthenticationProfile profile = new AuthenticationProfile(authnExtension, ssoExtensionsManager.getExtensionByName(authzName), mapperName != null ? ssoExtensionsManager.getExtensionByName(mapperName) : null);
            if (results.containsKey(profile.getName())) {
                log.warn("Profile name '{}' already registered for '{}', ignoring for '{}'", profile.getName(), results.get(profile.getName()).getAuthnName(), profile.getAuthnName());
            } else {
                results.put(profile.getName(), profile);
            }
        } catch (ConfigurationException e) {
            log.debug("Exception", e);
        }
    }
    profiles = results;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConfigurationException(org.ovirt.engine.core.extensions.mgr.ConfigurationException) ExtensionProxy(org.ovirt.engine.core.extensions.mgr.ExtensionProxy) Authn(org.ovirt.engine.api.extensions.aaa.Authn)

Example 2 with ExtensionProxy

use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.

the class AuthenticationUtils method getProfileEntry.

private static Map<String, Object> getProfileEntry(SsoExtensionsManager extensionsManager, ExtensionProxy authn) {
    Map<String, Object> profileEntry = new HashMap<>();
    profileEntry.put("authn_name", getProfileName(authn));
    ExtensionProxy authz = extensionsManager.getExtensionByName(getAuthzName(authn));
    profileEntry.put("authz_name", AuthzUtils.getName(authz));
    profileEntry.put("capability_password_auth", AuthzUtils.supportsPasswordAuthentication(authz));
    return profileEntry;
}
Also used : HashMap(java.util.HashMap) ExtensionProxy(org.ovirt.engine.core.extensions.mgr.ExtensionProxy)

Example 3 with ExtensionProxy

use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy 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");
        }
    }
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) ExtensionProxy(org.ovirt.engine.core.extensions.mgr.ExtensionProxy) Acct(org.ovirt.engine.api.extensions.aaa.Acct)

Example 4 with ExtensionProxy

use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.

the class AcctUtils method report.

public static void report(ExtMap input) {
    List<ExtensionProxy> acctExtensions = EngineExtensionsManager.getInstance().getExtensionsByService(Acct.class.getName());
    input.putIfAbsent(Base.InvokeKeys.COMMAND, Acct.InvokeCommands.REPORT);
    if (acctExtensions != null) {
        for (ExtensionProxy proxy : acctExtensions) {
            proxy.invoke(input);
        }
    }
}
Also used : ExtensionProxy(org.ovirt.engine.core.extensions.mgr.ExtensionProxy) Acct(org.ovirt.engine.api.extensions.aaa.Acct)

Example 5 with ExtensionProxy

use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.

the class AuthenticationProfileRepository method createProfiles.

private void createProfiles() {
    // Get the extensions that correspond to authn (authentication) service.
    // For each extension - get the relevant authn extension.
    Map<String, AuthenticationProfile> results = new HashMap<>();
    for (ExtensionProxy authnExtension : EngineExtensionsManager.getInstance().getExtensionsByService(Authn.class.getName())) {
        try {
            String mapperName = authnExtension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION).getProperty(Authn.ConfigKeys.MAPPING_PLUGIN);
            String authzName = authnExtension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION).getProperty(Authn.ConfigKeys.AUTHZ_PLUGIN);
            AuthenticationProfile profile = new AuthenticationProfile(authnExtension, authzName, mapperName != null ? EngineExtensionsManager.getInstance().getExtensionByName(mapperName) : null);
            if (results.containsKey(profile.getName())) {
                log.warn("Profile name '{}' already registered for '{}', ignoring for '{}'", profile.getName(), results.get(profile.getName()).getAuthnName(), profile.getAuthnName());
            } else {
                results.put(profile.getName(), profile);
            }
        } catch (ConfigurationException e) {
            log.debug("Ignoring", e);
        }
    }
    profiles = results;
    setChanged();
    notifyObservers();
}
Also used : HashMap(java.util.HashMap) ConfigurationException(org.ovirt.engine.core.extensions.mgr.ConfigurationException) ExtensionProxy(org.ovirt.engine.core.extensions.mgr.ExtensionProxy) Authn(org.ovirt.engine.api.extensions.aaa.Authn)

Aggregations

ExtensionProxy (org.ovirt.engine.core.extensions.mgr.ExtensionProxy)9 HashMap (java.util.HashMap)3 ExtMap (org.ovirt.engine.api.extensions.ExtMap)3 Authn (org.ovirt.engine.api.extensions.aaa.Authn)3 File (java.io.File)2 Properties (java.util.Properties)2 Acct (org.ovirt.engine.api.extensions.aaa.Acct)2 ConfigurationException (org.ovirt.engine.core.extensions.mgr.ConfigurationException)2 ArrayList (java.util.ArrayList)1 Arrays.sort (java.util.Arrays.sort)1 Collection (java.util.Collection)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Pattern (java.util.regex.Pattern)1 Base (org.ovirt.engine.api.extensions.Base)1 ExtensionsManager (org.ovirt.engine.core.extensions.mgr.ExtensionsManager)1 EngineLocalConfig (org.ovirt.engine.core.utils.EngineLocalConfig)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1