com.holonplatform.auth

## Interface Authorizer<P extends Permission>

- Type Parameters:
    `P` - Supported Permission type
  All Known Subinterfaces:
    Realm

      public interface Authorizer<P extends Permission>

  Authorizer is responsible for `Authentication` authorization control using `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<P> permissions)` Check if given Authentication has all specified permission/s using a Collection
    `boolean` | `isPermitted(Authentication authentication, P... permissions)` Check if given Authentication has all specified permission/s
    `boolean` | `isPermitted(Authentication authentication, String... permissions)` Check if given Authentication has all specified permission/s using String permission form.
    `boolean` | `isPermittedAny(Authentication authentication, Collection<P> permissions)` Check if given Authentication has any of specified permission/s using a Collection
    `boolean` | `isPermittedAny(Authentication authentication, P... permissions)` Check if given Authentication has any of specified permission/s
    `boolean` | `isPermittedAny(Authentication authentication, String... permissions)` Check if given Authentication has any of specified permission/s using String permission form.

- - ### Method Detail

    - #### getPermissionType

          Class<? extends P> getPermissionType()

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

    - #### isPermitted

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

      Check if given Authentication has all specified permission/s
      Parameters:
        `authentication` - Authentication subject
        `permissions` - Permissions to check
      Returns:
        `true` if given Authentication has all specified permission

    - #### isPermitted

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

      Check if given Authentication has all specified permission/s using String permission form.

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

      Parameters:
        `authentication` - Authentication subject
        `permissions` - Permissions to check
      Returns:
        `true` if given Authentication has all specified permission

    - #### isPermittedAny

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

      Check if given Authentication has any of specified permission/s
      Parameters:
        `authentication` - Authentication subject
        `permissions` - Permissions to check
      Returns:
        `true` if given Authentication has any of specified permission

    - #### isPermittedAny

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

      Check if given Authentication has any of specified permission/s using String permission form.

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

      Parameters:
        `authentication` - Authentication subject
        `permissions` - Permissions to check
      Returns:
        `true` if given Authentication has any of specified permission

    - #### isPermitted

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

      Check if given Authentication has all specified permission/s using a Collection
      Parameters:
        `authentication` - Authentication subject
        `permissions` - Permissions to check
      Returns:
        `true` if given Authentication has all specified permission

    - #### isPermittedAny

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

      Check if given Authentication has any of specified permission/s using a Collection
      Parameters:
        `authentication` - Authentication subject
        `permissions` - Permissions to check
      Returns:
        `true` if given Authentication has any of 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 © 2017 The Holon Platform. All rights reserved.