@Override public GoogleCredential setExpirationTimeMilliseconds(Long expirationTimeMilliseconds) { return (GoogleCredential) super.setExpirationTimeMilliseconds(expirationTimeMilliseconds); }
/** * @param credential credential whose {@link Credential#setAccessToken access token}, * {@link Credential#setRefreshToken refresh token}, and * {@link Credential#setExpirationTimeMilliseconds expiration time} need to be set if the * credential already exists in storage */ void load(Credential credential) { credential.setAccessToken(accessToken); credential.setRefreshToken(refreshToken); credential.setExpirationTimeMilliseconds(expirationTimeMillis); }
/** * Load information into the credential. * * @param credential credential whose {@link Credential#setAccessToken access token}, * {@link Credential#setRefreshToken refresh token}, and * {@link Credential#setExpirationTimeMilliseconds expiration time} need to be set if the * credential already exists in storage */ void load(Credential credential) { credential.setAccessToken(accessToken); credential.setRefreshToken(refreshToken); credential.setExpirationTimeMilliseconds(expirationTimeMillis); } }
@Override public boolean load(String userId, Credential credential) { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Key key = KeyFactory.createKey(KIND, userId); try { Entity entity = datastore.get(key); credential.setAccessToken((String) entity.getProperty("accessToken")); credential.setRefreshToken((String) entity.getProperty("refreshToken")); credential.setExpirationTimeMilliseconds((Long) entity.getProperty("expirationTimeMillis")); return true; } catch (EntityNotFoundException exception) { return false; } }
public boolean load(String userId, Credential credential) throws IOException { Session session = persistence.getSession(table.getDatabaseName()); Column idColumn = DatabaseLogic.findColumnByPropertyName(table, idProperty); Object idValue = OgnlUtils.convertValue(userId, idColumn.getActualJavaType()); Criteria criteria = session.createCriteria(table.getActualEntityName()).add(Restrictions.eq(idProperty, idValue)); TableAccessor tableAccessor = new TableAccessor(table); Object record = criteria.uniqueResult(); if(record == null) { return false; } try { Object value = tableAccessor.getProperty(accessTokenProperty).get(record); credential.setAccessToken((String) value); value = tableAccessor.getProperty(refreshTokenProperty).get(record); credential.setRefreshToken((String) value); value = tableAccessor.getProperty(expirationProperty).get(record); credential.setExpirationTimeMilliseconds((Long) OgnlUtils.convertValue(value, Long.class)); return true; } catch (NoSuchFieldException e) { throw new Error(e); } }
public boolean load(String userId, Credential credential) throws IOException { Session session = persistence.getSession(table.getDatabaseName()); Column idColumn = DatabaseLogic.findColumnByPropertyName(table, idProperty); Object idValue = OgnlUtils.convertValue(userId, idColumn.getActualJavaType()); Criteria criteria = session.createCriteria(table.getActualEntityName()).add(Restrictions.eq(idProperty, idValue)); TableAccessor tableAccessor = new TableAccessor(table); Object record = criteria.uniqueResult(); if(record == null) { return false; } try { Object value = tableAccessor.getProperty(accessTokenProperty).get(record); credential.setAccessToken((String) value); value = tableAccessor.getProperty(refreshTokenProperty).get(record); credential.setRefreshToken((String) value); value = tableAccessor.getProperty(expirationProperty).get(record); credential.setExpirationTimeMilliseconds((Long) OgnlUtils.convertValue(value, Long.class)); return true; } catch (NoSuchFieldException e) { throw new Error(e); } }