Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
import org.apache.ignite.internal.management.cache.VerifyBackupPartitionsTask;
import org.apache.ignite.internal.processors.security.AbstractSecurityTest;
import org.apache.ignite.internal.processors.security.AbstractTestSecurityPluginProvider;
import org.apache.ignite.internal.processors.security.OperationSecurityContext;
import org.apache.ignite.internal.processors.security.PublicAccessJob;
import org.apache.ignite.internal.processors.security.SecurityContext;
import org.apache.ignite.internal.processors.security.compute.ComputePermissionCheckTest;
import org.apache.ignite.internal.processors.security.impl.TestSecurityData;
import org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider;
import org.apache.ignite.internal.thread.context.Scope;
import org.apache.ignite.internal.util.lang.ConsumerX;
import org.apache.ignite.internal.util.lang.RunnableX;
import org.apache.ignite.internal.util.lang.gridfunc.AtomicIntegerFactoryCallable;
Expand Down Expand Up @@ -476,7 +476,7 @@ public void testSystemTaskCancel() throws Exception {
SecurityContext initiatorSecCtx = securityContext("no-permissions-login-0");

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

try (
OperationSecurityContext ignored = initiator == null
Scope ignored = initiator == null
? null
: grid(0).context().security().withContext(initiator)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,29 @@
* limitations under the License.
*/

package org.apache.ignite.internal.processors.security;
package org.apache.ignite.internal.thread.context;

/**
*
*/
public class OperationSecurityContext implements AutoCloseable {
/** Ignite Security. */
private final IgniteSecurity proc;
/** Immutable container that stores an attribute and its corresponding value. */
class AttributeValueHolder<T> {
/** */
private final ContextAttribute<T> attr;

/** Security context. */
private final SecurityContext secCtx;
/** */
private final T val;

/** */
AttributeValueHolder(ContextAttribute<T> attr, T val) {
this.attr = attr;
this.val = val;
}

/**
* @param proc Ignite Security.
* @param secCtx Security context.
*/
OperationSecurityContext(IgniteSecurity proc, SecurityContext secCtx) {
this.proc = proc;
this.secCtx = secCtx;
/** */
ContextAttribute<T> attribute() {
return attr;
}

/** {@inheritDoc} */
@Override public void close() {
if (secCtx == null)
((IgniteSecurityProcessor)proc).restoreDefaultContext();
else
proc.withContext(secCtx);
/** */
T value() {
return val;
}
}
Loading
Loading