Interface IUserPermissions

  • All Known Implementing Classes:
    UserPermissions

    public interface IUserPermissions
    Interface that represents the permissions for a single user.

    This example demonstrates how to insert an IUserPermissions into a token.

    import com.caplin.keymaster.AuthenticationParameters;
    import com.caplin.keymaster.IAuthenticationParameters;
    import com.caplin.keymaster.IKeyMaster;
    import com.caplin.keymaster.IKeyMasterFormatter;
    import com.caplin.keymaster.StandardFormatter;
    
    public class CreateTokenWithPermissions
    {
            public String generateToken(IKeyMaster keymaster, String username, IUserPermissions permissions)
            {
                    // Create a set of authentication parameters that encapsulate the permissions.
                    IAuthenticationParameters authParams = new AuthenticationParameters(username, permissions);
                    
                    // Create a new formatter instance (they can be reused).
                    IKeyMasterFormatter formatter = new StandardFormatter();
                    
                    // Generate and return the KeyMaster token.
                    return keymaster.generateToken(authParams, formatter);
            }
            
    }
    

    • Method Detail

      • addPermission

        void addPermission​(IPermission permission)
        Adds a new subject permission to the user's permissioning information.

        Permissions are applied on a first match basis, and the matching process is in the order that the permissions were added to the IUserPermissions. As a result, you should add more specific permissions before more general ones. For example, you should add a permission for /FX/GBPEUR before adding a permission for ^/FX.

        Parameters:
        permission - The subject permission to add.
      • addMapping

        void addMapping​(ISubjectMapping mapping)
        Adds a new subject mapping to the user's permissioning information.

        Mappings are applied on a first match basis, and the matching process is in the order that the mappings were added to the IUserPermissions. As a result, you should add more specific mappings before more general ones.

        Parameters:
        mapping - The subject mapping to add.
      • toPermissionString

        java.lang.String toPermissionString()
        Returns a string representation of the user's permissions.
        Returns:
        A string representation of the user's permissions.