Skip to content

Commit 9b255fa

Browse files
committed
added lenient way of access to headers as well
1 parent e09a82c commit 9b255fa

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

source/JSONWebToken-Core/JOSEHeader.class.st

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Class {
55
#name : 'JOSEHeader',
66
#superclass : 'Object',
77
#instVars : [
8-
'properties'
8+
'properties',
9+
'strict'
910
],
1011
#category : 'JSONWebToken-Core-Headers',
1112
#package : 'JSONWebToken-Core',
@@ -27,15 +28,30 @@ JOSEHeader >> = aHeader [
2728
]
2829

2930
{ #category : 'accessing' }
30-
JOSEHeader >> at: aKey [
31-
^ properties at: aKey
31+
JOSEHeader >> at: aString [
32+
33+
^ strict
34+
ifTrue: [ properties at: aString ]
35+
ifFalse: [ properties at: aString ifAbsent: nil ]
3236
]
3337

3438
{ #category : 'accessing' }
3539
JOSEHeader >> at: aKey put: aValue [
3640
properties at: aKey put: aValue
3741
]
3842

43+
{ #category : 'initialization' }
44+
JOSEHeader >> beLenient [
45+
46+
strict := false
47+
]
48+
49+
{ #category : 'initialization' }
50+
JOSEHeader >> beStrict [
51+
52+
strict := true
53+
]
54+
3955
{ #category : 'testing' }
4056
JOSEHeader >> hasSameElements: aDictionary [
4157
^ (properties difference: aDictionary) isEmpty
@@ -46,6 +62,12 @@ JOSEHeader >> hash [
4662
^ properties hash
4763
]
4864

65+
{ #category : 'initialization' }
66+
JOSEHeader >> initialize [
67+
super initialize.
68+
strict := true
69+
]
70+
4971
{ #category : 'accessing' }
5072
JOSEHeader >> kid [
5173
"Public Key ID"

source/JSONWebToken-Core/JWTClaimsSet.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ JWTClaimsSet >> at: aString [
3232

3333
^ strict
3434
ifTrue: [ claims at: aString ]
35-
ifFalse: [ claims at: aString ifAbsent: [ ] ]
35+
ifFalse: [ claims at: aString ifAbsent: nil ]
3636
]
3737

3838
{ #category : 'accessing - basic' }

0 commit comments

Comments
 (0)