diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Class.java b/src/be/jeffcheasey88/peeratcode/parser/java/Class.java index f85cf50..8daabc5 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Class.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Class.java @@ -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(); diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java b/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java index 037ff16..127e979 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Variable.java @@ -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; + //Testt; + //Test 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(){ diff --git a/src/be/jeffcheasey88/peeratcode/webserver/Client.java b/src/be/jeffcheasey88/peeratcode/webserver/Client.java index 0132583..e7bf5c7 100644 --- a/src/be/jeffcheasey88/peeratcode/webserver/Client.java +++ b/src/be/jeffcheasey88/peeratcode/webserver/Client.java @@ -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; } } \ No newline at end of file