Fix JWt subject
This commit is contained in:
parent
d4fcf57144
commit
46e6b49db2
3 changed files with 12 additions and 3 deletions
|
@ -44,7 +44,6 @@ public class Client extends Thread{
|
||||||
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
|
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
|
||||||
.setRequireExpirationTime()
|
.setRequireExpirationTime()
|
||||||
.setAllowedClockSkewInSeconds(30)
|
.setAllowedClockSkewInSeconds(30)
|
||||||
.setRequireSubject()
|
|
||||||
.setExpectedIssuer(this.router.getTokenIssuer())
|
.setExpectedIssuer(this.router.getTokenIssuer())
|
||||||
.setVerificationKey(this.router.getWebKey().getKey())
|
.setVerificationKey(this.router.getWebKey().getKey())
|
||||||
.setJwsAlgorithmConstraints(
|
.setJwsAlgorithmConstraints(
|
||||||
|
|
|
@ -87,8 +87,6 @@ public class Router{
|
||||||
|
|
||||||
claims.setClaim("id", id);
|
claims.setClaim("id", id);
|
||||||
|
|
||||||
claims.setSubject("Nani ???");
|
|
||||||
|
|
||||||
JsonWebSignature jws = new JsonWebSignature();
|
JsonWebSignature jws = new JsonWebSignature();
|
||||||
jws.setPayload(claims.toJson());
|
jws.setPayload(claims.toJson());
|
||||||
jws.setKey(rsaJsonWebKey.getPrivateKey());
|
jws.setKey(rsaJsonWebKey.getPrivateKey());
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class WebClient {
|
||||||
private String token;
|
private String token;
|
||||||
private int responseCode;
|
private int responseCode;
|
||||||
private List<String> headers;
|
private List<String> headers;
|
||||||
|
private List<String> content;
|
||||||
|
|
||||||
private String host;
|
private String host;
|
||||||
private int port;
|
private int port;
|
||||||
|
@ -32,6 +33,7 @@ public class WebClient {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.headers = new ArrayList<>();
|
this.headers = new ArrayList<>();
|
||||||
|
this.content = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureConnection() throws Exception{
|
private void ensureConnection() throws Exception{
|
||||||
|
@ -40,6 +42,7 @@ public class WebClient {
|
||||||
this.writer = new HttpWriter(socket);
|
this.writer = new HttpWriter(socket);
|
||||||
this.responseCode = -1;
|
this.responseCode = -1;
|
||||||
this.headers.clear();
|
this.headers.clear();
|
||||||
|
this.content.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void auth(String user, String password) throws Exception{
|
public void auth(String user, String password) throws Exception{
|
||||||
|
@ -52,6 +55,7 @@ public class WebClient {
|
||||||
Matcher matcher = AUTORIZATION.matcher(line);
|
Matcher matcher = AUTORIZATION.matcher(line);
|
||||||
if(matcher.matches()){
|
if(matcher.matches()){
|
||||||
this.token = matcher.group(1);
|
this.token = matcher.group(1);
|
||||||
|
System.out.println(token);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +73,8 @@ public class WebClient {
|
||||||
this.responseCode = Integer.parseInt(this.reader.readLine().split("\\s+")[1]);
|
this.responseCode = Integer.parseInt(this.reader.readLine().split("\\s+")[1]);
|
||||||
String line;
|
String line;
|
||||||
while(((line = reader.readLine()) != null) && line.length() > 0) this.headers.add(line);
|
while(((line = reader.readLine()) != null) && line.length() > 0) this.headers.add(line);
|
||||||
|
|
||||||
|
while((line = reader.readLine()) != null) this.content.add(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertResponseCode(int expected){
|
public void assertResponseCode(int expected){
|
||||||
|
@ -79,4 +85,10 @@ public class WebClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void assertHeader(String expected){
|
||||||
|
for(String header : headers){
|
||||||
|
if(header.equals(expected)) return;
|
||||||
|
}
|
||||||
|
fail("Line <"+expected+"> not found in "+this.headers.size()+" headers");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue