Interface PermissionResolver

  • All Known Implementing Classes:
    WildcardPermissionResolver

    public interface PermissionResolver
    A PermisisonResolver resolves a String value and converts it into a Permission instance.

    The default WildcardPermissionResolver should be suitable for most purposes, which constructs WildcardPermission objects. However, any resolver may be configured if an application wishes to use different Permission implementations.

    A PermissionResolver is used by many Shiro components such as annotations, property file configuration, URL configuration, etc. It is useful whenever a String representation of a permission is specified and that String needs to be converted to a Permission instance before executing a security check.

    Shiro chooses to support Wildcardpermissions by default in almost all components and we do that in the form of the WildcardPermissionResolver. One of the nice things about WildcardPermissions being supported by default is that it makes it very easy to store complex permissions in the database - and also makes it very easy to represent permissions in JSP files, annotations, etc., where a simple string representation is useful.

    Although this happens to be the Shiro default, you are of course free to provide custom String-to-Permission conversion by providing Shiro components any instance of this interface.

    Since:
    0.9
    See Also:
    ModularRealmAuthorizer.setPermissionResolver, AuthorizingRealm.setPermissionResolver, PermissionResolverAware
    • Method Detail

      • resolvePermission

        Permission resolvePermission​(String permissionString)
        Resolves a Permission based on the given String representation.
        Parameters:
        permissionString - the String representation of a permission.
        Returns:
        A Permission object that can be used internally to determine a subject's permissions.
        Throws:
        InvalidPermissionStringException - if the permission string is not valid for this resolver.