Interface AccessManager

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AccessManager
A manager that provides access validators for different execution contexts.

The most basic manager creates validators that simply check if the user belongs to the given group; however, manager implementations are free to customize access control by checking additional context information, external state, or even dynamically applying different validation rules depending on the context.

Since:
1.0
Version:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a manager for which all validators always allow access.
    Creates a manager for which all validators always deny access.
    Creates a manager that issues validators that perform simple group memebership checks (that is, a user has equivalent access to a group if and only if they belong to that group).
    doValidate(AccessContext context, Group group, Supplier<Mono<Boolean>> membershipCheck)
    Validates that an access is legal.
    overridable(GuildGroup overrideGroup)
    Creates a manager that issues validators that generally perform group membership checks, but also allows a given group to override any permission in the system (that is, users that are members of the given group have equivalent permissions to any other group).
    Creates an access validator under the given context.
    Creates an access validator under the given context.
  • Method Details

    • doValidate

      Mono<Boolean> doValidate(AccessContext context, Group group, Supplier<Mono<Boolean>> membershipCheck)
      Validates that an access is legal.
      Parameters:
      context - The access context.
      group - The required group.
      membershipCheck - A function that applies Group.belongs(ChannelAccessContext) or GuildGroup.belongs(AccessContext) (as appropriate).
      Returns:
      Whether the access is allowed.
    • validator

      default ChannelAccessValidator validator(ChannelAccessContext context)
      Creates an access validator under the given context.
      Parameters:
      context - The access context for the current execution.
      Returns:
      The appropriate access validator.
    • validator

      default AccessValidator validator(AccessContext context)
      Creates an access validator under the given context.
      Parameters:
      context - The access context for the current execution.
      Returns:
      The appropriate access validator.
    • alwaysAllow

      @SideEffectFree static AccessManager alwaysAllow()
      Creates a manager for which all validators always allow access. That is, a manager that allows access for any user to any group (effectively disabling group checking).
      Returns:
      The manager.
    • alwaysDeny

      @SideEffectFree static AccessManager alwaysDeny()
      Creates a manager for which all validators always deny access. That is, a manager that denies access for any user to any group (effectively disabling any functionality that requires group membership).
      Returns:
      The manager.
    • basic

      Creates a manager that issues validators that perform simple group memebership checks (that is, a user has equivalent access to a group if and only if they belong to that group).
      Returns:
      The manager.
    • overridable

      @SideEffectFree static AccessManager overridable(GuildGroup overrideGroup)
      Creates a manager that issues validators that generally perform group membership checks, but also allows a given group to override any permission in the system (that is, users that are members of the given group have equivalent permissions to any other group).
      Parameters:
      overrideGroup - The group that overrides any permission check.
      Returns:
      The manager.