本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}