private void requestAccessTokenPassword(final String userId, final String userSecret, String clientId, String clientSecret) throws Exception { // Request Resource Owner Credentials Grant String scope = "openid"; TokenClient tokenClient = new TokenClient(tokenEndpoint); TokenResponse response1 = tokenClient.execResourceOwnerPasswordCredentialsGrant(userId, userSecret, scope, clientId, clientSecret); assertEquals(response1.getStatus(), 200, "Unexpected response code: " + response1.getStatus()); assertNotNull(response1.getEntity(), "The entity is null"); assertNotNull(response1.getAccessToken(), "The access token is null"); assertNotNull(response1.getTokenType(), "The token type is null"); assertNotNull(response1.getRefreshToken(), "The refresh token is null"); assertNotNull(response1.getScope(), "The scope is null"); assertNotNull(response1.getIdToken(), "The id token is null"); }
public static Token request(final String tokenUrl, final TokenRequest tokenRequest) throws Exception { if (tokenRequest.getGrantType() != GrantType.CLIENT_CREDENTIALS) { return null; } TokenClient tokenClient = new TokenClient(tokenUrl); tokenClient.setRequest(tokenRequest); TokenResponse response = tokenClient.exec(); if (response.getStatus() == 200) { final String patToken = response.getAccessToken(); final Integer expiresIn = response.getExpiresIn(); if (Util.allNotBlank(patToken)) { return new Token(null, null, patToken, response.getScope(), expiresIn); } } return null; }
/** * Test for the obtaining UMA PAT token using refresh token */ //@Test(dependsOnMethods = {"testObtainPatTokenFlow"}) @Parameters({"umaPatClientId", "umaPatClientSecret"}) public void testObtainPatTokenUsingRefreshTokenFlow(final String umaPatClientId, final String umaPatClientSecret) throws Exception { showTitle("testObtainPatTokenUsingRefreshTokenFlow"); // Request new access token using the refresh token. TokenClient tokenClient1 = new TokenClient(tokenEndpoint); TokenResponse response1 = tokenClient1.execRefreshToken(m_pat.getScope(), m_pat.getRefreshToken(), umaPatClientId, umaPatClientSecret); showClient(tokenClient1); assertEquals(response1.getStatus(), 200, "Unexpected response code: " + response1.getStatus()); assertNotNull(response1.getEntity(), "The entity is null"); assertNotNull(response1.getAccessToken(), "The access token is null"); assertNotNull(response1.getTokenType(), "The token type is null"); assertNotNull(response1.getRefreshToken(), "The refresh token is null"); assertNotNull(response1.getScope(), "The scope is null"); } }
assertNotNull(response1.getTokenType(), "The token type is null"); assertNotNull(response1.getRefreshToken(), "The refresh token is null"); assertNotNull(response1.getScope(), "The scope is null");
assertNotNull(response1.getTokenType(), "The token type is null"); assertNotNull(response1.getRefreshToken(), "The refresh token is null"); assertNotNull(response1.getScope(), "The scope is null");
assertNotNull(response1.getTokenType(), "The token type is null"); assertNotNull(response1.getRefreshToken(), "The refresh token is null"); assertNotNull(response1.getScope(), "The scope is null");
assertNotNull(response.getAccessToken(), "The access token is null"); assertNotNull(response.getTokenType(), "The token type is null"); assertNotNull(response.getScope(), "The scope is null");
assertNotNull(response1.getTokenType(), "The token type is null"); assertNotNull(response1.getRefreshToken(), "The refresh token is null"); assertNotNull(response1.getScope(), "The scope is null");
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());
assertNotNull(tokenResponse.getTokenType(), "The token type is null"); assertNotNull(tokenResponse.getRefreshToken(), "The refresh token is null"); assertNotNull(tokenResponse.getScope(), "The scope is null"); assertNotNull(tokenResponse.getIdToken(), "The id token is null");
assertNotNull(tokenResponse.getTokenType(), "The token type is null"); assertNotNull(tokenResponse.getRefreshToken(), "The refresh token is null"); assertNotNull(tokenResponse.getScope(), "The scope is null"); assertNotNull(tokenResponse.getIdToken(), "The id token is null");
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());
assertNotNull(tokenResponse.getTokenType(), "The token type is null"); assertNotNull(tokenResponse.getRefreshToken(), "The refresh token is null"); assertNotNull(tokenResponse.getScope(), "The scope is null"); assertNotNull(tokenResponse.getIdToken(), "The id token is null");
assertNotNull(tokenResponse.getTokenType(), "The token type is null"); assertNotNull(tokenResponse.getRefreshToken(), "The refresh token is null"); assertNotNull(tokenResponse.getScope(), "The scope is null"); assertNotNull(tokenResponse.getIdToken(), "The id token is null");
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());
assertNotNull(tokenResponse.getAccessToken()); assertNotNull(tokenResponse.getTokenType()); assertNotNull(tokenResponse.getScope()); assertNull(tokenResponse.getRefreshToken());