use of io.gravitee.management.idp.api.IdentityProvider in project gravitee-management-rest-api by gravitee-io.
the class BasicSecurityConfigurerAdapter method configure.
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
LOGGER.info("Loading authentication identity providers for Basic authentication");
List<io.gravitee.management.security.authentication.AuthenticationProvider> providers = authenticationProviderManager.getIdentityProviders().stream().filter(authenticationProvider -> !authenticationProvider.external()).collect(Collectors.toList());
for (io.gravitee.management.security.authentication.AuthenticationProvider provider : providers) {
LOGGER.info("Loading authentication provider of type {} at position {}", provider.type(), provider.index());
boolean found = false;
Collection<IdentityProvider> identityProviders = identityProviderManager.getAll();
for (IdentityProvider identityProvider : identityProviders) {
if (identityProvider.type().equalsIgnoreCase(provider.type())) {
AuthenticationProvider authenticationProviderPlugin = identityProviderManager.loadIdentityProvider(identityProvider.type(), provider.configuration());
if (authenticationProviderPlugin != null) {
Object authenticationProvider = authenticationProviderPlugin.configure();
if (authenticationProvider instanceof org.springframework.security.authentication.AuthenticationProvider) {
auth.authenticationProvider((org.springframework.security.authentication.AuthenticationProvider) authenticationProvider);
} else if (authenticationProvider instanceof SecurityConfigurer) {
auth.apply((SecurityConfigurer) authenticationProvider);
}
found = true;
break;
}
}
}
if (!found) {
LOGGER.error("No authentication provider found for type: {}", provider.type());
throw new IllegalStateException("No authentication provider found for type: " + provider.type());
}
}
}
use of io.gravitee.management.idp.api.IdentityProvider in project gravitee-management-rest-api by gravitee-io.
the class IdentityProviderManagerImpl method authenticationProvider.
private AuthenticationProvider authenticationProvider(String identityProviderType, Map<String, Object> properties) {
LOGGER.debug("Looking for an authentication provider for [{}]", identityProviderType);
IdentityProvider identityProvider = identityProviders.get(identityProviderType);
if (identityProvider != null) {
return create(identityProviderPlugins.get(identityProvider), identityProvider.authenticationProvider(), properties);
} else {
LOGGER.error("No identity provider is registered for type {}", identityProviderType);
throw new IllegalStateException("No identity provider is registered for type " + identityProviderType);
}
}
use of io.gravitee.management.idp.api.IdentityProvider in project gravitee-management-rest-api by gravitee-io.
the class IdentityProviderManagerImpl method identityLookup.
private IdentityLookup identityLookup(String identityProviderType, Map<String, Object> properties) {
LOGGER.debug("Looking for an identity lookup for [{}]", identityProviderType);
IdentityProvider identityProvider = identityProviders.get(identityProviderType);
if (identityProvider != null) {
return create(identityProviderPlugins.get(identityProvider), identityProvider.identityLookup(), properties);
} else {
LOGGER.error("No identity provider is registered for type {}", identityProviderType);
throw new IllegalStateException("No identity provider is registered for type " + identityProviderType);
}
}
use of io.gravitee.management.idp.api.IdentityProvider in project gravitee-management-rest-api by gravitee-io.
the class IdentityProviderPluginHandler method handle.
@Override
public void handle(Plugin plugin) {
try {
ClassLoader classloader = pluginClassLoaderFactory.getOrCreateClassLoader(plugin, this.getClass().getClassLoader());
final Class<?> identityProviderClass = classloader.loadClass(plugin.clazz());
LOGGER.info("Register a new identity provider plugin: {} [{}]", plugin.id(), plugin.clazz());
Assert.isAssignable(IdentityProvider.class, identityProviderClass);
IdentityProvider identityIdentityProvider = createInstance((Class<IdentityProvider>) identityProviderClass);
identityProviderManager.register(new IdentityProviderDefinition(identityIdentityProvider, plugin));
} catch (Exception iae) {
LOGGER.error("Unexpected error while create identity provider instance", iae);
}
}
Aggregations