通过LDAP或者DB进行认证的灵活配置
TODO待完善
Interface IPasswordAuth(){
User getUser();
}
Class DBAuthService() implements IPasswordAuth{
@Autowired
DatabaseResource db;
@Override
public User getUser(DatabaseResource db){
//通过DB认证
}
}
Class LDAPAuthService() implements IPasswordAuth{
@Autowired
LdapTemplete temp;
@Override
public User getUser(LdapTemplete temp){
//通过Ldap认证
}
}
@Configuration
Class AuthConfig(){
@Bean
@ConditionalOnProperty(value = "spring.auth.type", havingValue = "LDAP")
public LdapTemplete temp(){
return new LdapTemplete;
}
@Bean
@ConditionalOnProperty(value = "spring.auth.type", havingValue = "LDAP")
public LdapAuthService LdapAuthService(){
return new LdapAuthService;
}
@Bean
@ConditionalOnProperty(value = "spring.auth.type", havingValue = "DB")
public DatabaseResource db(){
return new DatabaseResource;
}
@Bean
@ConditionalOnProperty(value = "spring.auth.type", havingValue = "DB")
public DbAuthService dbAuthService(){
return new DbAuthService;
}
}