use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-security by spring-projects.
the class ClearCredentialsMethodInvokingFactoryBean method createPortResolver.
private RuntimeBeanReference createPortResolver(BeanReference portMapper, ParserContext pc) {
RootBeanDefinition portResolver = new RootBeanDefinition(PortResolverImpl.class);
portResolver.getPropertyValues().addPropertyValue("portMapper", portMapper);
String portResolverName = pc.getReaderContext().generateBeanName(portResolver);
pc.registerBeanComponent(new BeanComponentDefinition(portResolver, portResolverName));
return new RuntimeBeanReference(portResolverName);
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-security by spring-projects.
the class LogoutBeanDefinitionParser method parse.
public BeanDefinition parse(Element element, ParserContext pc) {
String logoutUrl = null;
String successHandlerRef = null;
String logoutSuccessUrl = null;
String invalidateSession = null;
String deleteCookies = null;
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(LogoutFilter.class);
if (element != null) {
Object source = pc.extractSource(element);
builder.getRawBeanDefinition().setSource(source);
logoutUrl = element.getAttribute(ATT_LOGOUT_URL);
successHandlerRef = element.getAttribute(ATT_LOGOUT_HANDLER);
WebConfigUtils.validateHttpRedirect(logoutUrl, pc, source);
logoutSuccessUrl = element.getAttribute(ATT_LOGOUT_SUCCESS_URL);
WebConfigUtils.validateHttpRedirect(logoutSuccessUrl, pc, source);
invalidateSession = element.getAttribute(ATT_INVALIDATE_SESSION);
deleteCookies = element.getAttribute(ATT_DELETE_COOKIES);
}
if (!StringUtils.hasText(logoutUrl)) {
logoutUrl = DEF_LOGOUT_URL;
}
builder.addPropertyValue("logoutRequestMatcher", getLogoutRequestMatcher(logoutUrl));
if (StringUtils.hasText(successHandlerRef)) {
if (StringUtils.hasText(logoutSuccessUrl)) {
pc.getReaderContext().error("Use " + ATT_LOGOUT_SUCCESS_URL + " or " + ATT_LOGOUT_HANDLER + ", but not both", pc.extractSource(element));
}
builder.addConstructorArgReference(successHandlerRef);
} else {
// Use the logout URL if no handler set
if (!StringUtils.hasText(logoutSuccessUrl)) {
logoutSuccessUrl = defaultLogoutUrl;
}
builder.addConstructorArgValue(logoutSuccessUrl);
}
BeanDefinition sclh = new RootBeanDefinition(SecurityContextLogoutHandler.class);
sclh.getPropertyValues().addPropertyValue("invalidateHttpSession", !"false".equals(invalidateSession));
logoutHandlers.add(sclh);
if (rememberMeServices != null) {
logoutHandlers.add(new RuntimeBeanReference(rememberMeServices));
}
if (StringUtils.hasText(deleteCookies)) {
BeanDefinition cookieDeleter = new RootBeanDefinition(CookieClearingLogoutHandler.class);
String[] names = StringUtils.tokenizeToStringArray(deleteCookies, ",");
cookieDeleter.getConstructorArgumentValues().addGenericArgumentValue(names);
logoutHandlers.add(cookieDeleter);
}
builder.addConstructorArgValue(logoutHandlers);
return builder.getBeanDefinition();
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-security by spring-projects.
the class PasswordEncoderParser method parse.
private void parse(Element element, ParserContext parserContext) {
String hash = element.getAttribute(ATT_HASH);
boolean useBase64 = false;
if (StringUtils.hasText(element.getAttribute(ATT_BASE_64))) {
useBase64 = Boolean.valueOf(element.getAttribute(ATT_BASE_64)).booleanValue();
}
String ref = element.getAttribute(ATT_REF);
if (StringUtils.hasText(ref)) {
passwordEncoder = new RuntimeBeanReference(ref);
} else {
passwordEncoder = createPasswordEncoderBeanDefinition(hash, useBase64);
((RootBeanDefinition) passwordEncoder).setSource(parserContext.extractSource(element));
}
Element saltSourceElt = DomUtils.getChildElementByTagName(element, Elements.SALT_SOURCE);
if (saltSourceElt != null) {
if (OPT_HASH_BCRYPT.equals(hash)) {
parserContext.getReaderContext().error(Elements.SALT_SOURCE + " isn't compatible with bcrypt", parserContext.extractSource(saltSourceElt));
} else {
saltSource = new SaltSourceBeanDefinitionParser().parse(saltSourceElt, parserContext);
}
}
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-security by spring-projects.
the class AuthenticationConfigBuilder method createRememberMeProvider.
private void createRememberMeProvider(String key) {
RootBeanDefinition provider = new RootBeanDefinition(RememberMeAuthenticationProvider.class);
provider.setSource(rememberMeFilter.getSource());
provider.getConstructorArgumentValues().addGenericArgumentValue(key);
String id = pc.getReaderContext().generateBeanName(provider);
pc.registerBeanComponent(new BeanComponentDefinition(provider, id));
rememberMeProviderRef = new RuntimeBeanReference(id);
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-security by spring-projects.
the class HeadersBeanDefinitionParser method parseHeaderElements.
private void parseHeaderElements(Element element) {
List<Element> headerElts = element == null ? Collections.<Element>emptyList() : DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT);
for (Element headerElt : headerElts) {
String headerFactoryRef = headerElt.getAttribute(ATT_REF);
if (StringUtils.hasText(headerFactoryRef)) {
headerWriters.add(new RuntimeBeanReference(headerFactoryRef));
} else {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(StaticHeadersWriter.class);
builder.addConstructorArgValue(headerElt.getAttribute(ATT_NAME));
builder.addConstructorArgValue(headerElt.getAttribute(ATT_VALUE));
headerWriters.add(builder.getBeanDefinition());
}
}
}
Aggregations