use of edu.uiuc.ncsa.security.oauth_2_0.client.DS2 in project OA4MP by ncsa.
the class OA2MPService method refresh.
/**
* This will take the identifier and make the necessary calls to the service to update the refresh
* token and access token. This returns the asset or null if no such asset exists.
*
* @param identifier
*/
public RTResponse refresh(String identifier) {
OA2Asset asset = (OA2Asset) getAssetStore().get(identifier);
if (asset == null)
return null;
DS2 ds2 = (DS2) getEnvironment().getDelegationService();
RTRequest rtRequest = new RTRequest(getEnvironment().getClient(), null);
rtRequest.setAccessToken(asset.getAccessToken());
rtRequest.setRefreshToken(asset.getRefreshToken());
RTResponse rtResponse = ds2.refresh(rtRequest);
asset.setAccessToken(rtResponse.getAccessToken());
asset.setRefreshToken(rtResponse.getRefreshToken());
// clear out
getAssetStore().remove(asset.getIdentifier());
getAssetStore().save(asset);
return rtResponse;
}
use of edu.uiuc.ncsa.security.oauth_2_0.client.DS2 in project OA4MP by ncsa.
the class OA2MPService method getUserInfo.
public UserInfo getUserInfo(String identifier) {
OA2Asset asset = getAsset2(identifier);
if (asset == null || asset.getAccessToken() == null)
return null;
UIRequest uiRequest = new UIRequest(asset.getAccessToken());
uiRequest.setClient(getEnvironment().getClient());
DS2 ds2 = (DS2) getEnvironment().getDelegationService();
UIResponse resp = ds2.getUserInfo(uiRequest);
JSONObject json = JSONObject.fromObject(resp.getRawJSON());
UserInfo ui = new UserInfo();
// return everything, even specialized fields.
ui.setMap(json);
// UserInfo ui = (UserInfo) JSONObject.toBean(json, UserInfo.class);
return ui;
}
Aggregations