Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
portal-backend
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HBP Medical Informatics Platform
portal-backend
Commits
a50d9500
Commit
a50d9500
authored
5 years ago
by
Manuel Spuhler
Browse files
Options
Downloads
Patches
Plain Diff
Downgraded jsonwebtoken lib
parent
a1051b2b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pom.xml
+2
-14
2 additions, 14 deletions
pom.xml
src/main/java/eu/hbp/mip/controllers/JWTApi.java
+13
-10
13 additions, 10 deletions
src/main/java/eu/hbp/mip/controllers/JWTApi.java
with
15 additions
and
24 deletions
pom.xml
+
2
−
14
View file @
a50d9500
...
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/eu/hbp/mip/controllers/JWTApi.java
+
13
−
10
View file @
a50d9500
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment