List of usage examples for org.springframework.security.config Elements BASIC_AUTH
String BASIC_AUTH
To view the source code for org.springframework.security.config Elements BASIC_AUTH.
Click Source Link
From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java
void createBasicFilter(BeanReference authManager) { Element basicAuthElt = DomUtils.getChildElementByTagName(httpElt, Elements.BASIC_AUTH); if (basicAuthElt == null && !autoConfig) { // No basic auth, do nothing return;//from w ww.j av a2 s.c o m } String realm = httpElt.getAttribute(ATT_REALM); if (!StringUtils.hasText(realm)) { realm = DEF_REALM; } BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder .rootBeanDefinition(BasicAuthenticationFilter.class); String entryPointId; if (basicAuthElt != null) { if (StringUtils.hasText(basicAuthElt.getAttribute(ATT_ENTRY_POINT_REF))) { basicEntryPoint = new RuntimeBeanReference(basicAuthElt.getAttribute(ATT_ENTRY_POINT_REF)); } injectAuthenticationDetailsSource(basicAuthElt, filterBuilder); } if (basicEntryPoint == null) { RootBeanDefinition entryPoint = new RootBeanDefinition(BasicAuthenticationEntryPoint.class); entryPoint.setSource(pc.extractSource(httpElt)); entryPoint.getPropertyValues().addPropertyValue("realmName", realm); entryPointId = pc.getReaderContext().generateBeanName(entryPoint); pc.registerBeanComponent(new BeanComponentDefinition(entryPoint, entryPointId)); basicEntryPoint = new RuntimeBeanReference(entryPointId); } filterBuilder.addConstructorArgValue(authManager); filterBuilder.addConstructorArgValue(basicEntryPoint); basicFilter = filterBuilder.getBeanDefinition(); }
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 .j av a 2 s .com*/ 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; }