本文整理汇总了Java中com.nimbusds.oauth2.sdk.auth.Secret类的典型用法代码示例。如果您正苦于以下问题:Java Secret类的具体用法?Java Secret怎么用?Java Secret使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Secret类属于com.nimbusds.oauth2.sdk.auth包,在下文中一共展示了Secret类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Override
public OIDCClientInformation create(OIDCClientMetadata metadata, boolean dynamicRegistration) {
metadata.applyDefaults();
ClientID id = new ClientID(UUID.randomUUID().toString());
Instant issueDate = Instant.now();
Secret secret = isTokenEndpointAuthEnabled(metadata) ? new Secret() : null;
URI registrationUri = dynamicRegistration
? URI.create(this.registrationUriTemplate.replace("{id}", id.getValue()))
: null;
BearerAccessToken accessToken = dynamicRegistration ? new BearerAccessToken() : null;
OIDCClientInformation client = new OIDCClientInformation(id, Date.from(issueDate), metadata, secret,
registrationUri, accessToken);
this.clientRepository.save(client);
return client;
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:18,代码来源:DefaultClientService.java
示例2: mapRow
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Override
public OIDCClientInformation mapRow(ResultSet rs, int rowNum) throws SQLException {
try {
String id = rs.getString("id");
Date issueDate = rs.getTimestamp("issue_date");
String metadata = rs.getString("metadata");
String secret = rs.getString("secret");
String registrationUri = rs.getString("registration_uri");
String accessToken = rs.getString("access_token");
return new OIDCClientInformation(new ClientID(id), issueDate,
OIDCClientMetadata.parse(JSONObjectUtils.parse(metadata)),
(secret != null) ? new Secret(secret) : null,
(registrationUri != null) ? URI.create(registrationUri) : null,
(accessToken != null) ? new BearerAccessToken(accessToken) : null);
}
catch (ParseException e) {
throw new TypeMismatchDataAccessException(e.getMessage(), e);
}
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:21,代码来源:JdbcClientRepository.java
示例3: authCode_postAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的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
示例4: resourceOwnerPasswordCredentials_basicAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void resourceOwnerPasswordCredentials_basicAuth_isOk() throws Exception {
ClientSecretBasic clientAuth = new ClientSecretBasic(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_BASIC));
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)
.header("Authorization", clientAuth.toHTTPAuthorizationHeader());
this.mvc.perform(request).andExpect(status().isOk());
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:23,代码来源:TokenEndpointTests.java
示例5: resourceOwnerPasswordCredentials_postAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的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
示例6: clientCredentials_basicAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void clientCredentials_basicAuth_isOk() throws Exception {
ClientSecretBasic clientAuth = new ClientSecretBasic(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_BASIC));
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)
.header("Authorization", clientAuth.toHTTPAuthorizationHeader());
this.mvc.perform(request).andExpect(status().isOk());
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:20,代码来源:TokenEndpointTests.java
示例7: clientCredentials_postAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的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
示例8: refreshToken_basicAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void refreshToken_basicAuth_isOk() throws Exception {
ClientID clientId = new ClientID("test-client");
ClientSecretBasic clientAuth = new ClientSecretBasic(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_BASIC));
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)
.header("Authorization", clientAuth.toHTTPAuthorizationHeader());
this.mvc.perform(request).andExpect(status().isOk());
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:22,代码来源:TokenEndpointTests.java
示例9: refreshToken_postAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的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
示例10: Authenticator
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
public Authenticator(State state) {
authC = new ClientSecretBasic(new ClientID("xxxxxxxxxxxxxx"), new Secret("xxxxxxxxxxxxxx"));
this.state = state;
try {
callback = new URI("https://csgf.egi.eu/c/portal/login");
// callback = new URI("http://burns.ct.infn.it/c/portal/login");
oauthS = new URI("https://unity.egi.eu/oauth2-as/oauth2-authz");
tokenS = new URI("https://unity.egi.eu/oauth2/token");
userS = new URI("https://unity.egi.eu/oauth2/userinfo");
tokenCertSign = new URI("https://unity.egi.eu/oauth2/jwk");
issuer = "https://unity.egi.eu/oauth2";
aud = "unity-oauth-sg";
} catch (URISyntaxException ex) {
_log.error(ex);
}
}
开发者ID:csgf,项目名称:OpenIdConnectLiferay,代码行数:17,代码来源:Authenticator.java
示例11: setUp
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void setUp(boolean idtoken, boolean userinfo) throws Exception {
matcher = new AttributeInOIDCRequestedClaimsMatcher();
final RequestContext requestCtx = new RequestContextBuilder().buildRequestContext();
prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
msgCtx = new MessageContext<AuthenticationRequest>();
prc.setInboundMessageContext(msgCtx);
//We use the same ctx for outbonud, outbound is olnly used here for fetching response context.
prc.setOutboundMessageContext(msgCtx);
OIDCAuthenticationResponseContext respCtx = new OIDCAuthenticationResponseContext();
msgCtx.addSubcontext(respCtx);
if (!idtoken && !userinfo) {
msgCtx.setMessage(new AuthenticationRequest(new URI("htts://example.org"), ResponseType.getDefault(),
new Scope("openid"), new ClientID(), new URI("htts://example.org"), new State(), new Nonce()));
} else {
msgCtx.setMessage(new AuthenticationRequest(new URI("htts://example.org"), ResponseType.getDefault(), null,
new Scope("openid"), new ClientID(), new URI("htts://example.org"), new State(), new Nonce(), null,
null, 0, null, null, null, null, null, getClaimsRequest(idtoken, userinfo), null, null, null, null));
respCtx.setRequestedClaims(getClaimsRequest(idtoken, userinfo));
}
// shortcut, may break the test
filtercontext = prc.getSubcontext(AttributeFilterContext.class, true);
ctx = new OIDCMetadataContext();
OIDCClientMetadata metadata = new OIDCClientMetadata();
OIDCClientInformation information = new OIDCClientInformation(new ClientID(), new Date(), metadata,
new Secret());
ctx.setClientInformation(information);
msgCtx.addSubcontext(ctx);
attribute = new IdPAttribute("test");
OIDCStringAttributeEncoder encoder = new OIDCStringAttributeEncoder();
encoder.setName("test");
encoders = new ArrayList<AttributeEncoder<?>>();
encoders.add(encoder);
attribute.setEncoders(encoders);
matcher.setId("componentId");
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:40,代码来源:AttributeInOIDCRequestedClaimsMatcherTest.java
示例12: setUp
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@BeforeMethod
protected void setUp() throws Exception {
sector = new URI("https://example.org/uri");
lookup = new SectorIdentifierLookupFunction();
final RequestContext requestCtx = new RequestContextBuilder().buildRequestContext();
prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
msgCtx = new MessageContext<AuthenticationRequest>();
prc.setInboundMessageContext(msgCtx);
ctx = new OIDCMetadataContext();
OIDCClientMetadata metadata= new OIDCClientMetadata();
OIDCClientInformation information = new OIDCClientInformation(new ClientID(), new Date(), metadata, new Secret() );
ctx.setClientInformation(information);
msgCtx.addSubcontext(ctx);
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:16,代码来源:SectorIdentifierLookupFunctionTest.java
示例13: setClientID
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
/**
* Sets the client ID.
* If the provider does not support dynamic client registration, set client ID and client secret with the client credentials received out-of-band.
*
* @param clientIDString the client ID string
* @param clientSecret the client secret
*/
public void setClientID(String clientIDString, String clientSecret) {
clientID = new ClientID(clientIDString);
if (this.clientSecret != null && (clientSecret == null || clientSecret.isEmpty())) {
this.clientSecret = new Secret();
} else {
this.clientSecret = new Secret(clientSecret);
}
clientInformation = new OIDCClientInformation(clientID, null, clientMetadata, this.clientSecret);
}
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:17,代码来源:SimpleOIDCClient.java
示例14: exchange
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Override
public TokenResponseAttributes exchange(
AuthorizationCodeAuthenticationToken authorizationCodeAuthenticationToken)
throws OAuth2AuthenticationException {
ClientRegistration clientRegistration = authorizationCodeAuthenticationToken.getClientRegistration();
AuthorizationCode authorizationCode = new AuthorizationCode(
authorizationCodeAuthenticationToken.getAuthorizationCode());
AuthorizationGrant authorizationCodeGrant = new AuthorizationCodeGrant(
authorizationCode, URI.create(clientRegistration.getRedirectUri()));
URI tokenUri = URI.create(clientRegistration.getProviderDetails().getTokenUri());
ClientID clientId = new ClientID(clientRegistration.getClientId());
Secret clientSecret = new Secret(clientRegistration.getClientSecret());
ClientAuthentication clientAuthentication = new ClientSecretGet(clientId, clientSecret);
try {
HTTPRequest httpRequest = createTokenRequest(
clientRegistration, authorizationCodeGrant,
tokenUri, clientAuthentication);
TokenResponse tokenResponse = TokenResponse.parse(httpRequest.send());
if (!tokenResponse.indicatesSuccess()) {
OAuth2Error errorObject = new OAuth2Error("invalid_token_response");
throw new OAuth2AuthenticationException(errorObject, "error");
}
return createTokenResponse((AccessTokenResponse) tokenResponse);
} catch (MalformedURLException e) {
throw new SerializeException(e.getMessage(), e);
} catch (ParseException pe) {
throw new OAuth2AuthenticationException(new OAuth2Error("invalid_token_response"), pe);
} catch (IOException ioe) {
throw new AuthenticationServiceException(
"An error occurred while sending the Access Token Request: " +
ioe.getMessage(), ioe);
}
}
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:43,代码来源:FacebookAuthorizationGrantTokenExchanger.java
示例15: selectClientSecrets
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Override
public List<Secret> selectClientSecrets(ClientID claimedClientID, ClientAuthenticationMethod authMethod,
Context<OIDCClientInformation> context) throws InvalidClientException {
OIDCClientInformation client = context.get();
ClientAuthenticationMethod configuredAuthMethod = client.getOIDCMetadata().getTokenEndpointAuthMethod();
if (configuredAuthMethod != null && !configuredAuthMethod.equals(authMethod)) {
throw InvalidClientException.NOT_REGISTERED_FOR_AUTH_METHOD;
}
return Collections.singletonList(client.getSecret());
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:13,代码来源:ClientRequestValidator.java
示例16: save
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Override
@Transactional
public void save(OIDCClientInformation client) {
Objects.requireNonNull(client, "client must not be null");
ClientID id = client.getID();
Date issueDate = client.getIDIssueDate();
OIDCClientMetadata metadata = client.getOIDCMetadata();
Secret secret = client.getSecret();
URI registrationUri = client.getRegistrationURI();
BearerAccessToken accessToken = client.getRegistrationAccessToken();
int updatedCount = this.jdbcOperations.update(this.statementUpdate, ps -> {
ps.setString(1, metadata.toJSONObject().toJSONString());
ps.setString(2, (secret != null) ? secret.getValue() : null);
ps.setString(3, (accessToken != null) ? accessToken.getValue() : null);
ps.setString(4, id.getValue());
});
if (updatedCount == 0) {
this.jdbcOperations.update(this.statementInsert, ps -> {
ps.setString(1, id.getValue());
ps.setTimestamp(2, Timestamp.from(issueDate.toInstant()));
ps.setString(3, metadata.toJSONObject().toJSONString());
ps.setString(4, (secret != null) ? secret.getValue() : null);
ps.setString(5, (registrationUri != null) ? registrationUri.toString() : null);
ps.setString(6, (accessToken != null) ? accessToken.getValue() : null);
});
}
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:30,代码来源:JdbcClientRepository.java
示例17: createClient
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
static OIDCClientInformation createClient() {
ClientID id = new ClientID(UUID.randomUUID().toString());
Date issueDate = new Date();
OIDCClientMetadata metadata = new OIDCClientMetadata();
Secret secret = new Secret();
URI registrationUri = URI.create("http://example.com/register/" + id);
BearerAccessToken accessToken = new BearerAccessToken();
return new OIDCClientInformation(id, issueDate, metadata, secret, registrationUri, accessToken);
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:10,代码来源:ClientTestUtils.java
示例18: client
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
private static OIDCClientInformation client(ResponseType responseType, Scope scope) {
OIDCClientMetadata clientMetadata = new OIDCClientMetadata();
clientMetadata.applyDefaults();
clientMetadata.setRedirectionURI(URI.create("http://example.com"));
clientMetadata.setScope(scope);
clientMetadata.setResponseTypes(Collections.singleton(responseType));
return new OIDCClientInformation(new ClientID("test-client"), new Date(), clientMetadata,
new Secret("test-secret"));
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:11,代码来源:AuthorizationEndpointTests.java
示例19: authCode_basicAuth_isOk
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void authCode_basicAuth_isOk() throws Exception {
ClientID clientId = new ClientID("test-client");
URI redirectUri = URI.create("http://rp.example.com");
Scope scope = new Scope(OIDCScopeValue.OPENID);
AuthorizationCode authorizationCode = new AuthorizationCode();
ClientSecretBasic clientAuth = new ClientSecretBasic(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,
scope, 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_BASIC));
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)
.header("Authorization", clientAuth.toHTTPAuthorizationHeader());
this.mvc.perform(request).andExpect(status().isOk());
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:28,代码来源:TokenEndpointTests.java
示例20: authCode_mismatchedClientId_shouldThrowException
import com.nimbusds.oauth2.sdk.auth.Secret; //导入依赖的package包/类
@Test
public void authCode_mismatchedClientId_shouldThrowException() throws Exception {
URI redirectUri = URI.create("http://rp.example.com");
Scope scope = new Scope(OIDCScopeValue.OPENID);
AuthorizationCode authorizationCode = new AuthorizationCode();
ClientSecretBasic clientAuth = new ClientSecretBasic(new ClientID("bad-client"), 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"),
new ClientID("test-client"), redirectUri, scope, 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_BASIC));
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)
.header("Authorization", clientAuth.toHTTPAuthorizationHeader());
this.mvc.perform(request).andExpect(status().isBadRequest());
}
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:28,代码来源:TokenEndpointTests.java
注:本文中的com.nimbusds.oauth2.sdk.auth.Secret类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论