use of edu.uiuc.ncsa.security.oauth_2_0.OA2TokenForge in project OA4MP by ncsa.
the class RefreshTokenStoreTest method testRT.
public void testRT(TransactionStore tStore) throws Exception {
if (!(tStore instanceof RefreshTokenStore)) {
// fail here if can't cast
throw new IllegalStateException("Error: The store " + tStore.getClass().getSimpleName() + " is not of a type RefreshTokenStore");
}
RefreshTokenStore rts = (RefreshTokenStore) tStore;
OA2ServiceTransaction st2 = (OA2ServiceTransaction) tStore.create();
OA2TokenForge tf2 = new OA2TokenForge("http://localhost/test/");
RefreshToken rt = tf2.getRefreshToken();
st2.setRefreshToken(rt);
// the auth grant is used to retrieve this later and should in this case just be set to the identifier.
AuthorizationGrant ag = tf2.getAuthorizationGrant(st2.getIdentifierString());
st2.setAuthorizationGrant(ag);
st2.setRefreshTokenLifetime(EXPIRES_IN);
tStore.save(st2);
OA2ServiceTransaction testST = rts.get(rt);
assert testST.equals(st2) : "Error: created transaction is not fetched faithfully from the store";
// get another one and retry since we have to be able to show the store can handle updating the refresh token
rt = tf2.getRefreshToken();
st2.setRefreshToken(rt);
st2.setRefreshTokenValid(false);
tStore.save(st2);
assert rts.get(rt).equals(st2) : "Error: updating refresh token fails.";
}
use of edu.uiuc.ncsa.security.oauth_2_0.OA2TokenForge in project OA4MP by ncsa.
the class TokenTest2 method refreshTokenTest.
@Test
public void refreshTokenTest() throws Exception {
OA2TokenForge tf = (OA2TokenForge) getTSProvider().getTokenForge();
System.out.println("RT=" + tf.getRefreshToken());
}
Aggregations