public interface IUserPermissions
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);
}
}
Modifier and Type | Method and Description |
---|---|
void |
addMapping(ISubjectMapping mapping)
Adds a new subject mapping to the user's permissioning information.
|
void |
addPermission(IPermission permission)
Adds a new subject permission to the user's permissioning information.
|
java.lang.String |
toPermissionString()
Returns a string representation of the user's permissions.
|
void addPermission(IPermission permission)
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.
permission
- The subject permission to add.void addMapping(ISubjectMapping mapping)
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.
mapping
- The subject mapping to add.java.lang.String toPermissionString()
Please send bug reports and comments to Caplin support