Skip to content

Commit

Permalink
Rename AuthenticationProviderFactoryNotFoundException to Authenticati…
Browse files Browse the repository at this point in the history
…onProviderConfigurationException as we remove the current factory pattern, remove invalid catch in Admin API. IQSS#6694
  • Loading branch information
poikilotherm committed Mar 13, 2020
1 parent f840b82 commit 6189053
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 43 deletions.
5 changes: 0 additions & 5 deletions src/main/java/edu/harvard/iq/dataverse/api/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo;
import edu.harvard.iq.dataverse.authorization.providers.AuthenticationProvider;
import edu.harvard.iq.dataverse.authorization.UserIdentifier;
import edu.harvard.iq.dataverse.authorization.exceptions.AuthenticationProviderFactoryNotFoundException;
import edu.harvard.iq.dataverse.authorization.exceptions.AuthorizationSetupException;
import edu.harvard.iq.dataverse.authorization.groups.GroupServiceBean;
import edu.harvard.iq.dataverse.authorization.providers.AuthenticationProviderRow;
Expand Down Expand Up @@ -266,10 +265,6 @@ public Response enableAuthenticationProvider(@PathParam("id") String id, String
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import edu.harvard.iq.dataverse.actionlogging.ActionLogRecord;
import edu.harvard.iq.dataverse.actionlogging.ActionLogServiceBean;
import edu.harvard.iq.dataverse.authorization.exceptions.AuthenticationFailedException;
import edu.harvard.iq.dataverse.authorization.exceptions.AuthenticationProviderFactoryNotFoundException;
import edu.harvard.iq.dataverse.authorization.exceptions.AuthenticationProviderConfigurationException;
import edu.harvard.iq.dataverse.authorization.exceptions.AuthorizationSetupException;
import edu.harvard.iq.dataverse.authorization.providers.AuthenticationProviderFactory;
import edu.harvard.iq.dataverse.authorization.providers.AuthenticationProviderRow;
Expand Down Expand Up @@ -126,10 +126,6 @@ public void startup() {
.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);
}
Expand All @@ -152,14 +148,12 @@ public void registerProviderFactory(AuthenticationProviderFactory aFactory)
* Tries to load and {@link AuthenticationProvider} using the passed {@link AuthenticationProviderRow}.
* @param aRow The row to load the provider from.
* @return The provider, if successful
* @throws AuthenticationProviderFactoryNotFoundException If the row specifies a non-existent factory
* @throws AuthorizationSetupException If the factory failed to instantiate a provider from the row.
*/
public AuthenticationProvider loadProvider( AuthenticationProviderRow aRow )
throws AuthenticationProviderFactoryNotFoundException, AuthorizationSetupException {
public AuthenticationProvider loadProvider( AuthenticationProviderRow aRow ) throws AuthorizationSetupException {
AuthenticationProviderFactory fact = getProviderFactory(aRow.getFactoryAlias());

if ( fact == null ) throw new AuthenticationProviderFactoryNotFoundException(aRow.getFactoryAlias());
if ( fact == null ) throw new AuthenticationProviderConfigurationException(aRow.getFactoryAlias());

return fact.buildProvider(aRow);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package edu.harvard.iq.dataverse.authorization.exceptions;

import edu.harvard.iq.dataverse.authorization.providers.AuthenticationProvider;
import edu.harvard.iq.dataverse.authorization.providers.AuthenticationProviderFactory;
import edu.harvard.iq.dataverse.authorization.providers.AuthenticationProviderRow;

/**
* Thrown when trying to build an {@link AuthenticationProviderConfiguration}, but failing.
*/
public class AuthenticationProviderConfigurationException extends AuthorizationSetupException {
public AuthenticationProviderConfigurationException(String cause) {
super(cause);
}
}

This file was deleted.

0 comments on commit 6189053

Please sign in to comment.