use of org.gluu.oxauth.model.uma.wrapper.Token in project oxAuth by GluuFederation.
the class IntrospectionWsHttpTest method introspectWithValidAuthorizationButInvalidTokenShouldReturnActiveFalse.
@Test
@Parameters({ "umaPatClientId", "umaPatClientSecret" })
public void introspectWithValidAuthorizationButInvalidTokenShouldReturnActiveFalse(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final Token authorization = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret, clientEngine(true));
final IntrospectionService introspectionService = ClientFactory.instance().createIntrospectionService(introspectionEndpoint, clientEngine(true));
final IntrospectionResponse introspectionResponse = introspectionService.introspectToken("Bearer " + authorization.getAccessToken(), "invalid_token");
assertNotNull(introspectionResponse);
assertFalse(introspectionResponse.isActive());
}
use of org.gluu.oxauth.model.uma.wrapper.Token in project oxAuth by GluuFederation.
the class StatWSTest method statPost.
@Test(enabled = false)
@Parameters({ "umaPatClientId", "umaPatClientSecret" })
public void statPost(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final Token authorization = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret);
final StatService service = ClientFactory.instance().createStatService(issuer + "/oxauth/restv1/internal/stat");
final JsonNode node = service.statPost(authorization.getAccessToken(), "202101", null);
assertTrue(node != null && node.hasNonNull("response"));
}
use of org.gluu.oxauth.model.uma.wrapper.Token in project oxAuth by GluuFederation.
the class StatWSTest method stat.
@Test(enabled = false)
@Parameters({ "umaPatClientId", "umaPatClientSecret" })
public void stat(final String umaPatClientId, final String umaPatClientSecret) throws Exception {
final Token authorization = UmaClient.requestPat(tokenEndpoint, umaPatClientId, umaPatClientSecret);
final StatService service = ClientFactory.instance().createStatService(issuer + "/oxauth/restv1/internal/stat");
final JsonNode node = service.stat("Bearer " + authorization.getAccessToken(), "202101", null);
assertTrue(node != null && node.hasNonNull("response"));
}
use of org.gluu.oxauth.model.uma.wrapper.Token in project oxAuth by GluuFederation.
the class TTokenRequest method newTokenByRefreshToken.
public Token newTokenByRefreshToken(final String tokenPath, final Token p_oldToken, final String umaClientId, final String umaClientSecret) {
if (p_oldToken == null || StringUtils.isBlank(p_oldToken.getRefreshToken()) || StringUtils.isBlank(tokenPath)) {
throw new IllegalArgumentException("Refresh token or tokenPath is empty.");
}
final Holder<Token> t = new Holder<Token>();
try {
TokenRequest tokenRequest = new TokenRequest(GrantType.REFRESH_TOKEN);
tokenRequest.setAuthUsername(umaClientId);
tokenRequest.setAuthPassword(umaClientSecret);
tokenRequest.setRefreshToken(p_oldToken.getRefreshToken());
tokenRequest.setScope(p_oldToken.getScope());
Builder request = ResteasyClientBuilder.newClient().target(baseUri.toString() + tokenPath).request();
request.header("Authorization", "Basic " + tokenRequest.getEncodedCredentials());
Response response = request.post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters())));
String entity = response.readEntity(String.class);
BaseTest.showResponse("TTokenClient.requestToken() :", response, entity);
assertEquals(response.getStatus(), 200, "Unexpected response code.");
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("access_token"), "Unexpected result: access_token not found");
assertTrue(jsonObj.has("token_type"), "Unexpected result: token_type not found");
assertTrue(jsonObj.has("refresh_token"), "Unexpected result: refresh_token not found");
// assertTrue(jsonObj.has("id_token"), "Unexpected result:
// id_token not found");
String accessToken = jsonObj.getString("access_token");
String refreshToken = jsonObj.getString("refresh_token");
// String idToken = jsonObj.getString("id_token");
final Token newToken = new Token();
newToken.setAccessToken(accessToken);
newToken.setRefreshToken(refreshToken);
t.setT(newToken);
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
return t.getT();
}
use of org.gluu.oxauth.model.uma.wrapper.Token in project oxAuth by GluuFederation.
the class ObtainPatWSTest method requestNewPatByRefreshTokne.
@Test(dependsOnMethods = "requestPat")
@Parameters({ "tokenPath", "umaPatClientId", "umaPatClientSecret" })
public void requestNewPatByRefreshTokne(String tokenPath, String umaPatClientId, String umaPatClientSecret) {
final Token newPat = TUma.newTokenByRefreshToken(url, tokenPath, pat, umaPatClientId, umaPatClientSecret);
UmaTestUtil.assert_(newPat);
}
Aggregations