Skip to content

Commit

Permalink
Validate system authenticators names at registering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Feb 14, 2025
1 parent d5366d7 commit bc178fe
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
import org.wso2.carbon.identity.role.v2.mgt.core.RoleManagementService;
import org.wso2.carbon.identity.secret.mgt.core.SecretResolveManager;
import org.wso2.carbon.identity.user.profile.mgt.association.federation.FederatedAssociationManager;
import org.wso2.carbon.idp.mgt.IdentityProviderManagementServerException;
import org.wso2.carbon.idp.mgt.IdpManager;
import org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener;
import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
Expand Down Expand Up @@ -477,8 +478,16 @@ protected void unsetRealmService(RealmService realmService) {
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetAuthenticator"
)
protected void setAuthenticator(ApplicationAuthenticator authenticator) {

protected void setAuthenticator(ApplicationAuthenticator authenticator)
throws IdentityProviderManagementServerException {

/* All custom authenticator names must start with the `custom_` prefix. If a system-defined authenticator is
attempted to be registered at server startup with a name starting with this prefix, an error will be thrown.*/
if (authenticator.getName().startsWith("custom_")) {
throw new IdentityProviderManagementServerException(String.format("System-defined authenticator names " +
"are not allowed to have the custom_ prefix. Therefore, %s cannot be registered.",
authenticator.getName()));
}
ApplicationAuthenticatorManager.getInstance().addSystemDefinedAuthenticator(authenticator);

Property[] configProperties = null;
Expand Down

0 comments on commit bc178fe

Please sign in to comment.