Search in sources :

Example 1 with Authn

use of org.ovirt.engine.api.extensions.aaa.Authn 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 Authn

use of org.ovirt.engine.api.extensions.aaa.Authn 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)

Example 3 with Authn

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

Aggregations

Authn (org.ovirt.engine.api.extensions.aaa.Authn)3 ExtensionProxy (org.ovirt.engine.core.extensions.mgr.ExtensionProxy)3 HashMap (java.util.HashMap)2 ConfigurationException (org.ovirt.engine.core.extensions.mgr.ConfigurationException)2 Properties (java.util.Properties)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExtMap (org.ovirt.engine.api.extensions.ExtMap)1