use of edu.uiuc.ncsa.security.delegation.token.impl.AccessTokenImpl in project OA4MP by ncsa.
the class Client2AssetStoreTest method storeTest.
@Override
public Asset storeTest(AssetStore store) throws Exception {
OA2Asset asset = (OA2Asset) super.storeTest(store);
AccessToken at = new AccessTokenImpl(URI.create("oa4mp:accessToken:/" + ClientTestStoreUtil.getRandomString()));
RefreshToken rt = new OA2RefreshTokenImpl(URI.create("oa4mp:refreshToken:/" + ClientTestStoreUtil.getRandomString()));
rt.setExpiresIn(1000000L);
asset.setAccessToken(at);
asset.setRefreshToken(rt);
store.save(asset);
OA2Asset OA2Asset = (OA2Asset) store.get(asset.getIdentifier());
assert asset.getAccessToken().equals(OA2Asset.getAccessToken()) : "Failed to match access tokens. " + "Expected \"" + asset.getAccessToken() + "\" and got \"" + OA2Asset.getAccessToken() + "\"";
RefreshToken rt2 = OA2Asset.getRefreshToken();
assert rt.getToken().equals(rt2.getToken()) : "Failed to match refresh tokens. " + "Expected \"" + rt.getToken() + "\" and got \"" + rt2.getToken() + "\"";
assert rt.getExpiresIn() == rt2.getExpiresIn() : "Failed to match refresh lifetime. " + "Expected \"" + rt.getExpiresIn() + "\" and got \"" + rt2.getExpiresIn() + "\"";
return asset;
}
use of edu.uiuc.ncsa.security.delegation.token.impl.AccessTokenImpl in project OA4MP by ncsa.
the class OA2AssetConverter method fromMap.
@Override
public Asset fromMap(ConversionMap<String, Object> map, Asset asset) {
OA2Asset a = (OA2Asset) super.fromMap(map, asset);
String rawCR = map.getString(getASK().certReq());
if (rawCR != null) {
MyPKCS10CertRequest certReq = CertUtil.fromStringToCertReq(rawCR);
a.setCertReq(certReq);
}
String at = map.getString(getASK().accessToken());
if (at != null)
a.setAccessToken(new AccessTokenImpl(URI.create(at)));
String rt = map.getString(getASK().refreshToken());
if (rt != null) {
RefreshToken refreshToken = new OA2RefreshTokenImpl(URI.create(rt));
refreshToken.setExpiresIn(map.getLong(getASK().refreshLifetime()));
a.setRefreshToken(refreshToken);
}
String state = map.getString(getASK().state());
if (state != null) {
a.setState(state);
}
a.setNonce(map.getString(getASK().nonce()));
if (map.containsKey(OA2Claims.ISSUED_AT)) {
a.setIssuedAt(map.getDate(OA2Claims.ISSUED_AT));
}
return a;
}
Aggregations