當前位置: 首頁>>代碼示例>>Java>>正文


Java AuthenticationManagerBuilder類代碼示例

本文整理匯總了Java中org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder的典型用法代碼示例。如果您正苦於以下問題:Java AuthenticationManagerBuilder類的具體用法?Java AuthenticationManagerBuilder怎麽用?Java AuthenticationManagerBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AuthenticationManagerBuilder類屬於org.springframework.security.config.annotation.authentication.builders包,在下文中一共展示了AuthenticationManagerBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Override
protected void configure(AuthenticationManagerBuilder auth) {

    try {
        auth.jdbcAuthentication()
                .dataSource(dataSource)
                .usersByUsernameQuery(
                        "SELECT username, password, enabled " +
                                "FROM users " +
                                "WHERE username = ?"
                )
                .authoritiesByUsernameQuery(
                        "SELECT x.username, y.roles " +
                                "FROM users x, user_entity_roles y " +
                                "WHERE x.username = ? and y.user_entity_username = x.username "
                )
                /*
                    Note: in BCrypt, the "password" field also contains the salt
                 */
                .passwordEncoder(passwordEncoder);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:arcuri82,項目名稱:testing_security_development_enterprise_systems,代碼行數:25,代碼來源:WebSecurityConfig.java

示例2: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    if (ShepherConstants.LOGIN_TYPE_LDAP.equals(loginType.toUpperCase())) {
        auth.ldapAuthentication()
                .userDnPatterns("uid={0},ou=people")
                .groupSearchBase("ou=groups")
                .contextSource()
                .url(ldapUrl)
                .managerPassword(ldapPassword)
                .managerDn(ldapDn);
    } else if (ShepherConstants.LOGIN_TYPE_DEMO.equals(loginType.toUpperCase())) {
        auth.inMemoryAuthentication()
                .withUser(demoAdminName)
                .password(demoAdminPassword)
                .roles("USER");
    }
}
 
開發者ID:XiaoMi,項目名稱:shepher,代碼行數:18,代碼來源:WebSecurityConfig.java

示例3: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService)
                .passwordEncoder(passwordEncoder());
/*        auth.inMemoryAuthentication()
                .withUser("admin").password("yigepingguo.com").roles("ADMIN", "USER")
                .and()
                .withUser("user").password("user").roles("USER");*/
    }
 
開發者ID:helloworldtang,項目名稱:sns-todo,代碼行數:10,代碼來源:FormLoginSecurityConfig.java

示例4: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    AuthenticationProvider[] providers = primaryAuthProviders();
    for (AuthenticationProvider provider : providers) {
        auth = auth.authenticationProvider(provider);
    }

    auth.authenticationProvider(tokenProvider);
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:10,代碼來源:BaseSecurityInitializer.java

示例5: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
/**Configures the {@link #predefinedUsernames} as known users with their password equal to the user name.*/
 @Autowired
 public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
     final InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication = auth.inMemoryAuthentication();
     for(final String username: predefinedUsernames) {
     	final String role = username.equalsIgnoreCase(BANK_ROLE) ? BANK_ROLE : CLIENT_ROLE;
inMemoryAuthentication.withUser(username).password("").roles(role);
     }
 }
 
開發者ID:ChristophKnabe,項目名稱:spring-ddd-bank,代碼行數:10,代碼來源:WebSecurityConfig.java

示例6: init

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
/**
 * Initializes the {@link AuthenticationManagerBuilder}. Creates an
 * {@link InMemoryUserDetailsManager} with the provided {@link FileAuthenticationConfiguration#getUsers()}.
 * {@link FileAuthenticationConfiguration#getUsers()} must contain at least 1 user.
 *
 * @throws IllegalArgumentException if {@link FileAuthenticationConfiguration#getUsers()} is empty.
 */
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {

	Assert.notEmpty(this.users,
		String.format("No user specified. Please specify at least 1 user (e.g. via '%s')",
			CONFIGURATION_PROPERTIES_PREFIX + ".users"));

	final InMemoryUserDetailsManager inMemory = new InMemoryUserDetailsManager(getUsers());
	auth.userDetailsService(inMemory);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dashboard,代碼行數:18,代碼來源:FileAuthenticationConfiguration.java

示例7: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Override
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
    auth
        // Define our custom user details service.
        .userDetailsService(new CustomUserDetailsService(userRepository))
        .passwordEncoder(getPasswordEncoder());
}
 
開發者ID:SourceLabOrg,項目名稱:kafka-webview,代碼行數:8,代碼來源:SecurityConfig.java

示例8: configAuthentication

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
    // Authentication via JDBC, look up PostgreSQL database
    auth.jdbcAuthentication()
            .dataSource(dataSource)
            .usersByUsernameQuery("SELECT username, password, enabled FROM users WHERE username = ?")
            .authoritiesByUsernameQuery("SELECT username, role FROM user_roles WHERE username = ?");
}
 
開發者ID:ericywl,項目名稱:InfoSys-1D,代碼行數:9,代碼來源:ProfChoperSecurityConfig.java

示例9: configure

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
/**
 * Configure AuthenticationManager with inMemory credentials.
 *
 * @param auth       AuthenticationManagerBuilder
 * @throws Exception Authentication exception
 */
@Override
public void configure(final AuthenticationManagerBuilder auth) throws Exception {

    auth.inMemoryAuthentication()
            .withUser("user").password("user").roles("USER")
            .and().withUser("admin").password("admin").roles("USER", "ADMIN")
            .and().withUser("[email protected]").password("user1").roles("USER")
            .and().withUser("[email protected]").password("admin1").roles("USER", "ADMIN")
    ;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:17,代碼來源:SecurityConfig.java

示例10: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .jdbcAuthentication()
            .dataSource(dataSource)
            .passwordEncoder(passwordEncoder())
    ;// END AUTH CONFIG
}
 
開發者ID:Dawn-Team,項目名稱:dawn,代碼行數:9,代碼來源:SecurityConfig.java

示例11: configureAuthentication

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Autowired
public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
    authenticationManagerBuilder
            // 設置UserDetailsService
            .userDetailsService(this.userDetailsService)
            // 使用BCrypt進行密碼的hash
            .passwordEncoder(passwordEncoder());
}
 
開發者ID:CFshuming,項目名稱:bf-editor,代碼行數:9,代碼來源:WebSecurityConfig.java

示例12: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Autowired
public void configureGlobal(AuthenticationManagerBuilder authManagerBuilder) throws Exception {
    authManagerBuilder
            .inMemoryAuthentication()
            .withUser("user").password("password").roles("USER")
            .and().withUser("admin").password("password").roles("ADMIN", "USER");
}
 
開發者ID:chaokunyang,項目名稱:microservices-event-sourcing,代碼行數:8,代碼來源:AuthorizationServerConfig.java

示例13: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    String username = environment.getRequiredProperty("user.login");
    String password = environment.getRequiredProperty("user.password");

    auth
            .inMemoryAuthentication()
            .withUser(username).password(password).roles("ADMIN");
}
 
開發者ID:linkedin,項目名稱:custom-gradle-plugin-portal,代碼行數:10,代碼來源:WebSecurityConfig.java

示例14: configureGlobal

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
	auth
			.eraseCredentials(false)
			// Add an LDAP authentication provider instead of this to support LDAP
			.userDetailsService(userDetailsService()).and()
			// Required to allow JWT
			.authenticationProvider(jwtConfig.jwtAuthenticationProvider());
}
 
開發者ID:activeviam,項目名稱:autopivot,代碼行數:10,代碼來源:SecurityConfig.java

示例15: SecurityConfiguration

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; //導入依賴的package包/類
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,
        TokenProvider tokenProvider,
    CorsFilter corsFilter) {

    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
}
 
開發者ID:AppertaFoundation,項目名稱:Code4Health-Platform,代碼行數:10,代碼來源:SecurityConfiguration.java


注:本文中的org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。