com.almworks.jira.structure.api.auth.StructureAuth Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of structure-api Show documentation
Show all versions of structure-api Show documentation
Public API for the Structure Plugin for JIRA
package com.almworks.jira.structure.api.auth;
import com.almworks.jira.structure.api.structure.Structure;
import com.almworks.jira.structure.api.util.*;
import com.almworks.jira.structure.api.view.StructureView;
import com.atlassian.fugue.Option;
import com.atlassian.fugue.Pair;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.util.log.Log4jKit;
import org.apache.log4j.MDC;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.atlassian.fugue.Option.option;
import static com.atlassian.fugue.Pair.pair;
/**
*
* This class manages the current authentication context assumed when accessing, managing
* and updating Structure entities such as {@link Structure} or {@link StructureView}.
*
* The context is local to the current thread.
*
* By default, the context equals to {@link JiraAuthenticationContext JIRA's authentication context}.
* It is possible to specify another user or disable security checks; see {@link #sudo(ApplicationUser, boolean, CallableE)})
* and {@link #sudo(CallableE)}.
* */
public class StructureAuth {
private static final Logger log = LoggerFactory.getLogger(StructureAuth.class);
/**
* Not using custom class to avoid leaking our classes through ThreadLocal.
* Second component is "override security"
* */
private static final ThreadLocal, Boolean>> sudoContext = new ThreadLocal<>();
private static final AtomicBoolean reportedNoAuthContext = new AtomicBoolean();
/**
* Returns the current user. If the user is not authenticated, i.e. the context is anonymous,
* returns {@code null}. "Override security" setting does not influence this method.
*
* @return the current user
* */
@Nullable
public static ApplicationUser getUser() {
Pair
© 2015 - 2024 Weber Informatics LLC | Privacy Policy