Managing a Cache in a Secure System
To create a cache in a secured system, authentication at connection time will require credentials. Authorization permits operations as configured.
These steps demonstrate a programmatic cache creation.
To create the cache:
Add necessary security properties to the
gemfire.properties
orgfsecurity.properties
file, to configure for your particular security implementation. Examples:security-client-auth-init=mySecurity.UserPasswordAuthInit.create
security-peer-auth-init=myAuthPkg.myAuthInitImpl.create
When you create your cache, pass any properties required by your security implementation to the cache factory create call by using one of these methods:
ClientCacheFactory
orCacheFactory
set
methods. Example:ClientCache clientCache = new ClientCacheFactory() .set("security-username", username) .set("security-password", password) .create();
Properties object passed to the
ClientCacheFactory
orCacheFactory
create
method. These are usually properties of a sensitive nature that you do not want to put inside thegfsecurity.properties
file. Example:Properties properties = new Properties(); properties.setProperty("security-username", username); properties.setProperty("security-password", password); Cache cache = new CacheFactory(properties).create();
Note: Properties passed to a cache creation method override any settings in either the
gemfire.properties
file orgfsecurity.properties
.
Close your cache when you are done, using the
close
method of theClientCache
instance or the inheritedclose
method of theCache
instance. Example:cache.close();