Java 类org.springframework.beans.factory.support.SecurityContextProvider 实例源码

项目:spring4-understanding    文件:CallbacksSecurityTests.java   
@Before
public void setUp() throws Exception {

    final ProtectionDomain empty = new ProtectionDomain(null,
            new Permissions());

    provider = new SecurityContextProvider() {
        private final AccessControlContext acc = new AccessControlContext(
                new ProtectionDomain[] { empty });

        @Override
        public AccessControlContext getAccessControlContext() {
            return acc;
        }
    };

    DefaultResourceLoader drl = new DefaultResourceLoader();
    Resource config = drl
            .getResource("/org/springframework/beans/factory/support/security/callbacks.xml");
    beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config);
    beanFactory.setSecurityContextProvider(provider);
}
项目:class-guard    文件:CallbacksSecurityTests.java   
@Before
public void setUp() throws Exception {

    final ProtectionDomain empty = new ProtectionDomain(null,
            new Permissions());

    provider = new SecurityContextProvider() {
        private final AccessControlContext acc = new AccessControlContext(
                new ProtectionDomain[] { empty });

        @Override
        public AccessControlContext getAccessControlContext() {
            return acc;
        }
    };

    DefaultResourceLoader drl = new DefaultResourceLoader();
    Resource config = drl
            .getResource("/org/springframework/beans/factory/support/security/callbacks.xml");
    beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config);
    beanFactory.setSecurityContextProvider(provider);
}
项目:gemini.blueprint    文件:AbstractOsgiBundleApplicationContext.java   
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    super.postProcessBeanFactory(beanFactory);

    beanFactory.addBeanPostProcessor(new BundleContextAwareProcessor(this.bundleContext));
    beanFactory.ignoreDependencyInterface(BundleContextAware.class);

    if (beanFactory instanceof AbstractBeanFactory) {
        AbstractBeanFactory bf = (AbstractBeanFactory) beanFactory;
        bf.setSecurityContextProvider(new SecurityContextProvider() {

            public AccessControlContext getAccessControlContext() {
                return acc;
            }
        });
    }

    enforceExporterImporterDependency(beanFactory);

    // add predefined beans
    // bundleContext
    addPredefinedBean(beanFactory, BUNDLE_CONTEXT_BEAN_NAME, this.bundleContext);
    addPredefinedBean(beanFactory, BUNDLE_BEAN_NAME, this.bundle);

    // register property editors
    registerPropertyEditors(beanFactory);

    // register a 'bundle' scope
    beanFactory.registerScope(OsgiBundleScope.SCOPE_NAME, new OsgiBundleScope());
}
项目:spring-boot-starter-disruptor    文件:DisruptorEventAwareProcessor.java   
/**
 * Set the security context provider for this bean factory. If a security manager
 * is set, interaction with the user code will be executed using the privileged
 * of the provided security context.
 */
public void setSecurityContextProvider(SecurityContextProvider securityProvider) {
    this.securityContextProvider = securityProvider;
}