新增谷歌账号验证工具类

This commit is contained in:
yutou
2020-09-28 18:31:56 +08:00
parent 75c563c714
commit 11bbd3642e
5 changed files with 182 additions and 163 deletions

View File

@@ -16,6 +16,7 @@ import redis.clients.jedis.JedisPubSub;
import javax.accessibility.AccessibleAction;
public class RedisTools {
private static boolean isNotInstallRedis = false;
private static String host;
private static int port;
public static int TOKEN_TIMEOUT_DEFAULT = 360;
@@ -35,6 +36,9 @@ public class RedisTools {
public static boolean set(int dbIndex, String key, String value) {
try {
if (isNotInstallRedis) {
return false;
}
Jedis jedis = getRedis();
jedis.select(dbIndex);
String ret = jedis.set(key, value);
@@ -54,6 +58,9 @@ public class RedisTools {
public static boolean set(String key, String value, int timeout) {
try {
if (isNotInstallRedis) {
return false;
}
Jedis jedis = getRedis();
if (timeout == -1) {
jedis.set(key, value);
@@ -71,6 +78,9 @@ public class RedisTools {
public static String get(String key, int dbIndex) {
String value = "-999";
if (isNotInstallRedis) {
return value;
}
Jedis jedis = null;
try {
jedis = getRedis();
@@ -92,6 +102,9 @@ public class RedisTools {
}
public static boolean remove(String key) {
if (isNotInstallRedis) {
return false;
}
Jedis jedis = getRedis();
Long i = jedis.del(key);
jedis.close();
@@ -121,6 +134,9 @@ public class RedisTools {
}
public static boolean exists(String key, String value) {
if (isNotInstallRedis) {
return false;
}
Jedis jedis = getRedis();
boolean flag = value.equals(jedis.get(key));
jedis.close();
@@ -150,6 +166,9 @@ public class RedisTools {
}
private static Jedis getPoolRedis() {
if (isNotInstallRedis) {
return null;
}
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(0);
poolConfig.setMaxWaitMillis(1000);
@@ -178,7 +197,8 @@ public class RedisTools {
@Override
public void run() {
Jedis jedis = getPoolRedis();
jedis.psubscribe(new Consumer(), "*");
if (jedis != null)
jedis.psubscribe(new Consumer(), "*");
}
}).start();
@@ -191,12 +211,12 @@ public class RedisTools {
System.out.println("onPMessage: channel=" + channel + " msg=" + message + " pattern=" + pattern);
switch (channel) {
case "system":
switch (message){
switch (message) {
case "openPC":
system("openPC",null);
system("openPC", null);
break;
case "updateIP":
system("updateIP",null);
system("updateIP", null);
break;
}
break;
@@ -226,7 +246,7 @@ public class RedisTools {
exec = value;
break;
case "updateIP":
exec="python3 /media/yutou/4t/public/Python/tools/ip.py";
exec = "python3 /media/yutou/4t/public/Python/tools/ip.py";
break;
}
if (exec != null) {