Disconnect if token not valid

This commit is contained in:
jeffcheasey88 2023-02-27 14:52:42 +01:00
parent 1eafa7e972
commit 80bfa7816f
3 changed files with 24 additions and 15 deletions

View file

@ -46,6 +46,10 @@ public class Class {
//variable with value
System.out.println(content);
System.out.println("equals < braces");
Variable variable = new Variable();
int index = variable.parse(content);
this.vars.add(variable);
content = content.substring(index);
break;
}else{
Function func = new Function();

View file

@ -6,7 +6,7 @@ import java.util.regex.Pattern;
public class Variable {
private static Pattern PATTERN = Pattern.compile("^(\\s*([^;]*);).*$");
private static Pattern PATTERN = Pattern.compile("^(\\s*)(.*)$");
private int modifier;
private String name;
@ -14,18 +14,21 @@ public class Variable {
public Variable(){}
//int i = 4;
//int i,j,k,l=1;
//int lm ;
//public static int l;
//Test<Test>t;
//Test<Test,K,L> j = new Test().schedule(p -> { return true;});
//int i =j=k=l=4;
public int parse(String content) throws Exception{
System.out.println("Variable.parse");
System.out.println(content);
Matcher matcher = PATTERN.matcher(content);
matcher.matches();
String[] split = matcher.group(2).split("\\s+");
for(int i = 0; i < split.length-2; i++){
this.modifier+=JavaParser.getModifier(split[i]);
}
this.name = split[split.length-1];
this.type = split[split.length-2];
return matcher.group(1).length();
return 1;
}
public int getModifier(){

View file

@ -34,12 +34,12 @@ public class Client extends Thread{
router.exec(headers[0], headers[1], isLogin(reader), reader, writer);
writer.flush();
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e){}
}
private User isLogin(HttpReader reader){
private User isLogin(HttpReader reader) throws Exception{
String auth = HttpUtil.readAutorization(reader);
if(auth == null) return null;
try {
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
.setRequireExpirationTime()
@ -51,9 +51,11 @@ public class Client extends Thread{
ConstraintType.PERMIT, AlgorithmIdentifiers.RSA_USING_SHA256)
.build();
JwtClaims jwtClaims = jwtConsumer.processToClaims(HttpUtil.readAutorization(reader));
JwtClaims jwtClaims = jwtConsumer.processToClaims(auth);
return new User(jwtClaims);
}catch(Exception e){}
}catch(Exception e){
HttpUtil.responseHeaders(writer, 401, "Access-Control-Allow-Origin: *");
}
return null;
}
}