當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientDetails.getResourceIds方法代碼示例

本文整理匯總了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;
}
 
開發者ID:PatternFM,項目名稱:tokamak,代碼行數:25,代碼來源:JWTTokenConverter.java

示例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);
}
 
開發者ID:cloudade,項目名稱:authorization-server-with-mongodb,代碼行數:17,代碼來源:MongoClientDetailsService.java

示例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");
	}
}
 
開發者ID:cloudade,項目名稱:authorization-server-with-mongodb,代碼行數:20,代碼來源:MongoClientDetailsService.java

示例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;
}
 
開發者ID:timtebeek,項目名稱:resource-server-testing,代碼行數:24,代碼來源:OAuthHelper.java


注:本文中的org.springframework.security.oauth2.provider.ClientDetails.getResourceIds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。