List of usage examples for org.springframework.security.config BeanIds USER_DETAILS_SERVICE_FACTORY
String USER_DETAILS_SERVICE_FACTORY
To view the source code for org.springframework.security.config BeanIds USER_DETAILS_SERVICE_FACTORY.
Click Source Link
From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java
private void createOpenIDProvider() { Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.OPENID_LOGIN); BeanDefinitionBuilder openIDProviderBuilder = BeanDefinitionBuilder .rootBeanDefinition(OPEN_ID_AUTHENTICATION_PROVIDER_CLASS); RootBeanDefinition uds = new RootBeanDefinition(); uds.setFactoryBeanName(BeanIds.USER_DETAILS_SERVICE_FACTORY); uds.setFactoryMethodName("authenticationUserDetailsService"); uds.getConstructorArgumentValues()//from w ww . j a va 2 s. co m .addGenericArgumentValue(openIDLoginElt.getAttribute(ATT_USER_SERVICE_REF)); openIDProviderBuilder.addPropertyValue("authenticationUserDetailsService", uds); BeanDefinition openIDProvider = openIDProviderBuilder.getBeanDefinition(); openIDProviderRef = new RuntimeBeanReference( pc.getReaderContext().registerWithGeneratedName(openIDProvider)); }
From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java
private void createX509Provider() { Element x509Elt = DomUtils.getChildElementByTagName(httpElt, Elements.X509); BeanDefinition provider = new RootBeanDefinition(PreAuthenticatedAuthenticationProvider.class); RootBeanDefinition uds = new RootBeanDefinition(); uds.setFactoryBeanName(BeanIds.USER_DETAILS_SERVICE_FACTORY); uds.setFactoryMethodName("authenticationUserDetailsService"); uds.getConstructorArgumentValues().addGenericArgumentValue(x509Elt.getAttribute(ATT_USER_SERVICE_REF)); provider.getPropertyValues().addPropertyValue("preAuthenticatedUserDetailsService", uds); x509ProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(provider)); }
From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java
private void createJeeProvider() { Element jeeElt = DomUtils.getChildElementByTagName(httpElt, Elements.JEE); BeanDefinition provider = new RootBeanDefinition(PreAuthenticatedAuthenticationProvider.class); RootBeanDefinition uds;/*from w w w. jav a2s . c o m*/ if (StringUtils.hasText(jeeElt.getAttribute(ATT_USER_SERVICE_REF))) { uds = new RootBeanDefinition(); uds.setFactoryBeanName(BeanIds.USER_DETAILS_SERVICE_FACTORY); uds.setFactoryMethodName("authenticationUserDetailsService"); uds.getConstructorArgumentValues().addGenericArgumentValue(jeeElt.getAttribute(ATT_USER_SERVICE_REF)); } else { uds = new RootBeanDefinition(PreAuthenticatedGrantedAuthoritiesUserDetailsService.class); } provider.getPropertyValues().addPropertyValue("preAuthenticatedUserDetailsService", uds); jeeProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(provider)); }
From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java
private void createUserDetailsServiceFactory() { if (pc.getRegistry().containsBeanDefinition(BeanIds.USER_DETAILS_SERVICE_FACTORY)) { // Multiple <http> case return;/* w ww . j a va 2s. c om*/ } RootBeanDefinition bean = new RootBeanDefinition(UserDetailsServiceFactoryBean.class); bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); pc.registerBeanComponent(new BeanComponentDefinition(bean, BeanIds.USER_DETAILS_SERVICE_FACTORY)); }
From source file:org.springframework.security.config.http.RememberMeBeanDefinitionParser.java
public BeanDefinition parse(Element element, ParserContext pc) { CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), pc.extractSource(element));//from w w w .j ava 2s . co m pc.pushContainingComponent(compositeDef); String tokenRepository = element.getAttribute(ATT_TOKEN_REPOSITORY); String dataSource = element.getAttribute(ATT_DATA_SOURCE); String userServiceRef = element.getAttribute(ATT_USER_SERVICE_REF); String successHandlerRef = element.getAttribute(ATT_SUCCESS_HANDLER_REF); String rememberMeServicesRef = element.getAttribute(ATT_SERVICES_REF); String tokenValiditySeconds = element.getAttribute(ATT_TOKEN_VALIDITY); String useSecureCookie = element.getAttribute(ATT_SECURE_COOKIE); String remembermeParameter = element.getAttribute(ATT_FORM_REMEMBERME_PARAMETER); String remembermeCookie = element.getAttribute(ATT_REMEMBERME_COOKIE); Object source = pc.extractSource(element); RootBeanDefinition services = null; boolean dataSourceSet = StringUtils.hasText(dataSource); boolean tokenRepoSet = StringUtils.hasText(tokenRepository); boolean servicesRefSet = StringUtils.hasText(rememberMeServicesRef); boolean userServiceSet = StringUtils.hasText(userServiceRef); boolean useSecureCookieSet = StringUtils.hasText(useSecureCookie); boolean tokenValiditySet = StringUtils.hasText(tokenValiditySeconds); boolean remembermeParameterSet = StringUtils.hasText(remembermeParameter); boolean remembermeCookieSet = StringUtils.hasText(remembermeCookie); if (servicesRefSet && (dataSourceSet || tokenRepoSet || userServiceSet || tokenValiditySet || useSecureCookieSet || remembermeParameterSet || remembermeCookieSet)) { pc.getReaderContext() .error(ATT_SERVICES_REF + " can't be used in combination with attributes " + ATT_TOKEN_REPOSITORY + "," + ATT_DATA_SOURCE + ", " + ATT_USER_SERVICE_REF + ", " + ATT_TOKEN_VALIDITY + ", " + ATT_SECURE_COOKIE + ", " + ATT_FORM_REMEMBERME_PARAMETER + " or " + ATT_REMEMBERME_COOKIE, source); } if (dataSourceSet && tokenRepoSet) { pc.getReaderContext() .error("Specify " + ATT_TOKEN_REPOSITORY + " or " + ATT_DATA_SOURCE + " but not both", source); } boolean isPersistent = dataSourceSet | tokenRepoSet; if (isPersistent) { Object tokenRepo; services = new RootBeanDefinition(PersistentTokenBasedRememberMeServices.class); if (tokenRepoSet) { tokenRepo = new RuntimeBeanReference(tokenRepository); } else { tokenRepo = new RootBeanDefinition(JdbcTokenRepositoryImpl.class); ((BeanDefinition) tokenRepo).getPropertyValues().addPropertyValue("dataSource", new RuntimeBeanReference(dataSource)); } services.getConstructorArgumentValues().addIndexedArgumentValue(2, tokenRepo); } else if (!servicesRefSet) { services = new RootBeanDefinition(TokenBasedRememberMeServices.class); } String servicesName; if (services != null) { RootBeanDefinition uds = new RootBeanDefinition(); uds.setFactoryBeanName(BeanIds.USER_DETAILS_SERVICE_FACTORY); uds.setFactoryMethodName("cachingUserDetailsService"); uds.getConstructorArgumentValues().addGenericArgumentValue(userServiceRef); services.getConstructorArgumentValues().addGenericArgumentValue(key); services.getConstructorArgumentValues().addGenericArgumentValue(uds); // tokenRepo is already added if it is a // PersistentTokenBasedRememberMeServices if (useSecureCookieSet) { services.getPropertyValues().addPropertyValue("useSecureCookie", Boolean.valueOf(useSecureCookie)); } if (tokenValiditySet) { boolean isTokenValidityNegative = tokenValiditySeconds.startsWith("-"); if (isTokenValidityNegative && isPersistent) { pc.getReaderContext().error(ATT_TOKEN_VALIDITY + " cannot be negative if using" + " a persistent remember-me token repository", source); } services.getPropertyValues().addPropertyValue("tokenValiditySeconds", tokenValiditySeconds); } if (remembermeParameterSet) { services.getPropertyValues().addPropertyValue("parameter", remembermeParameter); } if (remembermeCookieSet) { services.getPropertyValues().addPropertyValue("cookieName", remembermeCookie); } services.setSource(source); servicesName = pc.getReaderContext().generateBeanName(services); pc.registerBeanComponent(new BeanComponentDefinition(services, servicesName)); } else { servicesName = rememberMeServicesRef; } if (StringUtils.hasText(element.getAttribute(ATT_SERVICES_ALIAS))) { pc.getRegistry().registerAlias(servicesName, element.getAttribute(ATT_SERVICES_ALIAS)); } this.rememberMeServicesId = servicesName; BeanDefinitionBuilder filter = BeanDefinitionBuilder .rootBeanDefinition(RememberMeAuthenticationFilter.class); filter.getRawBeanDefinition().setSource(source); if (StringUtils.hasText(successHandlerRef)) { filter.addPropertyReference("authenticationSuccessHandler", successHandlerRef); } filter.addConstructorArgValue(authenticationManager); filter.addConstructorArgReference(servicesName); pc.popAndRegisterContainingComponent(); return filter.getBeanDefinition(); }