use of cbit.vcell.modeldb.ApiAccessToken.AccessTokenStatus in project vcell by virtualcell.
the class UserDbDriver method generateApiAccessToken.
public ApiAccessToken generateApiAccessToken(Connection con, KeyFactory keyFactory, KeyValue apiClientKey, User user, Date expirationDate) throws SQLException {
String sql;
KeyValue key = keyFactory.getNewKey(con);
UUID idOne = UUID.randomUUID();
Date creationDate = new Date();
String token = idOne.toString();
AccessTokenStatus accessTokenStatus = AccessTokenStatus.created;
sql = "INSERT INTO " + ApiAccessTokenTable.table.getTableName() + " " + ApiAccessTokenTable.table.getSQLColumnList() + " VALUES " + ApiAccessTokenTable.table.getSQLValueList(key, token, apiClientKey, user, creationDate, expirationDate, accessTokenStatus);
DbDriver.updateCleanSQL(con, sql);
return new ApiAccessToken(key, token, apiClientKey, user, creationDate, expirationDate, accessTokenStatus);
}
use of cbit.vcell.modeldb.ApiAccessToken.AccessTokenStatus in project vcell by virtualcell.
the class ApiAccessTokenTable method getApiAccessToken.
/**
* This method was created in VisualAge.
* @return Model
* @param rset ResultSet
* @param log SessionLog
*/
public ApiAccessToken getApiAccessToken(ResultSet rset) throws SQLException, DataAccessException {
KeyValue key = new KeyValue(rset.getBigDecimal(id.toString()));
String token = rset.getString(accesstoken.toString());
KeyValue clientKey = new KeyValue(rset.getBigDecimal(clientRef.toString()));
KeyValue userKey = new KeyValue(rset.getBigDecimal(userref.toString()));
String userid = rset.getString(UserTable.table.userid.toString());
User user = new User(userid, userKey);
java.util.Date creation = VersionTable.getDate(rset, creationDate.toString());
if (creation == null) {
throw new DataAccessException("could not parse creation date");
}
java.util.Date expiration = VersionTable.getDate(rset, expireDate.toString());
if (expiration == null) {
throw new DataAccessException("could not parse expiration date");
}
String accessTokenDatabaseString = rset.getString(status.toString());
// default value if null
AccessTokenStatus accessTokenStatus = AccessTokenStatus.created;
if (accessTokenDatabaseString != null) {
accessTokenStatus = AccessTokenStatus.fromDatabaseString(accessTokenDatabaseString);
}
ApiAccessToken apiAccessToken = new ApiAccessToken(key, token, clientKey, user, creation, expiration, accessTokenStatus);
return apiAccessToken;
}
Aggregations