StoredCredential toStoredCredential() { return new StoredCredential().setAccessToken(accessToken) .setRefreshToken(refreshToken).setExpirationTimeMilliseconds(expirationTimeMillis); } }
public static StoredCredential asCredential(DocumentModel entry) { StoredCredential credential = new StoredCredential(); String accessToken = (String) entry.getProperty(SCHEMA, "accessToken"); String refreshToken = (String) entry.getProperty(SCHEMA, "refreshToken"); Long expirationTimeMilliseconds = (Long) entry.getProperty(SCHEMA, "expirationTimeMilliseconds"); credential.setAccessToken(accessToken); credential.setRefreshToken(refreshToken); credential.setExpirationTimeMilliseconds(expirationTimeMilliseconds); return credential; }
StoredCredential dataCredential = new StoredCredential(); dataCredential.setAccessToken(deviceToken.access_token); dataCredential.setRefreshToken(deviceToken.refresh_token);
/** * Migrates to the new format using {@link DataStore} of {@link StoredCredential}. * * @param credentialDataStore credential data store * @since 1.16 */ public final void migrateTo(DataStore<StoredCredential> credentialDataStore) throws IOException { DatastoreService service = DatastoreServiceFactory.getDatastoreService(); PreparedQuery queryResult = service.prepare(new Query(KIND)); for (Entity entity : queryResult.asIterable()) { StoredCredential storedCredential = new StoredCredential().setAccessToken( (String) entity.getProperty("accessToken")) .setRefreshToken((String) entity.getProperty("refreshToken")) .setExpirationTimeMilliseconds((Long) entity.getProperty("expirationTimeMillis")); credentialDataStore.set(entity.getKey().getName(), storedCredential); } } }
Mockito.when(mockDataStore.get(eq("userId"))).thenReturn(new StoredCredential(credential));