@Test public void testValidRequest() throws Exception { Reference reference = new Reference("riap: Request request = new Request(Method.POST, reference); Response response = new Response(request); CoreToken refreshToken = realm.getTokenStore().createRefreshToken(OAuth2Utils.split("read write", null), "test", "admin", "cid", null, OAuth2Constants.Params.REFRESH_TOKEN); Form parameters = new Form(); parameters.add(OAuth2Constants.Params.GRANT_TYPE, OAuth2Constants.Params.REFRESH_TOKEN); parameters.add(OAuth2Constants.Params.REFRESH_TOKEN, refreshToken.getTokenID()); parameters.add(OAuth2Constants.Params.SCOPE, OAuth2Utils.join(refreshToken.getScope(), "")); parameters.add(OAuth2Constants.Params.STATE, "random"); request.setEntity(parameters.getWebRepresentation()); getClient().handle(request, response); assertTrue(MediaType.APPLICATION_JSON.equals(response.getEntity().getMediaType())); JacksonRepresentation<Map> representation = new JacksonRepresentation<Map>(response.getEntity(), Map.class); assertThat(representation.getObject()).includes( MapAssert.entry(OAuth2Constants.Params.TOKEN_TYPE, OAuth2Constants.Bearer.BEARER), MapAssert.entry(OAuth2Constants.Params.EXPIRES_IN, 3600)).is(new Condition<Map<?, ?>>() { @Override public boolean matches(Map<?, ?> value) { return value.containsKey(OAuth2Constants.Params.ACCESS_TOKEN) && value.containsKey(OAuth2Constants.Params.REFRESH_TOKEN); } }); }
private CoreToken createRefreshToken(CoreToken refreshToken) { return getTokenStore().createRefreshToken(refreshToken.getScope(), OAuth2Utils.getRealm(getRequest()), refreshToken.getUserID(), refreshToken.getClientID(), refreshToken.getRedirectURI(), refreshToken.getGrantType()); }
RefreshTokenServerResource extends AbstractFlow { private CoreToken createRefreshToken(CoreToken refreshToken) { return getTokenStore().createRefreshToken(refreshToken.getScope(), OAuth2Utils.getRealm(getRequest()), refreshToken.getUserID(), refreshToken.getClientID(), refreshToken.getRedirectURI(), refreshToken.getGrantType()); } }
RefreshTokenServerResource extends AbstractFlow { private CoreToken createRefreshToken(CoreToken refreshToken) { return getTokenStore().createRefreshToken(refreshToken.getScope(), OAuth2Utils.getRealm(getRequest()), refreshToken.getUserID(), refreshToken.getClientID(), refreshToken.getRedirectURI(), refreshToken.getGrantType()); }  }
RefreshTokenServerResource extends AbstractFlow { private CoreToken createRefreshToken(CoreToken refreshToken) { return getTokenStore().createRefreshToken(refreshToken.getScope(), OAuth2Utils.getRealm(getRequest()), refreshToken.getUserID(), refreshToken.getClientID(), refreshToken.getRedirectURI(), refreshToken.getGrantType()); }  @Post("form:json") Representation represent(Representation entity); }
RefreshTokenServerResource extends AbstractFlow { private CoreToken createRefreshToken(CoreToken refreshToken) { return getTokenStore().createRefreshToken(refreshToken.getScope(), OAuth2Utils.getRealm(getRequest()), refreshToken.getUserID(), refreshToken.getClientID(), refreshToken.getRedirectURI(), refreshToken.getGrantType()); }  @Post("form:json") Representation represent(Representation entity);  }