List of usage examples for org.springframework.security.config Elements ANONYMOUS
String ANONYMOUS
To view the source code for org.springframework.security.config Elements ANONYMOUS.
Click Source Link
From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java
void createAnonymousFilter() { Element anonymousElt = DomUtils.getChildElementByTagName(httpElt, Elements.ANONYMOUS); if (anonymousElt != null && "false".equals(anonymousElt.getAttribute("enabled"))) { return;/* w ww . j a v a2 s . com*/ } String grantedAuthority = null; String username = null; String key = null; Object source = pc.extractSource(httpElt); if (anonymousElt != null) { grantedAuthority = anonymousElt.getAttribute("granted-authority"); username = anonymousElt.getAttribute("username"); key = anonymousElt.getAttribute(ATT_KEY); source = pc.extractSource(anonymousElt); } if (!StringUtils.hasText(grantedAuthority)) { grantedAuthority = "ROLE_ANONYMOUS"; } if (!StringUtils.hasText(username)) { username = "anonymousUser"; } if (!StringUtils.hasText(key)) { // Generate a random key for the Anonymous provider key = createKey(); } anonymousFilter = new RootBeanDefinition(AnonymousAuthenticationFilter.class); anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(0, key); anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(1, username); anonymousFilter.getConstructorArgumentValues().addIndexedArgumentValue(2, AuthorityUtils.commaSeparatedStringToAuthorityList(grantedAuthority)); anonymousFilter.setSource(source); RootBeanDefinition anonymousProviderBean = new RootBeanDefinition(AnonymousAuthenticationProvider.class); anonymousProviderBean.getConstructorArgumentValues().addIndexedArgumentValue(0, key); anonymousProviderBean.setSource(anonymousFilter.getSource()); String id = pc.getReaderContext().generateBeanName(anonymousProviderBean); pc.registerBeanComponent(new BeanComponentDefinition(anonymousProviderBean, id)); anonymousProviderRef = new RuntimeBeanReference(id); }