Skip to content
Snippets Groups Projects
Commit a50d9500 authored by Manuel Spuhler's avatar Manuel Spuhler
Browse files

Downgraded jsonwebtoken lib

parent a1051b2b
No related branches found
No related tags found
No related merge requests found
......@@ -295,20 +295,8 @@
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.10.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.10.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.10.5</version>
<scope>runtime</scope>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
......
......@@ -33,10 +33,10 @@ public class JWTApi {
LOGGER.info("Create a JSON Web Token");
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
String apiKey = "6v2oxpJMzU14U-dqVireln5AUKTtx5fBPSEgaBZiI983d98cfa6";
byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(apiKey);
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
// SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
// String apiKey = "6v2oxpJMzU14U-dqVireln5AUKTtx5fBPSEgaBZiI983d98cfa6";
// byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(apiKey);
// Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
......@@ -44,13 +44,16 @@ public class JWTApi {
User user = userInfo.getUser();
// Set the JWT Claims
JwtBuilder builder = Jwts.builder().setIssuedAt(now)
.setIssuer("mip.humanbrainproject.eu").setSubject(user.getEmail()).signWith(signatureAlgorithm, signingKey);
JwtBuilder builder = Jwts.builder().setIssuedAt(now).setIssuer("mip.humanbrainproject.eu")
.setSubject(user.getEmail()).signWith(SignatureAlgorithm.HS512,
"hbpSecret");
long expMillis = nowMillis + 86400 * 24;
Date exp = new Date(expMillis);
builder.setExpiration(exp);
String token = builder.compact();
LOGGER.info(token);
// long expMillis = nowMillis + 86400 * 24;
// Date exp = new Date(expMillis);
// builder.setExpiration(exp);
return ResponseEntity.status(HttpStatus.CREATED).body(builder.compact());
return ResponseEntity.status(HttpStatus.CREATED).body(token);
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment