Example usage for org.springframework.security.config.http AuthenticationConfigBuilder ATT_AUTH_DETAILS_SOURCE_REF

List of usage examples for org.springframework.security.config.http AuthenticationConfigBuilder ATT_AUTH_DETAILS_SOURCE_REF

Introduction

In this page you can find the example usage for org.springframework.security.config.http AuthenticationConfigBuilder ATT_AUTH_DETAILS_SOURCE_REF.

Prototype

String ATT_AUTH_DETAILS_SOURCE_REF

To view the source code for org.springframework.security.config.http AuthenticationConfigBuilder ATT_AUTH_DETAILS_SOURCE_REF.

Click Source Link

Usage

From source file:org.springframework.security.config.http.AuthenticationConfigBuilder.java

private void injectAuthenticationDetailsSource(Element elt, BeanDefinitionBuilder filterBuilder) {
    String authDetailsSourceRef = elt.getAttribute(AuthenticationConfigBuilder.ATT_AUTH_DETAILS_SOURCE_REF);

    if (StringUtils.hasText(authDetailsSourceRef)) {
        filterBuilder.addPropertyReference("authenticationDetailsSource", authDetailsSourceRef);
    }/*from w  ww.  j  a va2 s.c o m*/
}

From source file:org.springframework.security.config.http.FormLoginBeanDefinitionParser.java

public BeanDefinition parse(Element elt, ParserContext pc) {
    String loginUrl = null;/*from  w w  w  .ja  va 2s .  c  o m*/
    String defaultTargetUrl = null;
    String authenticationFailureUrl = null;
    String alwaysUseDefault = null;
    String successHandlerRef = null;
    String failureHandlerRef = null;
    // Only available with form-login
    String usernameParameter = null;
    String passwordParameter = null;
    String authDetailsSourceRef = null;
    String authenticationFailureForwardUrl = null;
    String authenticationSuccessForwardUrl = null;

    Object source = null;

    if (elt != null) {
        source = pc.extractSource(elt);
        loginUrl = elt.getAttribute(ATT_LOGIN_URL);
        WebConfigUtils.validateHttpRedirect(loginUrl, pc, source);
        defaultTargetUrl = elt.getAttribute(ATT_FORM_LOGIN_TARGET_URL);
        WebConfigUtils.validateHttpRedirect(defaultTargetUrl, pc, source);
        authenticationFailureUrl = elt.getAttribute(ATT_FORM_LOGIN_AUTHENTICATION_FAILURE_URL);
        WebConfigUtils.validateHttpRedirect(authenticationFailureUrl, pc, source);
        alwaysUseDefault = elt.getAttribute(ATT_ALWAYS_USE_DEFAULT_TARGET_URL);
        loginPage = elt.getAttribute(ATT_LOGIN_PAGE);
        successHandlerRef = elt.getAttribute(ATT_SUCCESS_HANDLER_REF);
        failureHandlerRef = elt.getAttribute(ATT_FAILURE_HANDLER_REF);
        authDetailsSourceRef = elt.getAttribute(AuthenticationConfigBuilder.ATT_AUTH_DETAILS_SOURCE_REF);
        authenticationFailureForwardUrl = elt.getAttribute(ATT_FORM_LOGIN_AUTHENTICATION_FAILURE_FORWARD_URL);
        WebConfigUtils.validateHttpRedirect(authenticationFailureForwardUrl, pc, source);
        authenticationSuccessForwardUrl = elt.getAttribute(ATT_FORM_LOGIN_AUTHENTICATION_SUCCESS_FORWARD_URL);
        WebConfigUtils.validateHttpRedirect(authenticationSuccessForwardUrl, pc, source);

        if (!StringUtils.hasText(loginPage)) {
            loginPage = null;
        }
        WebConfigUtils.validateHttpRedirect(loginPage, pc, source);
        usernameParameter = elt.getAttribute(ATT_USERNAME_PARAMETER);
        passwordParameter = elt.getAttribute(ATT_PASSWORD_PARAMETER);
    }

    filterBean = createFilterBean(loginUrl, defaultTargetUrl, alwaysUseDefault, loginPage,
            authenticationFailureUrl, successHandlerRef, failureHandlerRef, authDetailsSourceRef,
            authenticationFailureForwardUrl, authenticationSuccessForwardUrl);

    if (StringUtils.hasText(usernameParameter)) {
        filterBean.getPropertyValues().addPropertyValue("usernameParameter", usernameParameter);
    }
    if (StringUtils.hasText(passwordParameter)) {
        filterBean.getPropertyValues().addPropertyValue("passwordParameter", passwordParameter);
    }

    filterBean.setSource(source);

    BeanDefinitionBuilder entryPointBuilder = BeanDefinitionBuilder
            .rootBeanDefinition(LoginUrlAuthenticationEntryPoint.class);
    entryPointBuilder.getRawBeanDefinition().setSource(source);
    entryPointBuilder.addConstructorArgValue(loginPage != null ? loginPage : DEF_LOGIN_PAGE);
    entryPointBuilder.addPropertyValue("portMapper", portMapper);
    entryPointBuilder.addPropertyValue("portResolver", portResolver);
    entryPointBean = (RootBeanDefinition) entryPointBuilder.getBeanDefinition();

    return null;
}