com.holonplatform.auth

## Interface Authorizer<P extends Permission>

- Type Parameters:
    `P` - Supported Permission type
  All Known Subinterfaces:
    Realm
  All Known Implementing Classes:
    AbstractAuthorizer, DefaultAuthorizer, DefaultRealm

      public interface Authorizer<P extends Permission>

  An Authorizer is responsible for `Authentication` authorization control using `Authentication.getPermissions()` permissions.
  Since:
    5.0.0

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Authorizer<Permission>` | `create()` Create a default Authorizer.
    `Class<? extends P>` | `getPermissionType()` Get supported `Permission` type
    `boolean` | `isPermitted(Authentication authentication, Collection<? extends P> permissions)` Check if given Authentication has all the specified permissions.
    `boolean` | `isPermitted(Authentication authentication, String... permissions)` Check if given Authentication has all specified permission/s, using the `String` permission representation.
    `default <T extends P> boolean` | `isPermitted(Authentication authentication, T... permissions)` Check if given Authentication has all the specified permission/s.
    `boolean` | `isPermittedAny(Authentication authentication, Collection<? extends P> permissions)` Check if given Authentication has any of the specified permissions.
    `boolean` | `isPermittedAny(Authentication authentication, String... permissions)` Check if given Authentication has any of the specified permission/s, using the `String` permission representation.
    `default <T extends P> boolean` | `isPermittedAny(Authentication authentication, T... permissions)` Check if given Authentication has any of the specified permission/s.

- - ### Method Detail

    - #### getPermissionType

          Class<? extends P> getPermissionType()

      Get supported `Permission` type
      Returns:
        Supported `Permission` type

    - #### isPermitted

          boolean isPermitted(Authentication authentication,
                              Collection<? extends P> permissions)

      Check if given Authentication has all the specified permissions.
      Parameters:
        `authentication` - The Authentication for which to check the permissions
        `permissions` - The permissions to be checked
      Returns:
        `true` if given Authentication has all the specified permissions

    - #### isPermitted

          default <T extends P> boolean isPermitted(Authentication authentication,
                                                    T... permissions)

      Check if given Authentication has all the specified permission/s.
      Type Parameters:
        `T` - Permission type
      Parameters:
        `authentication` - The Authentication for which to check the permissions
        `permissions` - The permissions to be checked
      Returns:
        `true` if given Authentication has all the specified permissions

    - #### isPermitted

          boolean isPermitted(Authentication authentication,
                              String... permissions)

      Check if given Authentication has all specified permission/s, using the `String` permission representation.

      String permission match against Authentication `Permission`s should be performed using the `Permission.getPermission()` method.

      Parameters:
        `authentication` - The Authentication for which to check the permissions
        `permissions` - The permissions to be checked
      Returns:
        `true` if given Authentication has all the specified permissions

    - #### isPermittedAny

          boolean isPermittedAny(Authentication authentication,
                                 Collection<? extends P> permissions)

      Check if given Authentication has any of the specified permissions.
      Parameters:
        `authentication` - The Authentication for which to check the permissions
        `permissions` - The permissions to be checked
      Returns:
        `true` if given Authentication has any of the specified permission

    - #### isPermittedAny

          default <T extends P> boolean isPermittedAny(Authentication authentication,
                                                       T... permissions)

      Check if given Authentication has any of the specified permission/s.
      Type Parameters:
        `T` - Permission type
      Parameters:
        `authentication` - The Authentication for which to check the permissions
        `permissions` - The permissions to be checked
      Returns:
        `true` if given Authentication has any of the specified permission

    - #### isPermittedAny

          boolean isPermittedAny(Authentication authentication,
                                 String... permissions)

      Check if given Authentication has any of the specified permission/s, using the `String` permission representation.

      String permission match against Authentication `Permission`s will be performed using `Permission.getPermission()` method.

      Parameters:
        `authentication` - The Authentication for which to check the permissions
        `permissions` - The permissions to be checked
      Returns:
        `true` if given Authentication has any of the specified permission

    - #### create

          static Authorizer<Permission> create()

      Create a default Authorizer.

      The default Authorizer never throws exceptions, adopting the following behaviour:

      - if `null` `Authentication` is given, always returns `false`
      - if `null` or empty permissions are given, always returns `false`
      - if `Authentication` is not `null` and is `root`, always returns `true`
      - For other cases, permission checking is performed comparing Authentication granted permission with requested permissions using `Permission.equals(Object)` to compare a single permission to another
      Returns:
        Authorizer
      See Also:
        `DefaultAuthorizer`

Copyright © 2019 The Holon Platform. All rights reserved.