Java Code Examples for org.springframework.boot.autoconfigure.security.oauth2.resource.PrincipalExtractor

The following examples show how to use org.springframework.boot.autoconfigure.security.oauth2.resource.PrincipalExtractor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-boot-samples   Source File: SecurityConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public PrincipalExtractor principalExtractor(GithubClient githubClient, UserRepository userRepository) {
	return map -> {
		String githubLogin = (String) map.get("login");
		User speaker = userRepository.findByGithub(githubLogin);
		if (speaker == null) {
			logger.info("Initialize user with githubId {}", githubLogin);
			GithubUser user = githubClient.getUser(githubLogin);
			speaker = new User();
			speaker.setEmail(user.getEmail());
			speaker.setName(user.getName());
			speaker.setGithub(githubLogin);
			speaker.setAvatarUrl(user.getAvatar());
			userRepository.save(speaker);
		}
		return speaker;
	};
}
 
Example 2
@Bean
public PrincipalExtractor principalExtractor() {
    return new SimplePrincipalExtractor(OAUTH2_PRINCIPAL_ATTRIBUTE);
}
 
Example 3
@Bean
public PrincipalExtractor principalExtractor() {
    return new SimplePrincipalExtractor(OAUTH2_PRINCIPAL_ATTRIBUTE);
}
 
Example 4
@Bean
public PrincipalExtractor principalExtractor() {
    return new SimplePrincipalExtractor(OAUTH2_PRINCIPAL_ATTRIBUTE);
}
 
Example 5
@Bean
public PrincipalExtractor principalExtractor() {
    return new SimplePrincipalExtractor(OAUTH2_PRINCIPAL_ATTRIBUTE);
}
 
Example 6
public void setPrincipalExtractor(PrincipalExtractor principalExtractor) {
    Assert.notNull(principalExtractor, "PrincipalExtractor must not be null");
    this.principalExtractor = principalExtractor;
}
 
Example 7
Source Project: onetwo   Source File: OAuth2SsoClientAutoContextConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public PrincipalExtractor userDetailPrincipalExtractor(){
	return new UserDetailPrincipalExtractor();
}
 
Example 8
Source Project: tutorials   Source File: SecurityConfig.java    License: MIT License 4 votes vote down vote up
@Bean
@Profile("oauth2-extractors-baeldung")
public PrincipalExtractor baeldungPrincipalExtractor() {
    return new BaeldungPrincipalExtractor();
}
 
Example 9
Source Project: tutorials   Source File: SecurityConfig.java    License: MIT License 4 votes vote down vote up
@Bean
@Profile("oauth2-extractors-github")
public PrincipalExtractor githubPrincipalExtractor() {
    return new GithubPrincipalExtractor();
}
 
Example 10
Source Project: springcloud-oauth2   Source File: ResourceServerConfig.java    License: MIT License 2 votes vote down vote up
/**
 * 自定义Principal提取器,返回的Principal是一个map
 *
 * @return
 */
@Bean
public PrincipalExtractor principalExtractor() {
    return new CustomizePrincipalExtractor();
}