DATAGEODE-111 - Add ability to configure SecurityManager on CacheFactoryBean.

This commit is contained in:
John Blum
2018-06-07 23:21:39 -07:00
parent 6ebc2a0611
commit d9346ea814
2 changed files with 97 additions and 6 deletions

View File

@@ -53,6 +53,7 @@ import org.apache.geode.internal.datasource.ConfigProperty;
import org.apache.geode.internal.jndi.JNDIInvoker;
import org.apache.geode.pdx.PdxSerializable;
import org.apache.geode.pdx.PdxSerializer;
import org.apache.geode.security.SecurityManager;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
@@ -159,6 +160,8 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
private String cacheResolutionMessagePrefix;
private String pdxDiskStoreName;
private org.apache.geode.security.SecurityManager securityManager;
private TransactionWriter transactionWriter;
/**
@@ -402,13 +405,13 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
* @see #configurePdx(CacheFactory)
*/
protected Object configureFactory(Object factory) {
return configurePdx((CacheFactory) factory);
return configureSecurity(configurePdx((CacheFactory) factory));
}
/**
* Configure PDX for the given {@link CacheFactory}.
* Configures PDX for this peer {@link Cache} instance.
*
* @param cacheFactory {@link CacheFactory} used to configure PDX.
* @param cacheFactory {@link CacheFactory} used to configure the peer {@link Cache} with PDX.
* @return the given {@link CacheFactory}.
* @see org.apache.geode.cache.CacheFactory
*/
@@ -428,6 +431,20 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
return cacheFactory;
}
/**
* Configures security for this peer {@link Cache} instance.
*
* @param cacheFactory {@link CacheFactory} used to configure the peer {@link Cache} with security.
* @return the given {@link CacheFactory}.
* @see org.apache.geode.cache.CacheFactory
*/
private CacheFactory configureSecurity(CacheFactory cacheFactory) {
Optional.ofNullable(getSecurityManager()).ifPresent(cacheFactory::setSecurityManager);
return cacheFactory;
}
/**
* Post processes the {@link CacheFactory} used to create the {@link Cache}.
*
@@ -1223,6 +1240,26 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
return searchTimeout;
}
/**
* Configures the {@link org.apache.geode.security.SecurityManager} used to secure this cache.
*
* @param securityManager {@link org.apache.geode.security.SecurityManager} used to secure this cache.
* @see org.apache.geode.security.SecurityManager
*/
public void setSecurityManager(SecurityManager securityManager) {
this.securityManager = securityManager;
}
/**
* Returns the {@link org.apache.geode.security.SecurityManager} used to secure this cache.
*
* @return the {@link org.apache.geode.security.SecurityManager} used to secure this cache.
* @see org.apache.geode.security.SecurityManager
*/
public SecurityManager getSecurityManager() {
return securityManager;
}
/**
* Sets the list of TransactionListeners used to configure the Cache to receive transaction events after
* the transaction is processed (committed, rolled back).