All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.almworks.jira.structure.api.auth.AuthContext Maven / Gradle / Ivy

The newest version!
package com.almworks.jira.structure.api.auth;

import com.almworks.jira.structure.api.util.CallableE;
import com.atlassian.jira.user.ApplicationUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface AuthContext {
  AuthContext CURRENT = new AuthContext() {
    @Nullable
    @Override
    public ApplicationUser getUser() {
      return StructureAuth.getUser();
    }

    @Override
    public boolean isSecurityOverridden() {
      return StructureAuth.isSecurityOverridden();
    }

    @Override
    public  R sudo(@NotNull CallableE f) throws E {
      return f.call();
    }
  };

  @Nullable
  ApplicationUser getUser();

  boolean isSecurityOverridden();

   R sudo(@NotNull CallableE f) throws E;


  class Custom implements AuthContext {
    @Nullable
    private final ApplicationUser myUser;

    private final boolean mySecurityOverridden;

    public Custom(@Nullable ApplicationUser user, boolean securityOverridden) {
      myUser = user;
      mySecurityOverridden = securityOverridden;
    }

    @Nullable
    @Override
    public final ApplicationUser getUser() {
      return myUser;
    }

    @Override
    public final boolean isSecurityOverridden() {
      return mySecurityOverridden;
    }

    @Override
    public final  R sudo(@NotNull CallableE f) throws E {
      return StructureAuth.sudo(myUser, mySecurityOverridden, f);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy