StoredCredential toStoredCredential() { return new StoredCredential().setAccessToken(accessToken) .setRefreshToken(refreshToken).setExpirationTimeMilliseconds(expirationTimeMillis); } }
public NuxeoOAuth2Token(StoredCredential credential) { this(credential.getAccessToken(), credential.getRefreshToken(), credential.getExpirationTimeMilliseconds()); }
StoredCredential dataCredential = new StoredCredential(); dataCredential.setAccessToken(deviceToken.access_token); dataCredential.setRefreshToken(deviceToken.refresh_token); dataCredential.setExpirationTimeMilliseconds((long)deviceToken.expires_in*1000); return null; credential.setAccessToken(stored.getAccessToken()); credential.setRefreshToken(stored.getRefreshToken()); credential.setExpirationTimeMilliseconds(stored.getExpirationTimeMilliseconds());
Mockito.when(mockDataStore.get(eq("userId"))).thenReturn(new StoredCredential(credential));
credential.setAccessToken(storedCredential.getAccessToken()); credential.setRefreshToken(storedCredential.getRefreshToken()); }else{
/** * Migrates to the new {@link FileDataStoreFactory} format. * * <p> * Sample usage: * </p> * * <pre> public static FileDataStore migrate(FileCredentialStore credentialStore, File dataDirectory) throws IOException { FileDataStore dataStore = new FileDataStore(dataDirectory); credentialStore.migrateTo(dataStore); return dataStore; } * </pre> * @param dataStoreFactory file data store factory * @since 1.16 */ public final void migrateTo(FileDataStoreFactory dataStoreFactory) throws IOException { migrateTo(StoredCredential.getDefaultDataStore(dataStoreFactory)); }
/** * Migrates to the new {@link AppEngineDataStoreFactory} format. * * <p> * Sample usage: * </p> * * <pre> public static AppEngineDataStore migrate(AppEngineCredentialStore credentialStore) throws IOException { AppEngineDataStore dataStore = new AppEngineDataStore(); credentialStore.migrateTo(dataStore); return dataStore; } * </pre> * @param dataStoreFactory App Engine data store factory * @since 1.16 */ public final void migrateTo(AppEngineDataStoreFactory dataStoreFactory) throws IOException { migrateTo(StoredCredential.getDefaultDataStore(dataStoreFactory)); }
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; }
/** * 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); } } }