Search in sources :

Example 16 with KsqlSecurityContext

use of io.confluent.ksql.security.KsqlSecurityContext in project ksql by confluentinc.

the class RequestHandler method executeStatement.

@SuppressWarnings("unchecked")
private <T extends Statement> Optional<KsqlEntity> executeStatement(final KsqlSecurityContext securityContext, final PreparedStatement<T> prepared, final SessionProperties sessionProperties, final KsqlEntityList entities) {
    final Class<? extends Statement> statementClass = prepared.getStatement().getClass();
    commandQueueSync.waitFor(new KsqlEntityList(entities), statementClass);
    final ConfiguredStatement<T> configured = ConfiguredStatement.of(prepared, SessionConfig.of(this.ksqlEngine.getKsqlConfig(), sessionProperties.getMutableScopedProperties()));
    FeatureFlagChecker.throwOnDisabledFeatures(configured);
    final StatementExecutor<T> executor = (StatementExecutor<T>) customExecutors.getOrDefault(statementClass, (stmt, props, ctx, svcCtx) -> distributor.execute(stmt, ctx, securityContext));
    final StatementExecutorResponse response = executor.execute(configured, sessionProperties, ksqlEngine, securityContext.getServiceContext());
    if (response.isHandled()) {
        return response.getEntity();
    } else {
        return distributor.execute(configured, ksqlEngine, securityContext).getEntity();
    }
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) SessionProperties(io.confluent.ksql.rest.SessionProperties) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KsqlConfig(io.confluent.ksql.util.KsqlConfig) FeatureFlagChecker(io.confluent.ksql.rest.util.FeatureFlagChecker) KsqlSecurityContext(io.confluent.ksql.security.KsqlSecurityContext) DistributingExecutor(io.confluent.ksql.rest.server.computation.DistributingExecutor) SessionConfig(io.confluent.ksql.config.SessionConfig) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) Objects(java.util.Objects) List(java.util.List) Map(java.util.Map) ParsedStatement(io.confluent.ksql.parser.KsqlParser.ParsedStatement) Optional(java.util.Optional) Statement(io.confluent.ksql.parser.tree.Statement) Collections(java.util.Collections) PreparedStatement(io.confluent.ksql.parser.KsqlParser.PreparedStatement)

Aggregations

KsqlSecurityContext (io.confluent.ksql.security.KsqlSecurityContext)16 Statement (io.confluent.ksql.parser.tree.Statement)7 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)7 KsqlException (io.confluent.ksql.util.KsqlException)7 Test (org.junit.Test)7 PreparedStatement (io.confluent.ksql.parser.KsqlParser.PreparedStatement)6 Before (org.junit.Before)6 SessionConfig (io.confluent.ksql.config.SessionConfig)4 KsqlTopicAuthorizationException (io.confluent.ksql.exception.KsqlTopicAuthorizationException)4 KsqlRestException (io.confluent.ksql.rest.server.resources.KsqlRestException)4 SandboxedServiceContext (io.confluent.ksql.services.SandboxedServiceContext)4 ServiceContext (io.confluent.ksql.services.ServiceContext)4 TestServiceContext (io.confluent.ksql.services.TestServiceContext)4 KsqlConfig (io.confluent.ksql.util.KsqlConfig)4 Optional (java.util.Optional)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 KsqlExecutionContext (io.confluent.ksql.KsqlExecutionContext)3 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)3 DataSource (io.confluent.ksql.metastore.model.DataSource)3