Skip to content
Snippets Groups Projects
Commit 04a7e541 authored by Barbara B. Frosik's avatar Barbara B. Frosik
Browse files

cleaning minor

parent 57e40cab
No related branches found
No related tags found
No related merge requests found
File deleted
Main-Class: gov.anl.dm.esafsync.Gui
Class-Path: ../lib/ojdbc7.jar ../lib/javax.json-api-1.0.jar ../lib/jdatepicker-1.3.4.jar
......@@ -16,8 +16,10 @@ public class OracleConnection {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
connection = DriverManager.getConnection(
config.getProperty("oracle.database.connection"),
config.getProperty("oracle.database.username"),
config.getProperty("oracle.database.password"));
// config.getProperty("oracle.database.username"),
// config.getProperty("oracle.database.password"));
"glob_conn",
"ur2ytkownicy2u");
}
String getExperiments(String sector, String lower, String upper) throws SQLException {
......
package gov.anl.dm.esafsync;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class PsqlConnection {
public final class UserInfo {
private final String signature;
private final int id;
UserInfo(String signature, int id) {
this.signature = signature;
this.id = id;
}
String getSignature() {
return signature;
}
int getId() {
return id;
}
}
final int ADMIN_ROLE_ID = 1;
Connection connection = null;
public void connect(Properties config) throws SQLException, ClassNotFoundException {
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection(
config.getProperty("dm.database.connection"),
config.getProperty("dm.database.username"),
config.getProperty("dm.database.password"));
}
UserInfo getUserInfo(String user) throws SQLException {
String signature = null;
int id = -1;
Statement statement = connection.createStatement();
if (statement != null) {
ResultSet results = statement.executeQuery("SELECT * FROM user_info WHERE username = '" + user + "';");
if (results != null) {
while (results.next()) {
signature = results.getString("password");
if (signature.length() > 0) {
id = Integer.parseInt(results.getString("id"));
break;
}
}
results.close();
}
statement.close();
}
if (id < 0) {
return null;
} else {
return new UserInfo(signature, id);
}
}
boolean isAuthorized(int id) throws SQLException {
boolean isAuthorized = false;
Statement statement = connection.createStatement();
if (statement != null) {
ResultSet results = statement.executeQuery("SELECT * FROM user_system_role WHERE user_id = " + id + ";");
if (results != null) {
while (results.next()) {
int roleId = Integer.parseInt(results.getString("role_type_id"));
if (roleId == ADMIN_ROLE_ID) {
isAuthorized = true;
break;
}
}
results.close();
}
statement.close();
}
return isAuthorized;
}
void close() {
try {
connection.close();
} catch (SQLException ex) {
// nothing to do here
}
}
}
......@@ -115,7 +115,6 @@ public class ServiceConnection {
}
String protocol = this.serviceUrl.getProtocol();
System.out.println("protocol "+ protocol);
if (protocol == null) {
JOptionPane.showMessageDialog(null,"Unsupported service protocol specified in " + serviceUrl, "Error",JOptionPane.ERROR_MESSAGE);
return ServiceConnectionStatus.ERROR;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment