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


Java ClientDetails.getAuthorizedGrantTypes方法代碼示例

本文整理匯總了Java中org.springframework.security.oauth2.provider.ClientDetails.getAuthorizedGrantTypes方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientDetails.getAuthorizedGrantTypes方法的具體用法?Java ClientDetails.getAuthorizedGrantTypes怎麽用?Java ClientDetails.getAuthorizedGrantTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.security.oauth2.provider.ClientDetails的用法示例。


在下文中一共展示了ClientDetails.getAuthorizedGrantTypes方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: resolveRedirect

import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
public String resolveRedirect(String requestedRedirect, ClientDetails client) throws OAuth2Exception {

		Set<String> authorizedGrantTypes = client.getAuthorizedGrantTypes();
		if (authorizedGrantTypes.isEmpty()) {
			throw new InvalidGrantException("A client must have at least one authorized grant type.");
		}
		if (!containsRedirectGrantType(authorizedGrantTypes)) {
			throw new InvalidGrantException(
					"A redirect_uri can only be used by implicit or authorization_code grant types.");
		}

		Set<String> redirectUris = client.getRegisteredRedirectUri();

		if (redirectUris != null && !redirectUris.isEmpty()) {
			return obtainMatchingRedirect(redirectUris, requestedRedirect);
		}
		else if (StringUtils.hasText(requestedRedirect)) {
			return requestedRedirect;
		}
		else {
			throw new InvalidRequestException("A redirect_uri must be supplied.");
		}

	}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:25,代碼來源:DefaultRedirectResolver.java

示例4: validateGrantType

import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
protected void validateGrantType(String grantType, ClientDetails clientDetails) {
	Collection<String> authorizedGrantTypes = clientDetails.getAuthorizedGrantTypes();
	if (authorizedGrantTypes != null && !authorizedGrantTypes.isEmpty()
			&& !authorizedGrantTypes.contains(grantType)) {
		throw new InvalidClientException("Unauthorized grant type: " + grantType);
	}
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:8,代碼來源:AbstractTokenGranter.java

示例5: testClientDetailsFromNonPropertyFile

import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Test
public void testClientDetailsFromNonPropertyFile() {

	// valid client details NOT from property file
	ClientDetails clientDetails = clientDetailsService.loadClientByClientId("my-client-id-non-property-file");
	assertNotNull(clientDetailsService);
	assertEquals("my-client-id-non-property-file", clientDetails.getClientId());
	assertEquals("my-client-secret-non-property-file", clientDetails.getClientSecret());

	Set<String> grantTypes = clientDetails.getAuthorizedGrantTypes();
	assertNotNull(grantTypes);
	assertEquals(2, grantTypes.size());
	assertTrue(grantTypes.contains("password"));
	assertTrue(grantTypes.contains("authorization_code"));

	Set<String> scopes = clientDetails.getScope();
	assertNotNull(scopes);
	assertEquals(2, scopes.size());
	assertTrue(scopes.contains("scope1"));
	assertTrue(scopes.contains("scope2"));

	Collection<GrantedAuthority> authorities = clientDetails.getAuthorities();
	assertNotNull(authorities);
	assertEquals(2, authorities.size());
	assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER"));
	assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_ANONYMOUS"));
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:28,代碼來源:ClientDetailsServiceBeanDefinitionParserTests.java

示例6: testClientDetailsFromPropertyFile

import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Test
public void testClientDetailsFromPropertyFile() {

	// valid client details from property file
	ClientDetails clientDetails = clientDetailsService.loadClientByClientId("my-client-id-property-file");
	assertNotNull(clientDetailsService);
	assertEquals("my-client-id-property-file", clientDetails.getClientId());
	assertEquals("my-client-secret-property-file", clientDetails.getClientSecret());

	Set<String> grantTypes = clientDetails.getAuthorizedGrantTypes();
	assertNotNull(grantTypes);
	assertEquals(2, grantTypes.size());
	assertTrue(grantTypes.contains("password"));
	assertTrue(grantTypes.contains("authorization_code"));

	Set<String> scopes = clientDetails.getScope();
	assertNotNull(scopes);
	assertEquals(2, scopes.size());
	assertTrue(scopes.contains("scope1"));
	assertTrue(scopes.contains("scope2"));

	Collection<GrantedAuthority> authorities = clientDetails.getAuthorities();
	assertNotNull(authorities);
	assertEquals(2, authorities.size());
	assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER"));
	assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_ANONYMOUS"));
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:28,代碼來源:ClientDetailsServiceBeanDefinitionParserTests.java

示例7: testClientDetailsDefaultFlow

import org.springframework.security.oauth2.provider.ClientDetails; //導入方法依賴的package包/類
@Test
public void testClientDetailsDefaultFlow() {
	ClientDetails clientDetails = clientDetailsService.loadClientByClientId("my-client-id-default-flow");
	assertNotNull(clientDetailsService);
	assertEquals("my-client-id-default-flow", clientDetails.getClientId());
	assertEquals(1, clientDetails.getRegisteredRedirectUri().size());
	assertEquals("http://mycompany.com", clientDetails.getRegisteredRedirectUri().iterator().next());

	Set<String> grantTypes = clientDetails.getAuthorizedGrantTypes();
	assertNotNull(grantTypes);
	assertEquals(2, grantTypes.size());
	assertTrue(grantTypes.contains("authorization_code"));
	assertTrue(grantTypes.contains("refresh_token"));
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:15,代碼來源:ClientDetailsServiceBeanDefinitionParserTests.java


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