diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/AuthenticatorsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/AuthenticatorsApiServiceImpl.java index 100fc12286..f3dd6eb6f9 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/AuthenticatorsApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/AuthenticatorsApiServiceImpl.java @@ -19,11 +19,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.server.authenticators.v1.AuthenticatorsApiService; import org.wso2.carbon.identity.api.server.authenticators.v1.core.ServerAuthenticatorManagementService; +import org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator; import org.wso2.carbon.identity.api.server.authenticators.v1.model.UserDefinedLocalAuthenticatorCreation; import org.wso2.carbon.identity.api.server.authenticators.v1.model.UserDefinedLocalAuthenticatorUpdate; +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import java.net.URI; import javax.ws.rs.core.Response; +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; + /** * Implementation of the Server Authenticators Rest API. */ @@ -48,8 +53,11 @@ public Response authenticatorsMetaTagsGet() { public Response addUserDefinedLocalAuthenticator( UserDefinedLocalAuthenticatorCreation userDefinedLocalAuthenticatorCreation) { - return Response.ok().entity(authenticatorManagementService - .addUserDefinedLocalAuthenticator(userDefinedLocalAuthenticatorCreation)).build(); + Authenticator response = authenticatorManagementService + .addUserDefinedLocalAuthenticator(userDefinedLocalAuthenticatorCreation); + URI location = ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + + "/authenticator/custom/" + response.getId()); + return Response.created(location).entity(response).build(); } @Override diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/LocalAuthenticatorConfigBuilderFactory.java b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/LocalAuthenticatorConfigBuilderFactory.java index ef732d1ccb..0e36abed91 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/LocalAuthenticatorConfigBuilderFactory.java +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/impl/LocalAuthenticatorConfigBuilderFactory.java @@ -56,15 +56,16 @@ public class LocalAuthenticatorConfigBuilderFactory { public static Authenticator build(UserDefinedLocalAuthenticatorConfig config) { Authenticator authenticator = new Authenticator(); + String authenticatorId = base64URLEncode(config.getName()); authenticator.setName(config.getName()); - authenticator.setId(base64URLEncode(config.getName())); + authenticator.setId(authenticatorId); authenticator.setDisplayName(config.getDisplayName()); authenticator.setIsEnabled(config.isEnabled()); authenticator.setDefinedBy(Authenticator.DefinedByEnum.USER); authenticator.setType(Authenticator.TypeEnum.LOCAL); authenticator.setTags(Arrays.asList(config.getTags())); authenticator.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + - CONFIGS_AUTHENTICATOR_PATH_COMPONENT, config.getName())).toString()); + CONFIGS_AUTHENTICATOR_PATH_COMPONENT, authenticatorId)).toString()); return authenticator; }