use of edu.harvard.iq.dataverse.authorization.exceptions.AuthenticationProviderFactoryNotFoundException in project dataverse by IQSS.
the class AuthenticationServiceBean method startup.
@PostConstruct
public void startup() {
// First, set up the factories
try {
registerProviderFactory(new BuiltinAuthenticationProviderFactory(builtinUserServiceBean, passwordValidatorService));
registerProviderFactory(new ShibAuthenticationProviderFactory());
registerProviderFactory(new OAuth2AuthenticationProviderFactory());
} catch (AuthorizationSetupException ex) {
logger.log(Level.SEVERE, "Exception setting up the authentication provider factories: " + ex.getMessage(), ex);
}
// Now, load the providers.
em.createNamedQuery("AuthenticationProviderRow.findAllEnabled", AuthenticationProviderRow.class).getResultList().forEach((row) -> {
try {
registerProvider(loadProvider(row));
} catch (AuthenticationProviderFactoryNotFoundException e) {
logger.log(Level.SEVERE, "Cannot find authentication provider factory with alias '" + e.getFactoryAlias() + "'", e);
} catch (AuthorizationSetupException ex) {
logger.log(Level.SEVERE, "Exception setting up the authentication provider '" + row.getId() + "': " + ex.getMessage(), ex);
}
});
}
use of edu.harvard.iq.dataverse.authorization.exceptions.AuthenticationProviderFactoryNotFoundException in project dataverse by IQSS.
the class Admin method enableAuthenticationProvider.
@PUT
@Path("authenticationProviders/{id}/enabled")
@Produces("application/json")
public Response enableAuthenticationProvider(@PathParam("id") String id, String body) {
body = body.trim();
if (!Util.isBoolean(body)) {
return error(Response.Status.BAD_REQUEST, "Illegal value '" + body + "'. Use 'true' or 'false'");
}
boolean enable = Util.isTrue(body);
AuthenticationProviderRow row = em.find(AuthenticationProviderRow.class, id);
if (row == null) {
return notFound("Can't find authentication provider with id '" + id + "'");
}
row.setEnabled(enable);
em.merge(row);
if (enable) {
// enable a provider
if (authSvc.getAuthenticationProvider(id) != null) {
return ok(String.format("Authentication provider '%s' already enabled", id));
}
try {
authSvc.registerProvider(authSvc.loadProvider(row));
return ok(String.format("Authentication Provider %s enabled", row.getId()));
} catch (AuthenticationProviderFactoryNotFoundException ex) {
return notFound(String.format("Can't instantiate provider, as there's no factory with alias %s", row.getFactoryAlias()));
} catch (AuthorizationSetupException ex) {
logger.log(Level.WARNING, "Error instantiating authentication provider: " + ex.getMessage(), ex);
return error(Status.INTERNAL_SERVER_ERROR, String.format("Can't instantiate provider: %s", ex.getMessage()));
}
} else {
// disable a provider
authSvc.deregisterProvider(id);
return ok("Authentication Provider '" + id + "' disabled. " + (authSvc.getAuthenticationProviderIds().isEmpty() ? "WARNING: no enabled authentication providers left." : ""));
}
}
Aggregations