Skip to content

Commit

Permalink
remove identityFactoryProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Akash Singh committed May 29, 2024
1 parent 8c0a5b6 commit a398b38
Show file tree
Hide file tree
Showing 80 changed files with 329 additions and 446 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.finos.legend.engine.application.query.model.QueryEvent;
import org.finos.legend.engine.application.query.model.QuerySearchSpecification;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider;
import org.finos.legend.engine.shared.core.kerberos.ProfileManagerHelper;
import org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionTool;
import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType;
Expand Down Expand Up @@ -150,7 +149,7 @@ public Response getQueryCount()
public Response createQuery(Query query, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> profileManager)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(profileManager);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
try (Scope scope = GlobalTracer.get().buildSpan("Query: Create Query").startActive(true))
{
return Response.ok().entity(this.queryStoreManager.createQuery(query, getCurrentUser(profileManager))).build();
Expand All @@ -172,7 +171,7 @@ public Response createQuery(Query query, @ApiParam(hidden = true) @Pac4JProfileM
public Response updateQuery(@PathParam("queryId") String queryId, Query query, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> profileManager)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(profileManager);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
try (Scope scope = GlobalTracer.get().buildSpan("Query: Update Query").startActive(true))
{
return Response.ok().entity(this.queryStoreManager.updateQuery(queryId, query, getCurrentUser(profileManager))).build();
Expand All @@ -194,7 +193,7 @@ public Response updateQuery(@PathParam("queryId") String queryId, Query query, @
public Response patchQuery(@PathParam("queryId") String queryId, Query query, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> profileManager)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(profileManager);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
try (Scope scope = GlobalTracer.get().buildSpan("Patch Query - update selected query fields").startActive(true))
{
return Response.ok().entity(this.queryStoreManager.patchQuery(queryId, query, getCurrentUser(profileManager))).build();
Expand All @@ -216,7 +215,7 @@ public Response patchQuery(@PathParam("queryId") String queryId, Query query, @A
public Response deleteQuery(@PathParam("queryId") String queryId, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> profileManager)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(profileManager);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
try (Scope scope = GlobalTracer.get().buildSpan("Query: Delete Query").startActive(true))
{
this.queryStoreManager.deleteQuery(queryId, getCurrentUser(profileManager));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import org.finos.legend.engine.repl.client.Client;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider;
import org.finos.legend.engine.shared.core.kerberos.SubjectTools;

public class Helpers
Expand All @@ -25,7 +24,7 @@ public static Identity resolveIdentityFromLocalSubject(Client client)
{
try
{
return IdentityFactoryProvider.getInstance().makeIdentity(SubjectTools.getLocalSubject());
return Identity.makeIdentity(SubjectTools.getLocalSubject());
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,17 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-identity-pac4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-identity-kerberos</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Authentication -->

<!-- In order to access Version for Pure platform -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.finos.legend.engine.plan.execution.stores.relational.plugin.Relational;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.credential.middletier.MiddleTierUserPasswordCredential;
import org.finos.legend.engine.shared.core.identity.factory.DefaultIdentityFactory;
import org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionError;
import org.finos.legend.engine.shared.core.vault.TestVaultImplementation;
import org.finos.legend.engine.shared.core.vault.Vault;
Expand Down Expand Up @@ -106,8 +105,7 @@ public static void shutdownClass()
@Before
public void setup() throws Exception
{
DefaultIdentityFactory defaultIdentityFactory = new DefaultIdentityFactory();
this.identity = defaultIdentityFactory.makeUnknownIdentity();
this.identity = Identity.makeUnknownIdentity();

this.testVaultImplementation = new TestVaultImplementation();
MiddleTierUserPasswordCredential middleTierUserPasswordCredential = new MiddleTierUserPasswordCredential(postgresTestContainerWrapper.getUser(), postgresTestContainerWrapper.getPassword(), "unused");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.finos.legend.engine.plan.execution.result.serialization.SerializationFormat;
import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan;
import org.finos.legend.engine.shared.core.ObjectMapperFactory;
import org.finos.legend.engine.shared.core.identity.factory.DefaultIdentityFactory;
import org.junit.Test;

import javax.ws.rs.core.Response;
Expand All @@ -47,7 +46,7 @@ public void testWithExecutePlan_ExecutionAuthorized() throws Exception
RootMiddleTierPlanExecutionAuthorizer planExecutionAuthorizer = new RootMiddleTierPlanExecutionAuthorizer(Lists.immutable.of(relationalMiddleTierPlanExecutionAuthorizer));

SingleExecutionPlan executionPlan = this.loadPlanFromFile("/plans/planWithSingleMiddleTierConnection.json", postgresTestContainerWrapper.getPort());
Response response = new ExecutePlan(buildPlanExecutor(), planExecutionAuthorizer, new DefaultIdentityFactory()).doExecutePlanImpl(new ExecutionRequest(executionPlan), SerializationFormat.defaultFormat, identity);
Response response = new ExecutePlan(buildPlanExecutor(), planExecutionAuthorizer).doExecutePlanImpl(new ExecutionRequest(executionPlan), SerializationFormat.defaultFormat, identity);

assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());

Expand All @@ -64,7 +63,7 @@ public void testWithExecutePlan_ExecutionNotAuthorized() throws Exception
RootMiddleTierPlanExecutionAuthorizer planExecutionAuthorizer = new RootMiddleTierPlanExecutionAuthorizer(Lists.immutable.of(relationalMiddleTierPlanExecutionAuthorizer));

SingleExecutionPlan executionPlan = this.loadPlanFromFile("/plans/planWithSingleMiddleTierConnection.json", postgresTestContainerWrapper.getPort());
Response response = new ExecutePlan(buildPlanExecutor(), planExecutionAuthorizer, new DefaultIdentityFactory()).doExecutePlanImpl(new ExecutionRequest(executionPlan), SerializationFormat.defaultFormat, identity);
Response response = new ExecutePlan(buildPlanExecutor(), planExecutionAuthorizer).doExecutePlanImpl(new ExecutionRequest(executionPlan), SerializationFormat.defaultFormat, identity);

assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan;
import org.finos.legend.engine.shared.core.ObjectMapperFactory;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.DefaultIdentityFactory;
import org.finos.legend.engine.shared.core.vault.TestVaultImplementation;
import org.finos.legend.engine.shared.core.vault.Vault;
import org.junit.After;
Expand Down Expand Up @@ -88,8 +87,7 @@ public String getRemoteUser()
@Before
public void setup() throws Exception
{
DefaultIdentityFactory defaultIdentityFactory = new DefaultIdentityFactory();
this.identity = defaultIdentityFactory.makeUnknownIdentity();
this.identity = Identity.makeUnknownIdentity();

this.testVaultImplementation = new TestVaultImplementation();
Vault.INSTANCE.registerImplementation(testVaultImplementation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
import org.finos.legend.engine.plan.execution.stores.StoreType;
import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.DefaultIdentityFactory;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactory;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider;
import org.finos.legend.engine.shared.core.kerberos.ProfileManagerHelper;
import org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionTool;
import org.finos.legend.engine.shared.core.operational.logs.LogInfo;
Expand All @@ -57,18 +55,16 @@ public class ExecutePlan
{
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(ExecutePlan.class);
private final PlanExecutor planExecutor;
private IdentityFactory identityFactory;
private final PlanExecutionAuthorizer planExecutionAuthorizer;

public ExecutePlan(PlanExecutor planExecutor)
{
this(planExecutor, null, new DefaultIdentityFactory());
this(planExecutor, null);
}

public ExecutePlan(PlanExecutor planExecutor, PlanExecutionAuthorizer planExecutionAuthorizer, IdentityFactory identityFactory)
public ExecutePlan(PlanExecutor planExecutor, PlanExecutionAuthorizer planExecutionAuthorizer)
{
this.planExecutor = planExecutor;
this.identityFactory = identityFactory;
this.planExecutionAuthorizer = planExecutionAuthorizer;
}

Expand All @@ -81,7 +77,7 @@ public Response doExecutePlan(@Context HttpServletRequest request, ExecutionRequ
*/

MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(pm);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
if (this.planExecutionAuthorizer == null)
{
return this.doExecutePlanLegacy(request, executionRequest, format, identity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.finos.legend.engine.plan.execution.authorization.PlanExecutionAuthorizer;
import org.finos.legend.engine.plan.execution.result.serialization.SerializationFormat;
import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.ExecutionPlan;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactory;
import org.pac4j.core.profile.CommonProfile;
import org.pac4j.core.profile.ProfileManager;
import org.pac4j.jax.rs.annotations.Pac4JProfileManager;
Expand All @@ -48,9 +47,9 @@ public ExecutePlanStrategic(PlanExecutor planExecutor)
super(planExecutor);
}

public ExecutePlanStrategic(PlanExecutor planExecutor, PlanExecutionAuthorizer planExecutionAuthorizer, IdentityFactory identityFactory)
public ExecutePlanStrategic(PlanExecutor planExecutor, PlanExecutionAuthorizer planExecutionAuthorizer)
{
super(planExecutor, planExecutionAuthorizer, identityFactory);
super(planExecutor, planExecutionAuthorizer);
}

@POST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-identity-kerberos</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-identity-pac4j</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-protocol</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.collections.impl.factory.Maps;
import org.eclipse.collections.impl.factory.Sets;
import org.eclipse.collections.impl.utility.ListIterate;
import org.finos.legend.engine.identity.extensions.pac4j.Pac4jUtils;
import org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;
import org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked;
import org.finos.legend.engine.plan.dependencies.domain.graphFetch.IGraphInstance;
Expand Down Expand Up @@ -86,7 +87,6 @@
import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.SerializationConfig;
import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.graph.PropertyGraphFetchTree;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider;
import org.pac4j.core.profile.ProfileManager;

import java.util.Arrays;
Expand Down Expand Up @@ -368,7 +368,7 @@ public Result visit(GraphFetchExecutionNode graphFetchExecutionNode)
String executionClassName = JavaHelper.getExecutionClassFullName(javaPlatformImpl);
String executionMethodName = JavaHelper.getExecutionMethodName(javaPlatformImpl);

Stream<?> transformedResult = ExecutionNodeJavaPlatformHelper.executeStaticJavaMethod(graphFetchExecutionNode, executionClassName, executionMethodName, Arrays.asList(StreamingObjectResult.class, ExecutionNode.class, ExecutionState.class, ProfileManager.class), Arrays.asList(objectResult, graphFetchExecutionNode, this.executionState, Lists.mutable.withAll(IdentityFactoryProvider.getInstance().adapt(identity))), this.executionState, this.identity);
Stream<?> transformedResult = ExecutionNodeJavaPlatformHelper.executeStaticJavaMethod(graphFetchExecutionNode, executionClassName, executionMethodName, Arrays.asList(StreamingObjectResult.class, ExecutionNode.class, ExecutionState.class, ProfileManager.class), Arrays.asList(objectResult, graphFetchExecutionNode, this.executionState, Pac4jUtils.getProfilesFromIdentity(identity)), this.executionState, this.identity);
return new StreamingObjectResult<>(transformedResult, objectResult.getResultBuilder(), objectResult);
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextPointer;
import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider;
import org.finos.legend.engine.shared.core.kerberos.ProfileManagerHelper;
import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException;
import org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionTool;
Expand Down Expand Up @@ -74,7 +73,7 @@ public Compile(ModelManager modelManager)
public Response compile(PureModelContext model, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> pm, @Context UriInfo uriInfo)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(pm);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
long start = System.currentTimeMillis();
try (Scope scope = GlobalTracer.get().buildSpan("Service: compile").startActive(true))
{
Expand Down Expand Up @@ -102,7 +101,7 @@ public Response compile(PureModelContext model, @ApiParam(hidden = true) @Pac4JP
public Response lambdaReturnType(LambdaReturnTypeInput lambdaReturnTypeInput, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> pm, @Context UriInfo uriInfo)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(pm);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
long start = System.currentTimeMillis();
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.finos.legend.engine.shared.core.api.grammar.ParserError;
import org.finos.legend.engine.shared.core.api.result.ManageConstantResult;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider;
import org.finos.legend.engine.shared.core.kerberos.ProfileManagerHelper;
import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException;
import org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionTool;
Expand Down Expand Up @@ -69,7 +68,7 @@ public class TransformGrammarToJson
public Response transformGrammarToJson(GrammarToJsonInput grammarInput, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> pm, @DefaultValue("true") @QueryParam("returnSourceInfo") boolean returnSourceInfo)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(pm);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
try (Scope scope = GlobalTracer.get().buildSpan("Service: transformJsonToGrammar").startActive(true))
{
PureGrammarParserExtensions.logExtensionList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtensionLoader;
import org.finos.legend.engine.shared.core.api.result.ManageConstantResult;
import org.finos.legend.engine.shared.core.identity.Identity;
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider;
import org.finos.legend.engine.shared.core.kerberos.ProfileManagerHelper;
import org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionTool;
import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType;
Expand Down Expand Up @@ -64,7 +63,7 @@ public class TransformJsonToGrammar
public Response transformJsonToGrammar(JsonToGrammarInput jsonInput, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> pm)
{
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(pm);
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles);
Identity identity = Identity.makeIdentity(profiles);
try (Scope scope = GlobalTracer.get().buildSpan("Service: transformJsonToGrammar").startActive(true))
{
PureGrammarComposerExtensionLoader.logExtensionList();
Expand Down
Loading

0 comments on commit a398b38

Please sign in to comment.