Skip to content

Commit 009563c

Browse files
committed
1 parent 5e193b6 commit 009563c

41 files changed

Lines changed: 1542 additions & 371 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/AbstractBasicIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
import org.apache.ignite.internal.processors.query.calcite.schema.IgniteIndex;
4545
import org.apache.ignite.internal.processors.query.calcite.schema.IgniteTable;
4646
import org.apache.ignite.internal.processors.query.calcite.util.Commons;
47-
import org.apache.ignite.internal.processors.security.OperationSecurityContext;
4847
import org.apache.ignite.internal.processors.security.SecurityContext;
48+
import org.apache.ignite.internal.thread.context.Scope;
4949
import org.apache.ignite.internal.util.typedef.F;
5050
import org.apache.ignite.internal.util.typedef.G;
5151
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -245,7 +245,7 @@ protected List<List<?>> sql(String sql, Object... params) {
245245
protected List<List<?>> sqlAsRoot(IgniteEx ignite, String sql) throws Exception {
246246
SecurityContext secCtx = authenticate(grid(0), DFAULT_USER_NAME, "ignite");
247247

248-
try (OperationSecurityContext ignored = ignite.context().security().withContext(secCtx)) {
248+
try (Scope ignored = ignite.context().security().withContext(secCtx)) {
249249
return sql(ignite, sql);
250250
}
251251
}

modules/clients/src/test/java/org/apache/ignite/common/ComputeTaskPermissionsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
import org.apache.ignite.internal.management.cache.VerifyBackupPartitionsTask;
5555
import org.apache.ignite.internal.processors.security.AbstractSecurityTest;
5656
import org.apache.ignite.internal.processors.security.AbstractTestSecurityPluginProvider;
57-
import org.apache.ignite.internal.processors.security.OperationSecurityContext;
5857
import org.apache.ignite.internal.processors.security.PublicAccessJob;
5958
import org.apache.ignite.internal.processors.security.SecurityContext;
6059
import org.apache.ignite.internal.processors.security.compute.ComputePermissionCheckTest;
6160
import org.apache.ignite.internal.processors.security.impl.TestSecurityData;
6261
import org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider;
62+
import org.apache.ignite.internal.thread.context.Scope;
6363
import org.apache.ignite.internal.util.lang.ConsumerX;
6464
import org.apache.ignite.internal.util.lang.RunnableX;
6565
import org.apache.ignite.internal.util.lang.gridfunc.AtomicIntegerFactoryCallable;
@@ -476,7 +476,7 @@ public void testSystemTaskCancel() throws Exception {
476476
SecurityContext initiatorSecCtx = securityContext("no-permissions-login-0");
477477

478478
SupplierX<Future<?>> starter = () -> {
479-
try (OperationSecurityContext ignored1 = grid(0).context().security().withContext(initiatorSecCtx)) {
479+
try (Scope ignored1 = grid(0).context().security().withContext(initiatorSecCtx)) {
480480
return new TestFutureAdapter<>(
481481
grid(0).context().closure().runAsync(
482482
BROADCAST,
@@ -525,7 +525,7 @@ private void checkTaskCancel(
525525
assertTrue(taskStartedLatch.await(getTestTimeout(), MILLISECONDS));
526526

527527
try (
528-
OperationSecurityContext ignored = initiator == null
528+
Scope ignored = initiator == null
529529
? null
530530
: grid(0).context().security().withContext(initiator)
531531
) {

modules/core/src/main/java/org/apache/ignite/internal/processors/security/OperationSecurityContext.java renamed to modules/commons/src/main/java/org/apache/ignite/internal/thread/context/AttributeValueHolder.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,29 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.ignite.internal.processors.security;
18+
package org.apache.ignite.internal.thread.context;
1919

20-
/**
21-
*
22-
*/
23-
public class OperationSecurityContext implements AutoCloseable {
24-
/** Ignite Security. */
25-
private final IgniteSecurity proc;
20+
/** Immutable container that stores an attribute and its corresponding value. */
21+
class AttributeValueHolder<T> {
22+
/** */
23+
private final ContextAttribute<T> attr;
2624

27-
/** Security context. */
28-
private final SecurityContext secCtx;
25+
/** */
26+
private final T val;
27+
28+
/** */
29+
AttributeValueHolder(ContextAttribute<T> attr, T val) {
30+
this.attr = attr;
31+
this.val = val;
32+
}
2933

30-
/**
31-
* @param proc Ignite Security.
32-
* @param secCtx Security context.
33-
*/
34-
OperationSecurityContext(IgniteSecurity proc, SecurityContext secCtx) {
35-
this.proc = proc;
36-
this.secCtx = secCtx;
34+
/** */
35+
ContextAttribute<T> attribute() {
36+
return attr;
3737
}
3838

39-
/** {@inheritDoc} */
40-
@Override public void close() {
41-
if (secCtx == null)
42-
((IgniteSecurityProcessor)proc).restoreDefaultContext();
43-
else
44-
proc.withContext(secCtx);
39+
/** */
40+
T value() {
41+
return val;
4542
}
4643
}

0 commit comments

Comments
 (0)