diff --git a/src/be/jeffcheasey88/peeratcode/Configuration.java b/src/be/jeffcheasey88/peeratcode/Configuration.java index 73e32b8..8a3523f 100644 --- a/src/be/jeffcheasey88/peeratcode/Configuration.java +++ b/src/be/jeffcheasey88/peeratcode/Configuration.java @@ -20,6 +20,8 @@ public class Configuration { private String ssl_keystore; private String ssl_keystorePasswd; + private String token_issuer; + private File _file; public Configuration(String path){ @@ -121,6 +123,10 @@ public class Configuration { return this.ssl_keystore; } + public String getTokenIssuer(){ + return this.token_issuer; + } + public String getSslKeystorePasswd(){ return this.ssl_keystorePasswd; } diff --git a/src/be/jeffcheasey88/peeratcode/Main.java b/src/be/jeffcheasey88/peeratcode/Main.java index 9be49b9..c00c796 100644 --- a/src/be/jeffcheasey88/peeratcode/Main.java +++ b/src/be/jeffcheasey88/peeratcode/Main.java @@ -49,7 +49,7 @@ public class Main { Class.forName("com.mysql.cj.jdbc.Driver"); - Router router = new Router(new DatabaseRepository(config)); + Router router = new Router(new DatabaseRepository(config), config.getTokenIssuer()); router.setDefault(new Response(){ diff --git a/src/be/jeffcheasey88/peeratcode/webserver/Router.java b/src/be/jeffcheasey88/peeratcode/webserver/Router.java index 0999d33..a5dcc1c 100644 --- a/src/be/jeffcheasey88/peeratcode/webserver/Router.java +++ b/src/be/jeffcheasey88/peeratcode/webserver/Router.java @@ -19,9 +19,11 @@ public class Router{ private Response noFileFound; private RsaJsonWebKey rsaJsonWebKey; private DatabaseRepository repo; + private String token_issuer; - public Router(DatabaseRepository repo) throws Exception{ + public Router(DatabaseRepository repo, String token_issuer) throws Exception{ this.repo = repo; + this.token_issuer = token_issuer; this.responses = new ArrayList<>(); this.rsaJsonWebKey = RsaJwkGenerator.generateJwk(2048); } @@ -57,8 +59,7 @@ public class Router{ public String createAuthUser(int id) throws JoseException{ JwtClaims claims = new JwtClaims(); - claims.setIssuer("Issuer"); // who creates the token and signs it - claims.setAudience("Audience"); // to whom the token is intended to be sent + claims.setIssuer(token_issuer); // who creates the token and signs it claims.setExpirationTimeMinutesInTheFuture(10); // time when the token will expire (10 minutes from now) claims.setGeneratedJwtId(); // a unique identifier for the token claims.setIssuedAtToNow(); // when the token was issued/created (now)