本文整理汇总了Java中org.springframework.security.core.userdetails.User.getPassword方法的典型用法代码示例。如果您正苦于以下问题:Java User.getPassword方法的具体用法?Java User.getPassword怎么用?Java User.getPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.core.userdetails.User
的用法示例。
在下文中一共展示了User.getPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAuthentication
import org.springframework.security.core.userdetails.User; //导入方法依赖的package包/类
private OAuth2Authentication createAuthentication(String username, Set<String> scopes, Set<String> roles) {
List<GrantedAuthority> authorities = roles.stream()
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toList());
User principal = new User(username, "test", true, true, true, true, authorities);
Authentication authentication = new UsernamePasswordAuthenticationToken(principal, principal.getPassword(),
principal.getAuthorities());
// Create the authorization request and OAuth2Authentication object
OAuth2Request authRequest = new OAuth2Request(null, "testClient", null, true, scopes, null, null, null,
null);
return new OAuth2Authentication(authRequest, authentication);
}
示例2: getOneOpsUser
import org.springframework.security.core.userdetails.User; //导入方法依赖的package包/类
/**
* Helper method to create {@link OneOpsUser} for authentication principal.
*
* @param principal authentication principal
* @return oneops user.
*/
private OneOpsUser getOneOpsUser(User principal) {
log.debug("Found user details in authentication. Creating OneOps User.");
String userName = principal.getUsername();
String password = principal.getPassword();
if (password == null) {
log.debug(userName + " credentials are already erased.");
password = "";
}
return new OneOpsUser(userName, password, principal.getAuthorities(), userName, DEFAULT_DOMAIN);
}