diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml index 0d6e7e7d..c84ccd37 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.analytics/pom.xml @@ -165,8 +165,6 @@ version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.base; - version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.common.model; version="${carbon.identity.package.import.version.range}", diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml index c9d12f25..c172dff0 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.http/pom.xml @@ -173,8 +173,6 @@ version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.base; - version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.core.util; version="${carbon.identity.package.import.version.range}", diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/http/GetCookieFunction.java b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/http/GetCookieFunction.java index 7b615168..1f1a5d6e 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/http/GetCookieFunction.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.http/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/http/GetCookieFunction.java @@ -19,7 +19,6 @@ package org.wso2.carbon.identity.conditional.auth.functions.http; -import org.graalvm.polyglot.HostAccess; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsServletRequest; import java.util.Map; @@ -37,7 +36,6 @@ public interface GetCookieFunction { * @param params value mandatory and properties optional * @return cookieValue */ - @HostAccess.Export String getCookieValue(JsServletRequest request, Object... params); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml index c7ece95e..558812bc 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.notification/pom.xml @@ -128,8 +128,6 @@ version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.base; - version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.event; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.event.event; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.event.services; version="${carbon.identity.package.import.version.range}", diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.session/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.session/pom.xml index 717445b4..bfd6d416 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.session/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.session/pom.xml @@ -106,7 +106,6 @@ org.osgi.service.component, org.wso2.carbon.identity.application.authentication.framework, org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js, - org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.base; org.wso2.carbon.identity.application.authentication.framework.context, org.wso2.carbon.identity.application.authentication.framework.exception, org.wso2.carbon.identity.application.authentication.framework.model, diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/pom.xml index 747d9f58..e0cf45e3 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/pom.xml @@ -114,7 +114,6 @@ org.wso2.carbon.identity.application.authentication.framework.exception; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.model; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.base; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.context; version="${carbon.identity.package.import.version.range}", diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/GetUserWithClaimValuesV2Function.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/GetUserWithClaimValuesV2Function.java new file mode 100644 index 00000000..de7e5099 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/GetUserWithClaimValuesV2Function.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.conditional.auth.functions.user.store; + +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticatedUser; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext; +import org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException; + +import java.util.Map; + +@FunctionalInterface +public interface GetUserWithClaimValuesV2Function { + + JsAuthenticatedUser getUniqueUserWithClaimValues(Map claimMap, + JsAuthenticationContext authenticationContext, + String... parameters) throws FrameworkException; +} diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/GetUserWithClaimValuesV2FunctionImpl.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/GetUserWithClaimValuesV2FunctionImpl.java new file mode 100644 index 00000000..23a126e3 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/GetUserWithClaimValuesV2FunctionImpl.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.conditional.auth.functions.user.store; + +import org.graalvm.polyglot.HostAccess; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticatedUser; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext; +import org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException; + +import java.util.Map; + +/** + * Implementation of GetUserWithClaimValuesV2Function. This will return a user given a set of claim values. + */ +public class GetUserWithClaimValuesV2FunctionImpl implements GetUserWithClaimValuesV2Function { + + @Override + @HostAccess.Export + public JsAuthenticatedUser getUniqueUserWithClaimValues(Map claimMap, + JsAuthenticationContext authenticationContext, + String... parameters) throws FrameworkException { + + return new UserStoreFunctions().getUniqueUserWithClaimValues(claimMap, authenticationContext, parameters); + } +} diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/UserStoreFunctions.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/UserStoreFunctions.java index 70b8ffae..307415ca 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/UserStoreFunctions.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/UserStoreFunctions.java @@ -20,7 +20,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.graalvm.polyglot.HostAccess; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsWrapperFactoryProvider; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticatedUser; @@ -46,11 +45,15 @@ public class UserStoreFunctions implements GetUserWithClaimValues { private static final Log LOG = LogFactory.getLog(UserStoreFunctions.class); - @HostAccess.Export public JsAuthenticatedUser getUniqueUserWithClaimValues(Map claimMap, Object... parameters) throws FrameworkException { + return getUniqueUserWithClaimValuesInternal(claimMap, parameters); + } + + private JsAuthenticatedUser getUniqueUserWithClaimValuesInternal(Map claimMap, Object... parameters) + throws FrameworkException { - JsAuthenticationContext authenticationContext = null; + JsAuthenticationContext authenticationContext = null; String tenantDomain = null; String profile = "default"; if (claimMap == null || parameters == null) { @@ -63,7 +66,7 @@ public JsAuthenticatedUser getUniqueUserWithClaimValues(Map clai if (parameters.length == 2) { if ( parameters[0] instanceof JsAuthenticationContext) { authenticationContext = (JsAuthenticationContext) parameters[0]; - tenantDomain = authenticationContext.getWrapped().getTenantDomain(); + tenantDomain = authenticationContext.getContext().getTenantDomain(); } if ( parameters[1] instanceof String) { profile = (String) parameters[1]; @@ -71,7 +74,7 @@ public JsAuthenticatedUser getUniqueUserWithClaimValues(Map clai } if (parameters.length == 1 && parameters[0] instanceof JsAuthenticationContext) { authenticationContext = (JsAuthenticationContext) parameters[0]; - tenantDomain = authenticationContext.getWrapped().getTenantDomain(); + tenantDomain = authenticationContext.getContext().getTenantDomain(); } if (tenantDomain != null) { int tenantId = IdentityTenantUtil.getTenantId(tenantDomain); @@ -121,6 +124,10 @@ public JsAuthenticatedUser getUniqueUserWithClaimValues(Map clai } authenticatedUser.setUserName(username); authenticatedUser.setTenantDomain(tenantDomain); + if (authenticationContext != null) { + return (JsAuthenticatedUser) JsWrapperFactoryProvider.getInstance().getWrapperFactory(). + createJsAuthenticatedUser(authenticatedUser); + } return (JsAuthenticatedUser) JsWrapperFactoryProvider.getInstance().getWrapperFactory(). createJsAuthenticatedUser(authenticationContext.getWrapped(), authenticatedUser); } else { @@ -136,4 +143,5 @@ public JsAuthenticatedUser getUniqueUserWithClaimValues(Map clai } return null; } + } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/internal/UserStoreFunctionsServiceComponent.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/internal/UserStoreFunctionsServiceComponent.java index 87e269ca..3b149918 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/internal/UserStoreFunctionsServiceComponent.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user.store/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/store/internal/UserStoreFunctionsServiceComponent.java @@ -28,8 +28,7 @@ import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; import org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry; -import org.wso2.carbon.identity.conditional.auth.functions.user.store.GetUserWithClaimValues; -import org.wso2.carbon.identity.conditional.auth.functions.user.store.UserStoreFunctions; +import org.wso2.carbon.identity.conditional.auth.functions.user.store.GetUserWithClaimValuesV2FunctionImpl; import org.wso2.carbon.user.core.service.RealmService; /** @@ -48,12 +47,12 @@ public class UserStoreFunctionsServiceComponent { protected void activate(ComponentContext ctxt) { try { - UserStoreFunctions storeFunctions = new UserStoreFunctions(); + GetUserWithClaimValuesV2FunctionImpl storeFunctions = new GetUserWithClaimValuesV2FunctionImpl(); JsFunctionRegistry jsFunctionRegistry = UserStoreFunctionsServiceHolder.getInstance() .getJsFunctionRegistry(); jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getUniqueUserWithClaimValues", - (GetUserWithClaimValues) storeFunctions::getUniqueUserWithClaimValues); + new GetUserWithClaimValuesV2FunctionImpl()); } catch (Throwable e) { LOG.error("Error occurred during conditional authentication user functions bundle activation. ", e); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml b/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml index cfa10b51..af36640b 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/pom.xml @@ -165,8 +165,6 @@ version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js; version="${carbon.identity.package.import.version.range}", - org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.base; - version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.nashorn; version="${carbon.identity.package.import.version.range}", org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.openjdk.*; diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsFunction.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsFunction.java index fdfb39ce..1758468f 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsFunction.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsFunction.java @@ -19,7 +19,7 @@ package org.wso2.carbon.identity.conditional.auth.functions.user; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext; -import org.wso2.carbon.identity.conditional.auth.functions.user.model.JsApplication; +import org.wso2.carbon.identity.application.authentication.framework.model.Application; import java.util.List; @@ -35,5 +35,5 @@ public interface GetAuthenticatedApplicationsFunction { * @param context context object. * @return List of already authenticated applications of the given session. */ - List getAuthenticatedApplications(JsAuthenticationContext context); + List getAuthenticatedApplications(JsAuthenticationContext context); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsV2Function.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsV2Function.java new file mode 100644 index 00000000..2490b9d2 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsV2Function.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.conditional.auth.functions.user; + +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext; +import org.wso2.carbon.identity.conditional.auth.functions.user.model.JsApplication; + +import java.util.List; + +/** + * Function definition for retrieving authenticated applications. + */ +@FunctionalInterface +public interface GetAuthenticatedApplicationsV2Function { + + /** + * Retrieve the already authenticated applications for a given session. + * + * @param context context object. + * @return List of already authenticated applications of the given session. + */ + List getAuthenticatedApplications(JsAuthenticationContext context); +} diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsV2FunctionImpl.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsV2FunctionImpl.java new file mode 100644 index 00000000..b6a04154 --- /dev/null +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedApplicationsV2FunctionImpl.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.conditional.auth.functions.user; + +import org.graalvm.polyglot.HostAccess; +import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext; +import org.wso2.carbon.identity.conditional.auth.functions.user.model.JsApplication; +import org.wso2.carbon.identity.conditional.auth.functions.user.model.JsWrapperFactoryProvider; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Function for retrieving javascript authenticated applications for a given session. + */ +public class GetAuthenticatedApplicationsV2FunctionImpl implements GetAuthenticatedApplicationsV2Function { + + @Override + @HostAccess.Export + public List getAuthenticatedApplications(JsAuthenticationContext context) { + + return new GetAuthenticatedAppsFuncImp().getAuthenticatedApplications(context) + .stream() + .map(app -> JsWrapperFactoryProvider.getInstance().getWrapperFactory().createJsApplication(app)) + .collect(Collectors.toList()); + } +} diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedAppsFuncImp.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedAppsFuncImp.java index 1373776b..ca278312 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedAppsFuncImp.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/GetAuthenticatedAppsFuncImp.java @@ -24,6 +24,7 @@ import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext; import org.wso2.carbon.identity.application.authentication.framework.exception.session.mgt.SessionManagementException; import org.wso2.carbon.identity.application.authentication.framework.model.UserSession; +import org.wso2.carbon.identity.application.authentication.framework.model.Application; import org.wso2.carbon.identity.conditional.auth.functions.user.internal.UserFunctionsServiceHolder; import org.wso2.carbon.identity.conditional.auth.functions.user.model.JsApplication; import org.wso2.carbon.identity.conditional.auth.functions.user.model.JsWrapperFactoryProvider; @@ -47,7 +48,7 @@ public class GetAuthenticatedAppsFuncImp implements GetAuthenticatedApplications */ @Override @HostAccess.Export - public List getAuthenticatedApplications(JsAuthenticationContext context) { + public List getAuthenticatedApplications(JsAuthenticationContext context) { String sessionContextKey = context.getWrapped().getSessionIdentifier(); try { @@ -55,9 +56,7 @@ public List getAuthenticatedApplications(JsAuthenticationContext UserSession userSession = UserFunctionsServiceHolder.getInstance().getUserSessionManagementService() .getUserSessionBySessionId(sessionContextKey).get(); - return userSession.getApplications().stream() - .map(app -> JsWrapperFactoryProvider.getInstance().getWrapperFactory().createJsApplication(app)) - .collect(Collectors.toList()); + return userSession.getApplications(); } } catch (SessionManagementException e) { log.debug("Error occurred while retrieving the user session."); diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunction.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunction.java index faeb6b0d..fa81be7e 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunction.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/HasRoleFunction.java @@ -18,7 +18,6 @@ package org.wso2.carbon.identity.conditional.auth.functions.user; -import org.graalvm.polyglot.HostAccess; import org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticatedUser; /** @@ -38,6 +37,5 @@ public interface HasRoleFunction { * @param roleName Role to be checked * @return true if the user has the given role. false for any other case. */ - @HostAccess.Export boolean hasRole(JsAuthenticatedUser user, String roleName); } diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/internal/UserFunctionsServiceComponent.java b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/internal/UserFunctionsServiceComponent.java index 7ad30c96..2f0896d8 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/internal/UserFunctionsServiceComponent.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.user/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/user/internal/UserFunctionsServiceComponent.java @@ -35,14 +35,13 @@ import org.wso2.carbon.identity.conditional.auth.functions.user.AssignUserRolesV2Function; import org.wso2.carbon.identity.conditional.auth.functions.user.AssignUserRolesV2FunctionImpl; import org.wso2.carbon.identity.conditional.auth.functions.user.CheckSessionExistenceFunctionImpl; +import org.wso2.carbon.identity.conditional.auth.functions.user.GetAuthenticatedApplicationsV2FunctionImpl; import org.wso2.carbon.identity.conditional.auth.functions.user.HasAnyOfTheRolesV2Function; import org.wso2.carbon.identity.conditional.auth.functions.user.HasAnyOfTheRolesV2FunctionImpl; import org.wso2.carbon.identity.conditional.auth.functions.user.MicrosoftEmailVerificationFunction; import org.wso2.carbon.identity.conditional.auth.functions.user.MicrosoftEmailVerificationFunctionImpl; import org.wso2.carbon.identity.conditional.auth.functions.user.GetAssociatedLocalUserFunction; import org.wso2.carbon.identity.conditional.auth.functions.user.GetAssociatedLocalUserFunctionImpl; -import org.wso2.carbon.identity.conditional.auth.functions.user.GetAuthenticatedApplicationsFunction; -import org.wso2.carbon.identity.conditional.auth.functions.user.GetAuthenticatedAppsFuncImp; import org.wso2.carbon.identity.conditional.auth.functions.user.GetUserSessionsFunctionImpl; import org.wso2.carbon.identity.conditional.auth.functions.user.IsMemberOfAnyOfGroupsFunction; import org.wso2.carbon.identity.conditional.auth.functions.user.IsMemberOfAnyOfGroupsFunctionImpl; @@ -89,7 +88,6 @@ protected void activate(ComponentContext ctxt) { RemoveUserRolesFunction removeUserRolesFunctionImpl = new RemoveUserRolesFunctionImpl(); GetAssociatedLocalUserFunction getAssociatedLocalUserFunctionImpl = new GetAssociatedLocalUserFunctionImpl(); SetAccountAssociationToLocalUser setAccountAssociationToLocalUserImpl = new SetAccountAssociationToLocalUserImpl(); - GetAuthenticatedApplicationsFunction getAuthenticatedApplicationsFunctionImp = new GetAuthenticatedAppsFuncImp(); MicrosoftEmailVerificationFunction microsoftEmailVerificationFunction = new MicrosoftEmailVerificationFunctionImpl(); JsFunctionRegistry jsFunctionRegistry = UserFunctionsServiceHolder.getInstance().getJsFunctionRegistry(); jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "hasRole", hasRoleFunctionImpl); @@ -122,7 +120,7 @@ protected void activate(ComponentContext ctxt) { jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "isAnyOfTheRolesAssignedToUser", new IsAnyOfTheRolesAssignedToUserFunctionImpl()); jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getAuthenticatedApplications", - getAuthenticatedApplicationsFunctionImp); + new GetAuthenticatedApplicationsV2FunctionImpl()); jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "checkMicrosoftEmailVerification", microsoftEmailVerificationFunction); } catch (Throwable e) {