List of usage examples for org.springframework.security.config Elements OPENID_LOGIN
String OPENID_LOGIN
To view the source code for org.springframework.security.config Elements OPENID_LOGIN.
Click Source Link
From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java
void createOpenIDLoginFilter(BeanReference sessionStrategy, BeanReference authManager) { Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.OPENID_LOGIN); RootBeanDefinition openIDFilter = null; if (openIDLoginElt != null) { FormLoginBeanDefinitionParser parser = new FormLoginBeanDefinitionParser("/login/openid", null, OPEN_ID_AUTHENTICATION_PROCESSING_FILTER_CLASS, requestCache, sessionStrategy, allowSessionCreation, portMapper, portResolver); parser.parse(openIDLoginElt, pc); openIDFilter = parser.getFilterBean(); openIDEntryPoint = parser.getEntryPointBean(); openidLoginProcessingUrl = parser.getLoginProcessingUrl(); openIDLoginPage = parser.getLoginPage(); List<Element> attrExElts = DomUtils.getChildElementsByTagName(openIDLoginElt, Elements.OPENID_ATTRIBUTE_EXCHANGE); if (!attrExElts.isEmpty()) { // Set up the consumer with the required attribute list BeanDefinitionBuilder consumerBldr = BeanDefinitionBuilder .rootBeanDefinition(OPEN_ID_CONSUMER_CLASS); BeanDefinitionBuilder axFactory = BeanDefinitionBuilder .rootBeanDefinition(OPEN_ID_ATTRIBUTE_FACTORY_CLASS); ManagedMap<String, ManagedList<BeanDefinition>> axMap = new ManagedMap<String, ManagedList<BeanDefinition>>(); for (Element attrExElt : attrExElts) { String identifierMatch = attrExElt.getAttribute("identifier-match"); if (!StringUtils.hasText(identifierMatch)) { if (attrExElts.size() > 1) { pc.getReaderContext() .error("You must supply an identifier-match attribute if using more" + " than one " + Elements.OPENID_ATTRIBUTE_EXCHANGE + " element", attrExElt); }/*w w w .j av a2 s .com*/ // Match anything identifierMatch = ".*"; } axMap.put(identifierMatch, parseOpenIDAttributes(attrExElt)); } axFactory.addConstructorArgValue(axMap); consumerBldr.addConstructorArgValue(axFactory.getBeanDefinition()); openIDFilter.getPropertyValues().addPropertyValue("consumer", consumerBldr.getBeanDefinition()); } } if (openIDFilter != null) { openIDFilter.getPropertyValues().addPropertyValue("allowSessionCreation", allowSessionCreation); openIDFilter.getPropertyValues().addPropertyValue("authenticationManager", authManager); // Required by login page filter openIDFilterId = pc.getReaderContext().generateBeanName(openIDFilter); pc.registerBeanComponent(new BeanComponentDefinition(openIDFilter, openIDFilterId)); injectRememberMeServicesRef(openIDFilter, rememberMeServicesId); createOpenIDProvider(); } }
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()// www. j a v a 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 BeanMetadataElement selectEntryPoint() { // We need to establish the main entry point. // First check if a custom entry point bean is set String customEntryPoint = httpElt.getAttribute(ATT_ENTRY_POINT_REF); if (StringUtils.hasText(customEntryPoint)) { return new RuntimeBeanReference(customEntryPoint); }/*from w w w . ja va 2 s . co m*/ Element basicAuthElt = DomUtils.getChildElementByTagName(httpElt, Elements.BASIC_AUTH); Element formLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.FORM_LOGIN); Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.OPENID_LOGIN); // Basic takes precedence if explicit element is used and no others are configured if (basicAuthElt != null && formLoginElt == null && openIDLoginElt == null) { return basicEntryPoint; } // If formLogin has been enabled either through an element or auto-config, then it // is used if no openID login page // has been set. if (formLoginPage != null && openIDLoginPage != null) { pc.getReaderContext().error( "Only one login-page can be defined, either for OpenID or form-login, " + "but not both.", pc.extractSource(openIDLoginElt)); } if (formFilterId != null && openIDLoginPage == null) { return formEntryPoint; } // Otherwise use OpenID if enabled if (openIDFilterId != null) { return openIDEntryPoint; } // If X.509 or JEE have been enabled, use the preauth entry point. if (preAuthEntryPoint != null) { return preAuthEntryPoint; } pc.getReaderContext().error("No AuthenticationEntryPoint could be established. Please " + "make sure you have a login mechanism configured through the namespace (such as form-login) or " + "specify a custom AuthenticationEntryPoint with the '" + ATT_ENTRY_POINT_REF + "' attribute ", pc.extractSource(httpElt)); return null; }