Class: Sigstore::TUF::Root
- Inherits:
-
Object
- Object
- Sigstore::TUF::Root
- Includes:
- Loggable
- Defined in:
- lib/sigstore/tuf/root.rb
Constant Summary collapse
- TYPE =
"root"
Instance Attribute Summary collapse
-
#consistent_snapshot ⇒ Object
readonly
Returns the value of attribute consistent_snapshot.
-
#expires ⇒ Object
readonly
Returns the value of attribute expires.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #expired?(reference_time) ⇒ Boolean
-
#initialize(data) ⇒ Root
constructor
A new instance of Root.
- #verify_delegate(type, bytes, signatures) ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(data) ⇒ Root
Returns a new instance of Root.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sigstore/tuf/root.rb', line 30 def initialize(data) type = data.fetch("_type") raise Error::InvalidData, "Expected type to be #{TYPE}, got #{type.inspect}" unless type == TYPE @spec_version = data.fetch("spec_version") { raise Error::InvalidData, "root missing spec_version" } @consistent_snapshot = data.fetch("consistent_snapshot") do raise Error::InvalidData, "root missing consistent_snapshot" end @version = data.fetch("version") { raise Error::InvalidData, "root missing version" } @expires = Time.iso8601(data.fetch("expires") { raise Error::InvalidData, "root missing expires" }) keys = Keys.new data.fetch("keys") @roles = Roles.new data.fetch("roles"), keys @unrecognized_fields = data.fetch("unrecognized_fields", {}) end |
Instance Attribute Details
#consistent_snapshot ⇒ Object (readonly)
Returns the value of attribute consistent_snapshot.
28 29 30 |
# File 'lib/sigstore/tuf/root.rb', line 28 def consistent_snapshot @consistent_snapshot end |
#expires ⇒ Object (readonly)
Returns the value of attribute expires.
28 29 30 |
# File 'lib/sigstore/tuf/root.rb', line 28 def expires @expires end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
28 29 30 |
# File 'lib/sigstore/tuf/root.rb', line 28 def version @version end |
Instance Method Details
#expired?(reference_time) ⇒ Boolean
49 50 51 |
# File 'lib/sigstore/tuf/root.rb', line 49 def expired?(reference_time) @expires < reference_time end |
#verify_delegate(type, bytes, signatures) ⇒ Object
45 46 47 |
# File 'lib/sigstore/tuf/root.rb', line 45 def verify_delegate(type, bytes, signatures) @roles.verify_delegate(type, bytes, signatures) end |