2016-08-02 23:53:40 +02:00
|
|
|
package eu.univento.commons.security;
|
|
|
|
|
|
|
|
import eu.univento.commons.Commons;
|
|
|
|
|
2016-11-20 09:27:25 +01:00
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.util.ArrayList;
|
2016-08-02 23:53:40 +02:00
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author joethei
|
|
|
|
* @version 0.1
|
|
|
|
*/
|
|
|
|
public class SecurityHandler {
|
|
|
|
|
|
|
|
private Commons commons;
|
|
|
|
|
2016-11-20 09:27:25 +01:00
|
|
|
private ArrayList<String> cache = new ArrayList<>();
|
|
|
|
|
2016-12-06 19:17:13 +01:00
|
|
|
//TODO: add real security
|
|
|
|
|
2016-08-02 23:53:40 +02:00
|
|
|
public SecurityHandler(Commons commons) {
|
|
|
|
this.commons = commons;
|
2017-02-18 18:08:45 +01:00
|
|
|
/*
|
2016-11-20 09:27:25 +01:00
|
|
|
load(resultSet -> {
|
2016-08-02 23:53:40 +02:00
|
|
|
try {
|
2016-11-20 09:27:25 +01:00
|
|
|
while (resultSet.next()) {
|
|
|
|
cache.add(resultSet.getString("ip"));
|
|
|
|
}
|
|
|
|
resultSet.close();
|
2016-08-02 23:53:40 +02:00
|
|
|
} catch (SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
});
|
2017-02-18 18:08:45 +01:00
|
|
|
*/
|
2016-08-02 23:53:40 +02:00
|
|
|
}
|
2016-11-20 09:27:25 +01:00
|
|
|
|
|
|
|
public boolean isValidServer(String ip) {
|
2017-02-18 18:08:45 +01:00
|
|
|
return true;
|
|
|
|
//return cache.contains(ip);
|
2016-11-20 09:27:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void load(Consumer<ResultSet> consumer) {
|
|
|
|
commons.getDatabaseManager().getAsyncMySQL().query("SELECT * FROM Servers;", consumer);
|
|
|
|
}
|
2016-08-02 23:53:40 +02:00
|
|
|
}
|