2016-08-02 23:53:40 +02:00
|
|
|
package eu.univento.commons.security;
|
|
|
|
|
|
|
|
import eu.univento.commons.Commons;
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author joethei
|
|
|
|
* @version 0.1
|
|
|
|
*/
|
|
|
|
public class SecurityHandler {
|
|
|
|
|
|
|
|
private Commons commons;
|
|
|
|
|
|
|
|
public SecurityHandler(Commons commons) {
|
|
|
|
this.commons = commons;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void isValidServer(String ip, Consumer<Boolean> consumer) {
|
2016-09-17 11:55:07 +02:00
|
|
|
commons.getDatabaseManager().getAsyncMySQL().query("SELECT * FROM Servers WHERE ip='" + ip + "';", resultSet -> {
|
2016-08-02 23:53:40 +02:00
|
|
|
try {
|
|
|
|
consumer.accept(resultSet.next());
|
|
|
|
} catch (SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
consumer.accept(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|