use of org.wso2.carbon.identity.core.util.JdbcUtils.isMySQLDB in project carbon-identity-framework by wso2.
the class UserSessionStore method storeAppSessionData.
/**
* Method to store app session data.
*
* @param sessionId id of the authenticated session
* @param subject username in application
* @param appID id of the application
* @param inboundAuth protocol used in app
* @throws DataAccessException if an error occurs when storing the authenticated user details to the database
*/
public void storeAppSessionData(String sessionId, String subject, int appID, String inboundAuth) throws DataAccessException {
JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate(JdbcUtils.Database.SESSION);
try {
jdbcTemplate.withTransaction(template -> {
String query = SQLQueries.SQL_STORE_IDN_AUTH_SESSION_APP_INFO_H2;
if (JdbcUtils.isOracleDB()) {
query = SQLQueries.SQL_STORE_IDN_AUTH_SESSION_APP_INFO_ORACLE;
template.executeUpdate(query, preparedStatement -> {
preparedStatement.setString(1, sessionId);
preparedStatement.setString(2, subject);
preparedStatement.setInt(3, appID);
preparedStatement.setString(4, inboundAuth);
preparedStatement.setString(5, sessionId);
preparedStatement.setString(6, subject);
preparedStatement.setInt(7, appID);
preparedStatement.setString(8, inboundAuth);
});
} else {
if (JdbcUtils.isMSSqlDB() || JdbcUtils.isDB2DB()) {
query = SQLQueries.SQL_STORE_IDN_AUTH_SESSION_APP_INFO_MSSQL_OR_DB2;
} else if (JdbcUtils.isMySQLDB() || JdbcUtils.isMariaDB()) {
query = SQLQueries.SQL_STORE_IDN_AUTH_SESSION_APP_INFO_MYSQL_OR_MARIADB;
} else if (JdbcUtils.isPostgreSQLDB()) {
query = SQLQueries.SQL_STORE_IDN_AUTH_SESSION_APP_INFO_POSTGRES;
} else if (JdbcUtils.isOracleDB()) {
query = SQLQueries.SQL_STORE_IDN_AUTH_SESSION_APP_INFO_ORACLE;
}
template.executeUpdate(query, preparedStatement -> {
preparedStatement.setString(1, sessionId);
preparedStatement.setString(2, subject);
preparedStatement.setInt(3, appID);
preparedStatement.setString(4, inboundAuth);
});
}
return null;
});
} catch (TransactionException e) {
throw new DataAccessException("Error while storing application data of session id: " + sessionId + ", subject: " + subject + ", app Id: " + appID + ", protocol: " + inboundAuth + ".", e);
}
}
Aggregations