From 6e7ae1512d7ff7c125819c45a68af98ca57d2b54 Mon Sep 17 00:00:00 2001 From: dhaura Date: Mon, 10 Jun 2024 17:49:37 +0530 Subject: [PATCH] Rename masking method method to 'getMaskedValue'. --- ...ction.java => GetMaskedValueFunction.java} | 12 +++++------ ...l.java => GetMaskedValueFunctionImpl.java} | 8 ++++---- .../UtilsFunctionServiceComponent.java | 12 +++++------ ...va => GetMaskedValueFunctionImplTest.java} | 20 +++++++++---------- ...content-sp.xml => get-masked-value-sp.xml} | 2 +- .../src/test/resources/testng.xml | 4 ++-- 6 files changed, 29 insertions(+), 29 deletions(-) rename components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/{GetMaskedContentFunction.java => GetMaskedValueFunction.java} (72%) rename components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/{GetMaskedContentFunctionImpl.java => GetMaskedValueFunctionImpl.java} (81%) rename components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/utils/{GetMaskedContentFunctionImplTest.java => GetMaskedValueFunctionImplTest.java} (84%) rename components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/org/wso2/carbon/identity/conditional/auth/functions/utils/{get-masked-content-sp.xml => get-masked-value-sp.xml} (97%) diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunction.java b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunction.java similarity index 72% rename from components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunction.java rename to components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunction.java index fb0bed9b..4d52495b 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunction.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunction.java @@ -19,16 +19,16 @@ package org.wso2.carbon.identity.conditional.auth.functions.utils; /** - * Function to mask the given content if log masking is enabled. + * Function to mask the given value if log masking is enabled. */ @FunctionalInterface -public interface GetMaskedContentFunction { +public interface GetMaskedValueFunction { /** - * Masks the given content if log masking is enabled. + * Masks the given value if log masking is enabled. * - * @param content The content to be masked. - * @return The masked content. + * @param value The value to be masked. + * @return The masked value. */ - String getMaskedContent(String content); + String getMaskedValue(String value); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunctionImpl.java b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunctionImpl.java similarity index 81% rename from components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunctionImpl.java rename to components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunctionImpl.java index be6bd179..869dc0e3 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunctionImpl.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunctionImpl.java @@ -22,14 +22,14 @@ import org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils; /** - * Implementation of {@link GetMaskedContentFunction}. + * Implementation of {@link GetMaskedValueFunction}. */ -public class GetMaskedContentFunctionImpl implements GetMaskedContentFunction { +public class GetMaskedValueFunctionImpl implements GetMaskedValueFunction { @Override @HostAccess.Export - public String getMaskedContent(String content) { + public String getMaskedValue(String value) { - return LoggerUtils.isLogMaskingEnable ? LoggerUtils.getMaskedContent(content) : content; + return LoggerUtils.isLogMaskingEnable ? LoggerUtils.getMaskedContent(value) : value; } } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/internal/UtilsFunctionServiceComponent.java b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/internal/UtilsFunctionServiceComponent.java index ff20790a..dbfbefb4 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/internal/UtilsFunctionServiceComponent.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/utils/internal/UtilsFunctionServiceComponent.java @@ -28,8 +28,8 @@ import org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry; import org.wso2.carbon.identity.conditional.auth.functions.utils.FilterAuthenticatorsFunction; import org.wso2.carbon.identity.conditional.auth.functions.utils.FilterAuthenticatorsFunctionImpl; -import org.wso2.carbon.identity.conditional.auth.functions.utils.GetMaskedContentFunction; -import org.wso2.carbon.identity.conditional.auth.functions.utils.GetMaskedContentFunctionImpl; +import org.wso2.carbon.identity.conditional.auth.functions.utils.GetMaskedValueFunction; +import org.wso2.carbon.identity.conditional.auth.functions.utils.GetMaskedValueFunctionImpl; import org.wso2.carbon.identity.conditional.auth.functions.utils.ResolveMultiAttributeLoginIdentifierFunction; import org.wso2.carbon.identity.conditional.auth.functions.utils.ResolveMultiAttributeLoginIdentifierFunctionImpl; @@ -56,9 +56,9 @@ protected void activate(ComponentContext ctxt) { jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "resolveMultiAttributeLoginIdentifier", resolveMultiAttributeLoginIdentifierFunctionImpl); - GetMaskedContentFunction getMaskedContentFunctionImpl = new GetMaskedContentFunctionImpl(); - jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getMaskedContent", - getMaskedContentFunctionImpl); + GetMaskedValueFunction getMaskedValueFunctionImpl = new GetMaskedValueFunctionImpl(); + jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getMaskedValue", + getMaskedValueFunctionImpl); } @Deactivate @@ -69,7 +69,7 @@ protected void deactivate(ComponentContext ctxt) { jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "filterAuthenticators"); jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "resolveMultiAttributeLoginIdentifier"); - jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getMaskedContent"); + jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getMaskedValue"); } } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunctionImplTest.java b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunctionImplTest.java similarity index 84% rename from components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunctionImplTest.java rename to components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunctionImplTest.java index de7611a9..75dda085 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedContentFunctionImplTest.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/java/org/wso2/carbon/identity/conditional/auth/functions/utils/GetMaskedValueFunctionImplTest.java @@ -41,12 +41,12 @@ import javax.servlet.http.HttpServletResponse; /** - * Test class for GetMaskedContentFunctionImpl. + * Test class for GetMaskedValueFunctionImplTest. */ @WithCarbonHome @WithH2Database(files = "dbscripts/h2.sql") @WithRealmService(injectToSingletons = {LoggerUtils.class, FrameworkServiceDataHolder.class}) -public class GetMaskedContentFunctionImplTest extends JsSequenceHandlerAbstractTest { +public class GetMaskedValueFunctionImplTest extends JsSequenceHandlerAbstractTest { @BeforeClass @Parameters({"scriptEngine"}) @@ -54,18 +54,18 @@ public void setUp(String scriptEngine) throws Exception { super.setUp(scriptEngine); CarbonConstants.ENABLE_LEGACY_AUTHZ_RUNTIME = true; - sequenceHandlerRunner.registerJsFunction("getMaskedContent", - new GetMaskedContentFunctionImpl()); + sequenceHandlerRunner.registerJsFunction("getMaskedValue", + new GetMaskedValueFunctionImpl()); } - @Test(dataProvider = "maskableContentProvider") - public void testGetMaskedContent(boolean isLogMaskingEnabled, String username, String expectedMaskedContent) + @Test(dataProvider = "maskableValueProvider") + public void testGetMaskedValue(boolean isLogMaskingEnabled, String username, String expectedMaskedValue) throws JsTestException { LoggerUtils.isLogMaskingEnable = isLogMaskingEnabled; sequenceHandlerRunner.addSubjectAuthenticator("BasicMockAuthenticator", username, Collections.emptyMap()); - ServiceProvider sp = sequenceHandlerRunner.loadServiceProviderFromResource("get-masked-content-sp.xml", this); + ServiceProvider sp = sequenceHandlerRunner.loadServiceProviderFromResource("get-masked-value-sp.xml", this); AuthenticationContext context = sequenceHandlerRunner.createAuthenticationContext(sp); SequenceConfig sequenceConfig = sequenceHandlerRunner.getSequenceConfig(context, sp); context.setSequenceConfig(sequenceConfig); @@ -76,11 +76,11 @@ public void testGetMaskedContent(boolean isLogMaskingEnabled, String username, S sequenceHandlerRunner.handle(req, resp, context, "test_domain"); - Assert.assertEquals(context.getSelectedAcr(), expectedMaskedContent); + Assert.assertEquals(context.getSelectedAcr(), expectedMaskedValue); } - @DataProvider(name = "maskableContentProvider") - public Object[][] loginIdentifierProvider() { + @DataProvider(name = "maskableValueProvider") + public Object[][] maskableValueProvider() { return new Object[][]{ {true, "johndoe", "j*****e"}, diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/org/wso2/carbon/identity/conditional/auth/functions/utils/get-masked-content-sp.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/org/wso2/carbon/identity/conditional/auth/functions/utils/get-masked-value-sp.xml similarity index 97% rename from components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/org/wso2/carbon/identity/conditional/auth/functions/utils/get-masked-content-sp.xml rename to components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/org/wso2/carbon/identity/conditional/auth/functions/utils/get-masked-value-sp.xml index 447377fb..69ce4034 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/org/wso2/carbon/identity/conditional/auth/functions/utils/get-masked-content-sp.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/org/wso2/carbon/identity/conditional/auth/functions/utils/get-masked-value-sp.xml @@ -40,7 +40,7 @@ var onLoginRequest = function(context) { executeStep(1, { onSuccess: function(context) { var username = context.currentKnownSubject.username; - var maskedUsername = getMaskedContent(username); + var maskedUsername = getMaskedValue(username); Log.info("Masked username of the logged user: " + maskedUsername); context.selectedAcr = maskedUsername; }, diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/testng.xml index 136eaa55..3126ecf4 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/testng.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.utils/src/test/resources/testng.xml @@ -23,14 +23,14 @@ - + - +