Skip to content

Commit

Permalink
Add support for managing custom federated authenticators.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Nov 5, 2024
1 parent 377dc85 commit 16268ae
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 118 deletions.

This file was deleted.

48 changes: 0 additions & 48 deletions components/application-mgt/spotbugs-exclude.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3985,8 +3985,10 @@ public String addIdPWithResourceId(IdentityProvider identityProvider, int tenant
throw new IdentityProviderManagementException("An error occurred while processing content stream.", e);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
endpointConfigurationManager.deleteEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.deleteEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
throw new IdentityProviderManagementException("Error occurred while adding Identity Provider for tenant "
+ tenantId, e);
} catch (IdentityProviderManagementException e) {
Expand Down Expand Up @@ -4315,8 +4317,12 @@ public void updateIdPWithResourceId(String resourceId, IdentityProvider
throw new IdentityProviderManagementException("An error occurred while processing content stream.", e);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
endpointConfigurationManager.updateEndpointConfigurations(currentIdentityProvider
.getDefaultAuthenticatorConfig(), newIdentityProvider.getDefaultAuthenticatorConfig(), tenantId);
//
if (currentIdentityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.updateEndpointConfigurations(currentIdentityProvider
.getFederatedAuthenticatorConfigs()[0], newIdentityProvider.getFederatedAuthenticatorConfigs()[0],
tenantId);
}
throw new IdentityProviderManagementException("Error occurred while updating Identity Provider " +
"information for tenant " + tenantId, e);
} catch (IdentityProviderManagementException e) {
Expand Down Expand Up @@ -4394,14 +4400,18 @@ public void deleteIdP(String idPName, int tenantId, String tenantDomain)
String msg = "Trying to delete non-existent Identity Provider: %s in tenantDomain: %s";
throw new IdentityProviderManagementException(String.format(msg, idPName, tenantDomain));
}
endpointConfigurationManager.deleteEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.deleteEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
deleteIdP(dbConnection, tenantId, idPName, null);
IdentityDatabaseUtil.commitTransaction(dbConnection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
endpointConfigurationManager.addEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.addEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
throw new IdentityProviderManagementException("Error occurred while deleting Identity Provider of tenant "
+ tenantDomain, e);
} catch (IdentityProviderManagementException e) {
Expand Down Expand Up @@ -4454,16 +4464,20 @@ public void deleteIdPByResourceId(String resourceId, int tenantId, String tenant
throw new IdentityProviderManagementException(String.format(msg, resourceId, tenantDomain));
}
idPName = identityProvider.getIdentityProviderName();
endpointConfigurationManager.deleteEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.deleteEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
deleteIdP(dbConnection, tenantId, null, resourceId);
// Delete IdP related secrets from the IDN_SECRET table.
idpSecretsProcessorService.deleteAssociatedSecrets(identityProvider);
IdentityDatabaseUtil.commitTransaction(dbConnection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
endpointConfigurationManager.addEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.addEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
throw new IdentityProviderManagementException("Error occurred while deleting Identity Provider of tenant "
+ tenantDomain, e);
} catch (IdentityProviderManagementException e) {
Expand Down Expand Up @@ -4502,15 +4516,19 @@ public void forceDeleteIdP(String idPName,
log.debug(String.format("Deleting SP Provisioning Associations for IDP:%s of tenantDomain:%s",
idPName, tenantDomain));
}
endpointConfigurationManager.deleteEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.deleteEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
deleteIdpSpProvisioningAssociations(dbConnection, tenantId, idPName);
deleteIdP(dbConnection, tenantId, idPName, null);
IdentityDatabaseUtil.commitTransaction(dbConnection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
endpointConfigurationManager.addEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.addEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
throw new IdentityProviderManagementException(
String.format("Error occurred while deleting Identity Provider:%s of tenant:%s ",
idPName, tenantDomain), e);
Expand Down Expand Up @@ -4549,14 +4567,18 @@ public void forceDeleteIdPByResourceId(String resourceId, int tenantId, String t
identityProvider.getIdentityProviderName(), tenantDomain));
}
deleteIdpSpProvisioningAssociations(dbConnection, tenantId, identityProvider.getIdentityProviderName());
endpointConfigurationManager.deleteEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.deleteEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
deleteIdP(dbConnection, tenantId, null, resourceId);
IdentityDatabaseUtil.commitTransaction(dbConnection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
endpointConfigurationManager.addEndpointConfigurations(identityProvider.getDefaultAuthenticatorConfig(),
tenantId);
if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) {
endpointConfigurationManager.addEndpointConfigurations(
identityProvider.getFederatedAuthenticatorConfigs()[0], tenantId);
}
throw new IdentityProviderManagementException(
String.format("Error occurred while deleting Identity Provider with resource ID:%s of tenant:%s ",
resourceId, tenantDomain), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public static IdpMgtServiceComponentHolder getInstance() {
private RoleManagementService roleManagementService;
private ClaimMetadataManagementService claimMetadataManagementService;
private SecretManager secretManager;
private SecretResolveManager secretResolveManager;
private SecretResolveManager secretResolveManager;
private ActionManagementService actionManagementService;

private List<MetadataConverter> metadataConverters = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(Authentic
}

return new UserDefinedFederatedAuthenticatorConfig(
AuthenticatorPropertyConstants.AuthenticationType.Identification);
AuthenticatorPropertyConstants.AuthenticationType.IDENTIFICATION);
}

private Action buildActionToCreate(String authenticatorName, EndpointConfig endpointConfig) {
Expand Down

0 comments on commit 16268ae

Please sign in to comment.