public class ExampleSecurityManager extends Object implements SecurityManager
SecurityManager
for authentication and
authorization initialized from data provided as JSON.
A Geode member must be configured with the following:
security-manager = org.apache.geode.examples.security.ExampleSecurityManager
The class can be initialized with from a JSON resource called security.json
. This file
must exist on the classpath, so members should be started with an appropriate --classpath
option.
The format of the JSON for configuration is as follows:
{
"roles": [
{
"name": "admin",
"operationsAllowed": [
"CLUSTER:MANAGE",
"DATA:MANAGE"
]
},
{
"name": "readRegionA",
"operationsAllowed": [
"DATA:READ"
],
"regions": ["RegionA", "RegionB"]
}
],
"users": [
{
"name": "admin",
"password": "secret",
"roles": ["admin"]
},
{
"name": "guest",
"password": "guest",
"roles": ["readRegionA"]
}
]
}
Modifier and Type | Class and Description |
---|---|
static class |
ExampleSecurityManager.Role |
static class |
ExampleSecurityManager.User |
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_JSON_FILE_NAME |
static String |
SECURITY_JSON |
PASSWORD, TOKEN, USER_NAME
Constructor and Description |
---|
ExampleSecurityManager() |
Modifier and Type | Method and Description |
---|---|
Object |
authenticate(Properties credentials)
Verify the credentials provided in the properties
Your security manager needs to validate credentials coming from all communication channels.
|
boolean |
authorize(Object principal,
ResourcePermission context)
Authorize the ResourcePermission for a given Principal
|
ExampleSecurityManager.User |
getUser(String user) |
void |
init(Properties securityProperties)
Initialize the SecurityManager.
|
boolean |
initializeFromJsonResource(String jsonResource) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public static final String SECURITY_JSON
protected static final String DEFAULT_JSON_FILE_NAME
public boolean authorize(Object principal, ResourcePermission context)
SecurityManager
authorize
in interface SecurityManager
principal
- The principal that's requesting the permissioncontext
- The permission requestedpublic void init(Properties securityProperties) throws NotAuthorizedException
SecurityManager
init
in interface SecurityManager
securityProperties
- the security properties obtained using a call to
DistributedSystem.getSecurityProperties()
NotAuthorizedException
public Object authenticate(Properties credentials) throws AuthenticationFailedException
SecurityManager
authenticate
in interface SecurityManager
credentials
- it contains the security-username, security-password or security-token,
as keys of the properties, also the properties generated by your AuthInitialize
interfaceAuthenticationFailedException
- if the credentials are invalid, this exception will be
seen by the client.public boolean initializeFromJsonResource(String jsonResource)
public ExampleSecurityManager.User getUser(String user)