本文整理匯總了Java中org.springframework.security.oauth2.provider.ClientDetails.getResourceIds方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientDetails.getResourceIds方法的具體用法?Java ClientDetails.getResourceIds怎麽用?Java ClientDetails.getResourceIds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.oauth2.provider.ClientDetails
的用法示例。
在下文中一共展示了ClientDetails.getResourceIds方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertAccessToken
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
/**
* Values placed into the map will be included in the JWT token only, not the OAuth 2 response itself.
*/
@Override
public Map<String, ?> convertAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {
Map<String, Object> map = (Map<String, Object>) super.convertAccessToken(token, authentication);
OAuth2Request request = authentication.getOAuth2Request();
Set<String> authorities = request.getAuthorities().stream().map(a -> a.getAuthority()).collect(Collectors.toSet());
ClientDetails client = clientAuthenticationService.loadClientByClientId(request.getClientId());
if (client.getResourceIds() != null && !client.getResourceIds().isEmpty()) {
map.put(AUDIENCE, client.getResourceIds());
}
Authentication userAuthentication = authentication.getUserAuthentication();
if (userAuthentication == null) {
map.remove("authorities");
}
map.put(CLIENT_AUTHORITIES, authorities);
return map;
}
示例2: addClientDetails
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Override
public void addClientDetails(final ClientDetails clientDetails) throws ClientAlreadyExistsException {
final MongoClientDetails mongoClientDetails = new MongoClientDetails(clientDetails.getClientId(),
passwordEncoder.encode(clientDetails.getClientSecret()),
clientDetails.getScope(),
clientDetails.getResourceIds(),
clientDetails.getAuthorizedGrantTypes(),
clientDetails.getRegisteredRedirectUri(),
newArrayList(clientDetails.getAuthorities()),
clientDetails.getAccessTokenValiditySeconds(),
clientDetails.getRefreshTokenValiditySeconds(),
clientDetails.getAdditionalInformation(),
null);
mongoClientDetailsRepository.save(mongoClientDetails);
}
示例3: updateClientDetails
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Override
public void updateClientDetails(ClientDetails clientDetails) throws NoSuchClientException {
final MongoClientDetails mongoClientDetails = new MongoClientDetails(clientDetails.getClientId(),
clientDetails.getClientSecret(),
clientDetails.getScope(),
clientDetails.getResourceIds(),
clientDetails.getAuthorizedGrantTypes(),
clientDetails.getRegisteredRedirectUri(),
newArrayList(clientDetails.getAuthorities()),
clientDetails.getAccessTokenValiditySeconds(),
clientDetails.getRefreshTokenValiditySeconds(),
clientDetails.getAdditionalInformation(),
getAutoApproveScopes(clientDetails));
final boolean result = mongoClientDetailsRepository.update(mongoClientDetails);
if (!result) {
throw new NoSuchClientException("No such Client Id");
}
}
示例4: oAuth2Authentication
import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
public OAuth2Authentication oAuth2Authentication(final String clientId, final String username) {
// Look up authorities, resourceIds and scopes based on clientId
ClientDetails client = clientDetailsService.loadClientByClientId(clientId);
Collection<GrantedAuthority> authorities = client.getAuthorities();
Set<String> resourceIds = client.getResourceIds();
Set<String> scopes = client.getScope();
// Default values for other parameters
Map<String, String> requestParameters = Collections.emptyMap();
boolean approved = true;
String redirectUrl = null;
Set<String> responseTypes = Collections.emptySet();
Map<String, Serializable> extensionProperties = Collections.emptyMap();
// Create request
OAuth2Request oAuth2Request = new OAuth2Request(requestParameters, clientId, authorities, approved, scopes, resourceIds, redirectUrl, responseTypes, extensionProperties);
// Create OAuth2AccessToken
UserDetails user = userDetailsService.loadUserByUsername(username);
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user, null, authorities);
OAuth2Authentication auth = new OAuth2Authentication(oAuth2Request, authenticationToken);
return auth;
}