Class: CWT::ClaimsSet

Inherits:
Object
  • Object
show all
Defined in:
lib/cwt/claims_set.rb

Constant Summary collapse

LABEL_ISS =
1
LABEL_SUB =
2
LABEL_AUD =
3
LABEL_EXP =
4
LABEL_NBF =
5
LABEL_IAT =
6
LABEL_CTI =
7

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iss:, sub:, aud:, exp:, nbf:, iat:, cti:) ⇒ ClaimsSet

Returns a new instance of ClaimsSet.



33
34
35
36
37
38
39
40
41
# File 'lib/cwt/claims_set.rb', line 33

def initialize(iss:, sub:, aud:, exp:, nbf:, iat:, cti:)
  @iss = iss
  @sub = sub
  @aud = aud
  @exp = exp
  @nbf = nbf
  @iat = iat
  @cti = cti
end

Instance Attribute Details

#audObject (readonly)

Returns the value of attribute aud.



31
32
33
# File 'lib/cwt/claims_set.rb', line 31

def aud
  @aud
end

#ctiObject (readonly)

Returns the value of attribute cti.



31
32
33
# File 'lib/cwt/claims_set.rb', line 31

def cti
  @cti
end

#expObject (readonly)

Returns the value of attribute exp.



31
32
33
# File 'lib/cwt/claims_set.rb', line 31

def exp
  @exp
end

#iatObject (readonly)

Returns the value of attribute iat.



31
32
33
# File 'lib/cwt/claims_set.rb', line 31

def iat
  @iat
end

#issObject (readonly)

Returns the value of attribute iss.



31
32
33
# File 'lib/cwt/claims_set.rb', line 31

def iss
  @iss
end

#nbfObject (readonly)

Returns the value of attribute nbf.



31
32
33
# File 'lib/cwt/claims_set.rb', line 31

def nbf
  @nbf
end

#subObject (readonly)

Returns the value of attribute sub.



31
32
33
# File 'lib/cwt/claims_set.rb', line 31

def sub
  @sub
end

Class Method Details

.from_cbor(cbor) ⇒ Object



15
16
17
# File 'lib/cwt/claims_set.rb', line 15

def self.from_cbor(cbor)
  from_map(CBOR.decode(cbor))
end

.from_map(map) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cwt/claims_set.rb', line 19

def self.from_map(map)
  new(
    iss: map[LABEL_ISS],
    sub: map[LABEL_SUB],
    aud: map[LABEL_AUD],
    exp: map[LABEL_EXP],
    nbf: map[LABEL_NBF],
    iat: map[LABEL_IAT],
    cti: map[LABEL_CTI]
  )
end

Instance Method Details

#expiration_timeObject



47
48
49
# File 'lib/cwt/claims_set.rb', line 47

def expiration_time
  Time.at(exp)
end

#expired?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/cwt/claims_set.rb', line 43

def expired?
  Time.now >= expiration_time
end