Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osiv2-postfach
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
osiv2-postfach
Merge requests
!2
Resolve "Bauen eines Mock Servicekonto & Mock Osi Fassade"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Resolve "Bauen eines Mock Servicekonto & Mock Osi Fassade"
2-erstellung-osiv2-repo
into
main
Overview
1
Commits
5
Pipelines
3
Changes
1
Closed
Jan Zickermann
requested to merge
2-erstellung-osiv2-repo
into
main
6 months ago
Overview
1
Commits
5
Pipelines
3
Changes
1
Expand
Closes
#2 (closed)
0
0
Merge request reports
Viewing commit
d67fa44b
Prev
Next
Show latest version
1 file
+
17
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
d67fa44b
#2
Cleanup JwtParser
· d67fa44b
Jan Zickermann
authored
6 months ago
src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/extension/JwtParser.java
+
17
−
7
Options
@@ -11,17 +11,27 @@ public class JwtParser {
@SneakyThrows
public
static
ReadContext
parseBody
(
String
authorizationHeaderValue
)
{
var
jwt
=
authorizationHeaderValue
.
substring
(
"Bearer "
.
length
());
// Step 2: Split the JWT
String
[]
jwtParts
=
jwt
.
split
(
"\\."
);
var
jwtParts
=
splitIntoSignatureAndHeaderAndBody
(
discardBearerPrefix
(
authorizationHeaderValue
)
);
var
bodyPart
=
jwtParts
[
1
];
return
parseJsonPartFromUrlEncodedBase64
(
bodyPart
);
}
private
static
ReadContext
parseJsonPartFromUrlEncodedBase64
(
String
base64EncodedPayload
)
{
return
JsonPath
.
parse
(
new
String
(
base64UrlDecode
(
base64EncodedPayload
)));
}
private
static
String
discardBearerPrefix
(
String
authorizationHeaderValue
)
{
return
authorizationHeaderValue
.
substring
(
"Bearer "
.
length
());
}
private
static
String
[]
splitIntoSignatureAndHeaderAndBody
(
String
jwt
)
{
var
jwtParts
=
jwt
.
split
(
"\\."
);
if
(
jwtParts
.
length
!=
3
)
{
throw
new
IllegalArgumentException
(
"Invalid JWT token"
);
}
// Step 3: Base64Url decode the Payload part
var
payloadJson
=
base64UrlDecode
(
jwtParts
[
1
]);
return
JsonPath
.
parse
(
new
String
(
payloadJson
));
return
jwtParts
;
}
private
static
byte
[]
base64UrlDecode
(
String
input
)
{
Loading