Disconnect if token not valid
This commit is contained in:
parent
1eafa7e972
commit
80bfa7816f
3 changed files with 24 additions and 15 deletions
|
@ -46,6 +46,10 @@ public class Class {
|
||||||
//variable with value
|
//variable with value
|
||||||
System.out.println(content);
|
System.out.println(content);
|
||||||
System.out.println("equals < braces");
|
System.out.println("equals < braces");
|
||||||
|
Variable variable = new Variable();
|
||||||
|
int index = variable.parse(content);
|
||||||
|
this.vars.add(variable);
|
||||||
|
content = content.substring(index);
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
Function func = new Function();
|
Function func = new Function();
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Variable {
|
public class Variable {
|
||||||
|
|
||||||
private static Pattern PATTERN = Pattern.compile("^(\\s*([^;]*);).*$");
|
private static Pattern PATTERN = Pattern.compile("^(\\s*)(.*)$");
|
||||||
|
|
||||||
private int modifier;
|
private int modifier;
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -14,18 +14,21 @@ public class Variable {
|
||||||
|
|
||||||
public 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{
|
public int parse(String content) throws Exception{
|
||||||
|
System.out.println("Variable.parse");
|
||||||
|
System.out.println(content);
|
||||||
Matcher matcher = PATTERN.matcher(content);
|
Matcher matcher = PATTERN.matcher(content);
|
||||||
matcher.matches();
|
matcher.matches();
|
||||||
|
|
||||||
String[] split = matcher.group(2).split("\\s+");
|
return 1;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getModifier(){
|
public int getModifier(){
|
||||||
|
|
|
@ -34,12 +34,12 @@ public class Client extends Thread{
|
||||||
router.exec(headers[0], headers[1], isLogin(reader), reader, writer);
|
router.exec(headers[0], headers[1], isLogin(reader), reader, writer);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e){}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private User isLogin(HttpReader reader){
|
private User isLogin(HttpReader reader) throws Exception{
|
||||||
|
String auth = HttpUtil.readAutorization(reader);
|
||||||
|
if(auth == null) return null;
|
||||||
try {
|
try {
|
||||||
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
|
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
|
||||||
.setRequireExpirationTime()
|
.setRequireExpirationTime()
|
||||||
|
@ -51,9 +51,11 @@ public class Client extends Thread{
|
||||||
ConstraintType.PERMIT, AlgorithmIdentifiers.RSA_USING_SHA256)
|
ConstraintType.PERMIT, AlgorithmIdentifiers.RSA_USING_SHA256)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
JwtClaims jwtClaims = jwtConsumer.processToClaims(HttpUtil.readAutorization(reader));
|
JwtClaims jwtClaims = jwtConsumer.processToClaims(auth);
|
||||||
return new User(jwtClaims);
|
return new User(jwtClaims);
|
||||||
}catch(Exception e){}
|
}catch(Exception e){
|
||||||
|
HttpUtil.responseHeaders(writer, 401, "Access-Control-Allow-Origin: *");
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue