Fix Java's Method access + Always response 401 when no token -> even when not neccessary
This commit is contained in:
parent
7e4cc9f425
commit
a79876b71c
2 changed files with 3 additions and 2 deletions
|
@ -22,6 +22,7 @@ public class RouteMapper<U extends User>{
|
||||||
|
|
||||||
public void register(Object instance, Method method, Route route){
|
public void register(Object instance, Method method, Route route){
|
||||||
int length = states.length+1;
|
int length = states.length+1;
|
||||||
|
method.setAccessible(true);
|
||||||
this.states = addElement(states, new RouteState[length], new RouteState(instance, method, route));
|
this.states = addElement(states, new RouteState[length], new RouteState(instance, method, route));
|
||||||
if(this.calls != null) this.calls = new int[length];
|
if(this.calls != null) this.calls = new int[length];
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,14 +81,14 @@ public class JwtAuthenticator<U extends User> implements Authenticator<U>{
|
||||||
@Override
|
@Override
|
||||||
public U getUser(RequestType type, HttpReader reader) throws Exception{
|
public U getUser(RequestType type, HttpReader reader) throws Exception{
|
||||||
String auth = reader.getHeader("Authorization");
|
String auth = reader.getHeader("Authorization");
|
||||||
if(auth == null) throw new AuthException("Header 'Authorization' notfound");
|
if(auth == null) return null;
|
||||||
auth = auth.substring(7);
|
auth = auth.substring(7);
|
||||||
return this.userCreator.apply(this.jwtConsumer.processToClaims(auth));
|
return this.userCreator.apply(this.jwtConsumer.processToClaims(auth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public U getUser(String data) throws Exception {
|
public U getUser(String data) throws Exception {
|
||||||
if(data == null) throw new AuthException("Null Token");
|
if(data == null) return null;
|
||||||
return this.userCreator.apply(this.jwtConsumer.processToClaims(data));
|
return this.userCreator.apply(this.jwtConsumer.processToClaims(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue