use of com.nimbusds.oauth2.sdk.JWTBearerGrant in project product-is by wso2.
the class OAuth2ServiceJWTGrantTestCase method testAccessTokenRevokeFlow.
@Test(description = "This test case tests access token revocation flow of JWTBearerGrant.", dependsOnMethods = "testRefreshTokenFlow")
public void testAccessTokenRevokeFlow() throws Exception {
OIDCTokens firstTokenSet = makeJWTBearerGrantRequest();
AccessToken firstAccessToken = firstTokenSet.getAccessToken();
makeTokenRevokeRequest(firstAccessToken);
OIDCTokens secondTokenSet = makeJWTBearerGrantRequest();
AccessToken secondAccessToken = secondTokenSet.getAccessToken();
Assert.assertFalse(firstAccessToken.toJSONString().equals(secondAccessToken.toJSONString()), "Same access " + "token is returned even after the access token issued from JWT Bearer grant has been revoked. ");
}
use of com.nimbusds.oauth2.sdk.JWTBearerGrant in project product-is by wso2.
the class OAuth2ServiceJWTGrantTestCase method testRefreshTokenRevokeFlow.
@Test(description = "This test case tests refresh token revocation flow of JWTBearerGrant.", dependsOnMethods = "testAccessTokenRevokeFlow")
public void testRefreshTokenRevokeFlow() throws Exception {
OIDCTokens firstTokenSet = makeJWTBearerGrantRequest();
RefreshToken firstRefreshToken = firstTokenSet.getRefreshToken();
makeTokenRevokeRequest(firstRefreshToken);
OIDCTokens secondTokenSet = makeJWTBearerGrantRequest();
RefreshToken refreshToken = secondTokenSet.getRefreshToken();
Assert.assertFalse(firstRefreshToken.toJSONString().equals(refreshToken.toJSONString()), "Same refresh " + "token is returned even after the refresh token issued from JWT Bearer grant has been revoked ");
}
use of com.nimbusds.oauth2.sdk.JWTBearerGrant in project product-is by wso2.
the class OAuth2ServiceJWTGrantTestCase method testRefreshTokenFlow.
@Test(description = "This test case tests refresh token flow of JWTBearerGrant.", dependsOnMethods = "testJWTGrantTypeWithConvertOIDCDialectWithIDPMappingWithSPMappingWithAddRemainingUserAttributes")
public void testRefreshTokenFlow() throws Exception {
AuthorizationGrant refreshGrant = new RefreshTokenGrant(new RefreshToken(refreshToken));
OIDCTokens oidcTokens = makeTokenRequest(refreshGrant);
Assert.assertEquals(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(COUNTRY_NEW_OIDC_CLAIM), COUNTRY_CLAIM_VALUE, "User claims are not mapped correctly when AddRemainingUserAttributes and " + "ConvertToOIDCDialect is set to true in identity.xml");
Assert.assertEquals(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(EMAIL_OIDC_CLAIM), EMAIL_CLAIM_VALUE, "User claims are not mapped correctly when AddRemainingUserAttributes and " + "ConvertToOIDCDialect is set to true in identity.xml");
Assert.assertNull(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(COUNTRY_LOCAL_CLAIM_URI), "User claims conversion happened wrongly.");
Assert.assertNull(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(COUNTRY_OIDC_CLAIM), "Duplicated claims while adding missing attributes.");
}
use of com.nimbusds.oauth2.sdk.JWTBearerGrant in project product-is by wso2.
the class OAuth2ServiceJWTGrantTestCase method makeJWTBearerGrantRequest.
/**
* To make the JWT Bearer Grant request.
*
* @return OIDC Tokens.
* @throws java.text.ParseException Parse Exception.
* @throws URISyntaxException URI Syntax Exception.
* @throws IOException IO Exception.
* @throws ParseException Parse Exception.
*/
private OIDCTokens makeJWTBearerGrantRequest() throws java.text.ParseException, URISyntaxException, IOException, ParseException {
SignedJWT signedJWT = SignedJWT.parse(jwtAssertion);
AuthorizationGrant jwtGrant = new JWTBearerGrant(signedJWT);
return makeTokenRequest(jwtGrant);
}
use of com.nimbusds.oauth2.sdk.JWTBearerGrant in project microsoft-authentication-library-for-java by AzureAD.
the class OnBehalfOfRequest method createAuthenticationGrant.
private static OAuthAuthorizationGrant createAuthenticationGrant(OnBehalfOfParameters parameters) {
AuthorizationGrant jWTBearerGrant;
try {
jWTBearerGrant = new JWTBearerGrant(SignedJWT.parse(parameters.userAssertion().getAssertion()));
} catch (Exception e) {
throw new MsalClientException(e);
}
Map<String, List<String>> params = new HashMap<>();
params.put("requested_token_use", Collections.singletonList("on_behalf_of"));
if (parameters.claims() != null) {
params.put("claims", Collections.singletonList(parameters.claims().formatAsJSONString()));
}
return new OAuthAuthorizationGrant(jWTBearerGrant, String.join(SCOPES_DELIMITER, parameters.scopes()), params);
}
Aggregations