Class: JWEToken

Inherits:
Object
  • Object
show all
Defined in:
lib/ons-jwe/jwe_token.rb

Overview

This class generates JSON Web Encryption (JWE) tokens as per RFC 7516.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_id, claims, public_key, private_key) ⇒ JWEToken

Returns a new instance of JWEToken.



9
10
11
12
13
14
15
16
17
# File 'lib/ons-jwe/jwe_token.rb', line 9

def initialize(key_id, claims, public_key, private_key)
  validate_key_id(key_id)
  validate_claims(claims)
  validate_public_key(public_key)
  validate_private_key(private_key)
  jwt    = build_jwt(claims, key_id)
  jws    = build_jws(jwt, private_key)
  @value = build_jwe(jws, public_key).to_s
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/ons-jwe/jwe_token.rb', line 7

def value
  @value
end

Instance Method Details

#to_sObject



19
20
21
# File 'lib/ons-jwe/jwe_token.rb', line 19

def to_s
  @value
end