Search in sources :

Example 1 with OA2RefreshTokenImpl

use of edu.uiuc.ncsa.security.oauth_2_0.OA2RefreshTokenImpl 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;
}
Also used : RefreshToken(edu.uiuc.ncsa.security.delegation.token.RefreshToken) AccessToken(edu.uiuc.ncsa.security.delegation.token.AccessToken) AccessTokenImpl(edu.uiuc.ncsa.security.delegation.token.impl.AccessTokenImpl) OA2RefreshTokenImpl(edu.uiuc.ncsa.security.oauth_2_0.OA2RefreshTokenImpl)

Example 2 with OA2RefreshTokenImpl

use of edu.uiuc.ncsa.security.oauth_2_0.OA2RefreshTokenImpl 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;
}
Also used : RefreshToken(edu.uiuc.ncsa.security.delegation.token.RefreshToken) AccessTokenImpl(edu.uiuc.ncsa.security.delegation.token.impl.AccessTokenImpl) MyPKCS10CertRequest(edu.uiuc.ncsa.security.util.pkcs.MyPKCS10CertRequest) OA2RefreshTokenImpl(edu.uiuc.ncsa.security.oauth_2_0.OA2RefreshTokenImpl)

Aggregations

RefreshToken (edu.uiuc.ncsa.security.delegation.token.RefreshToken)2 AccessTokenImpl (edu.uiuc.ncsa.security.delegation.token.impl.AccessTokenImpl)2 OA2RefreshTokenImpl (edu.uiuc.ncsa.security.oauth_2_0.OA2RefreshTokenImpl)2 AccessToken (edu.uiuc.ncsa.security.delegation.token.AccessToken)1 MyPKCS10CertRequest (edu.uiuc.ncsa.security.util.pkcs.MyPKCS10CertRequest)1