32 lines
822 B
Java
32 lines
822 B
Java
package eu.univento.commons.security;
|
|
|
|
import eu.univento.commons.Commons;
|
|
import eu.univento.commons.database.AsyncMySQL;
|
|
|
|
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) {
|
|
AsyncMySQL sql = commons.getDatabaseManager().getAsyncMySQL();
|
|
sql.query("SELECT * FROM Servers WHERE ip='" + ip + "';", resultSet -> {
|
|
try {
|
|
consumer.accept(resultSet.next());
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
consumer.accept(false);
|
|
}
|
|
});
|
|
}
|
|
} |