本文整理汇总了Java中org.springframework.security.provisioning.InMemoryUserDetailsManager类的典型用法代码示例。如果您正苦于以下问题:Java InMemoryUserDetailsManager类的具体用法?Java InMemoryUserDetailsManager怎么用?Java InMemoryUserDetailsManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InMemoryUserDetailsManager类属于org.springframework.security.provisioning包,在下文中一共展示了InMemoryUserDetailsManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OAuthConfig
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
public OAuthConfig() throws Exception {
ClientDetailsService csvc = new InMemoryClientDetailsServiceBuilder()
.withClient("mobile").authorizedGrantTypes("password")
.authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
.scopes("read","write").resourceIds("prublisher")
.accessTokenValiditySeconds(3600).and().build();
UserDetailsService svc = new InMemoryUserDetailsManager(
Arrays.asList(
User.create("publisher", "publisher", MobileClient.ROLE_PUBLISHER),
User.create("subscriber", "subscriber", MobileClient.ROLE_SUBSCRIBER)));
combinedService_ = new ClientAndUserDetailsService(csvc,svc);
}
示例2: setUp
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Set<UserDetails> users = new HashSet<>();
user = new User(KNOWN_USERNAME, "password", Arrays.asList(new SimpleGrantedAuthority("user")));
users.add(user);
userDetailsService = new InMemoryUserDetailsManager(Collections.unmodifiableCollection(users));
provider = new KeycloakUserDetailsAuthenticationProvider();
provider.setUserDetailsService(userDetailsService);
when(principal.getName()).thenReturn(KNOWN_USERNAME);
when(account.getPrincipal()).thenReturn(principal);
token = new KeycloakAuthenticationToken(account);
}
开发者ID:Smartling,项目名称:smartling-keycloak-extras,代码行数:19,代码来源:KeycloakUserDetailsAuthenticationProviderTest.java
示例3: propertyUserDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Bean
public InMemoryUserDetailsManager propertyUserDetailsService() throws IOException {
String env = System.getenv(ENVIRONMENT);
if (env == null) {
env = System.getProperty(ENVIRONMENT, "dev");
}
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocations(new ClassPathResource("usercredentials-" + env + ".properties"));
propertiesFactoryBean.afterPropertiesSet();
Properties users = propertiesFactoryBean.getObject();
return new InMemoryUserDetailsManager(users);
}
示例4: userDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User
.withUsername("user")
.password("password")
.roles("USER").build());
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:9,代码来源:LearningSpringBootConfigServer.java
示例5: userDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Bean
UserDetailsService userDetailsService() throws Exception {
UserDetails user = User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:10,代码来源:SampleSecureOAuth2ActuatorApplication.java
示例6: userDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Bean
UserDetailsService userDetailsService() {
UserDetails greg = User.withDefaultPasswordEncoder()
.username("greg")
.password("turnquist")
.roles("read")
.build();
return new InMemoryUserDetailsManager(greg);
}
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:10,代码来源:AuthenticationConfiguration.java
示例7: userDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Override
@Bean
public UserDetailsService userDetailsService() {
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(User.withUsername(adminUsername).password(adminPassword).roles("ADMIN").build());
return manager;
}
示例8: inMemoryUserService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Bean
public UserDetailsService inMemoryUserService() {
return new InMemoryUserDetailsManager(Arrays.asList(
new User(securityProperties.getUser().getName(),
securityProperties.getUser().getPassword(),
securityProperties.getUser().getRole().stream()
.map(role -> new SimpleGrantedAuthority("ROLE_" + role))
.collect(Collectors.toList()))));
}
示例9: init
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的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);
}
示例10: userDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
/**
* The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService())
* originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager}
* UserDetailsManager vs UserDetailsService
*/
@Bean
@Override
public UserDetailsManager userDetailsService() {
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(User.withUsername("[email protected]").password("user1").roles("USER").build());
manager.createUser(User.withUsername("[email protected]").password("admin1").roles("USER", "ADMIN").build());
return manager;
}
示例11: userDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
/**
* The parent method from {@link WebSecurityConfigurerAdapter} (public UserDetailsService userDetailsService())
* originally returns a {@link UserDetailsService}, but this needs to be a {@link UserDetailsManager}
* UserDetailsManager vs UserDetailsService
*/
@Bean
@Override
public UserDetailsManager userDetailsService() {
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(User.withUsername("user").password("password").roles("USER").build());
manager.createUser(User.withUsername("admin").password("admin").roles("USER", "ADMIN").build());
manager.createUser(User.withUsername("[email protected]").password("user1").roles("USER").build());
manager.createUser(User.withUsername("[email protected]").password("admin1").roles("USER", "ADMIN").build());
return manager;
}
示例12: userDetailsService
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Bean
public UserDetailsService userDetailsService() throws Exception {
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
manager.createUser(User
.withUsername("user")
.password("userPass")
.roles("USER").build());
manager.createUser(User
.withUsername("admin")
.password("adminPass")
.roles("ADMIN").build());
return manager;
}
示例13: inMemoryUserDetailsManager
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
@Bean
public InMemoryUserDetailsManager inMemoryUserDetailsManager() {
final Properties users = new Properties();
String adminPassword = passwordEncoder().encode("admin");
users.put("admin", adminPassword + ",ROLE_ADMIN,enabled");
users.put("[email protected]", "password,ROLE_USER,enabled"); //add whatever other user you need
return new InMemoryUserDetailsManager(users);
}
示例14: inMemProvider
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
public
@Bean
AuthenticationProvider inMemProvider() {
DaoAuthenticationProvider dap = new DaoAuthenticationProvider();
dap.setPasswordEncoder(new BCryptPasswordEncoder());
dap.setUserDetailsService(new InMemoryUserDetailsManager(Collections.singletonList(new User("user", "test", Collections.singletonList(new SimpleGrantedAuthority("API_CLIENT"))))));
return dap;
}
示例15: inMemProvider
import org.springframework.security.provisioning.InMemoryUserDetailsManager; //导入依赖的package包/类
public
@Bean
AuthenticationProvider inMemProvider() {
DaoAuthenticationProvider dap = new DaoAuthenticationProvider();
//dap.setPasswordEncoder(new BCryptPasswordEncoder());
dap.setUserDetailsService(new InMemoryUserDetailsManager(Collections.singletonList(new User("user", "test", Collections.singletonList(new SimpleGrantedAuthority("API_CLIENT"))))));
return dap;
}