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


Java ClientSecretPost類代碼示例

本文整理匯總了Java中com.nimbusds.oauth2.sdk.auth.ClientSecretPost的典型用法代碼示例。如果您正苦於以下問題:Java ClientSecretPost類的具體用法?Java ClientSecretPost怎麽用?Java ClientSecretPost使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClientSecretPost類屬於com.nimbusds.oauth2.sdk.auth包,在下文中一共展示了ClientSecretPost類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: authCode_postAuth_isOk

import com.nimbusds.oauth2.sdk.auth.ClientSecretPost; //導入依賴的package包/類
@Test
public void authCode_postAuth_isOk() throws Exception {
	ClientID clientId = new ClientID("test-client");
	URI redirectUri = URI.create("http://rp.example.com");
	AuthorizationCode authorizationCode = new AuthorizationCode();

	ClientSecretPost clientAuth = new ClientSecretPost(clientId, new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new AuthorizationCodeGrant(authorizationCode, redirectUri));

	AuthorizationCodeContext context = new AuthorizationCodeContext(new Subject("user"), clientId, redirectUri,
			new Scope(OIDCScopeValue.OPENID), Instant.now(), new ACR("1"), AMR.PWD, new SessionID("test"), null,
			null, null);
	BearerAccessToken accessToken = new BearerAccessToken();
	JWT idToken = new PlainJWT(new JWTClaimsSet.Builder().build());

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	given(this.authorizationCodeService.consume(eq(authorizationCode))).willReturn(context);
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);
	given(this.tokenService.createIdToken(any(IdTokenRequest.class))).willReturn(idToken);

	MockHttpServletRequestBuilder request = post("/oauth2/token").content(tokenRequest.toHTTPRequest().getQuery())
			.contentType(MediaType.APPLICATION_FORM_URLENCODED);
	this.mvc.perform(request).andExpect(status().isOk());
}
 
開發者ID:vpavic,項目名稱:simple-openid-provider,代碼行數:27,代碼來源:TokenEndpointTests.java

示例2: resourceOwnerPasswordCredentials_postAuth_isOk

import com.nimbusds.oauth2.sdk.auth.ClientSecretPost; //導入依賴的package包/類
@Test
public void resourceOwnerPasswordCredentials_postAuth_isOk() throws Exception {
	ClientSecretPost clientAuth = new ClientSecretPost(new ClientID("test-client"), new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new ResourceOwnerPasswordCredentialsGrant("user", new Secret("password")),
			new Scope(OIDCScopeValue.OPENID));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	given(this.authenticationHandler.authenticate(any(ResourceOwnerPasswordCredentialsGrant.class)))
			.willReturn(new Subject("user"));
	given(this.scopeResolver.resolve(any(Subject.class), any(Scope.class), any(OIDCClientMetadata.class)))
			.willAnswer(returnsSecondArg());
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);

	MockHttpServletRequestBuilder request = post("/oauth2/token").content(tokenRequest.toHTTPRequest().getQuery())
			.contentType(MediaType.APPLICATION_FORM_URLENCODED);
	this.mvc.perform(request).andExpect(status().isOk());
}
 
開發者ID:vpavic,項目名稱:simple-openid-provider,代碼行數:22,代碼來源:TokenEndpointTests.java

示例3: clientCredentials_postAuth_isOk

import com.nimbusds.oauth2.sdk.auth.ClientSecretPost; //導入依賴的package包/類
@Test
public void clientCredentials_postAuth_isOk() throws Exception {
	ClientSecretPost clientAuth = new ClientSecretPost(new ClientID("test-client"), new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new ClientCredentialsGrant(), new Scope("test"));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	given(this.scopeResolver.resolve(any(Subject.class), any(Scope.class), any(OIDCClientMetadata.class)))
			.willAnswer(returnsSecondArg());
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);

	MockHttpServletRequestBuilder request = post("/oauth2/token").content(tokenRequest.toHTTPRequest().getQuery())
			.contentType(MediaType.APPLICATION_FORM_URLENCODED);
	this.mvc.perform(request).andExpect(status().isOk());
}
 
開發者ID:vpavic,項目名稱:simple-openid-provider,代碼行數:19,代碼來源:TokenEndpointTests.java

示例4: refreshToken_postAuth_isOk

import com.nimbusds.oauth2.sdk.auth.ClientSecretPost; //導入依賴的package包/類
@Test
public void refreshToken_postAuth_isOk() throws Exception {
	ClientID clientId = new ClientID("test-client");

	ClientSecretPost clientAuth = new ClientSecretPost(clientId, new Secret("test-secret"));
	TokenRequest tokenRequest = new TokenRequest(URI.create("http://op.example.com"), clientAuth,
			new RefreshTokenGrant(new RefreshToken()));

	BearerAccessToken accessToken = new BearerAccessToken();

	given(this.clientRepository.findById(any(ClientID.class)))
			.willReturn(client(ClientAuthenticationMethod.CLIENT_SECRET_POST));
	given(this.tokenService.createAccessToken(any(AccessTokenRequest.class))).willReturn(accessToken);
	given(this.refreshTokenStore.load(any(RefreshToken.class))).willReturn(new RefreshTokenContext(
			new RefreshToken(), clientId, new Subject("user"), new Scope(OIDCScopeValue.OPENID), null));

	MockHttpServletRequestBuilder request = post("/oauth2/token").content(tokenRequest.toHTTPRequest().getQuery())
			.contentType(MediaType.APPLICATION_FORM_URLENCODED);
	this.mvc.perform(request).andExpect(status().isOk());
}
 
開發者ID:vpavic,項目名稱:simple-openid-provider,代碼行數:21,代碼來源:TokenEndpointTests.java


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