Class: Sigstore::TUF::Targets
- Inherits:
-
Object
- Object
- Sigstore::TUF::Targets
- Defined in:
- lib/sigstore/tuf/targets.rb
Defined Under Namespace
Classes: Delegations, Target
Constant Summary collapse
- TYPE =
"targets"
Instance Attribute Summary collapse
-
#delegations ⇒ Object
readonly
Returns the value of attribute delegations.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #expired?(reference_time) ⇒ Boolean
-
#initialize(data) ⇒ Targets
constructor
A new instance of Targets.
- #verify_delegate(type, bytes, signatures) ⇒ Object
Constructor Details
#initialize(data) ⇒ Targets
Returns a new instance of Targets.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sigstore/tuf/targets.rb', line 27 def initialize(data) type = data.fetch("_type") raise Error::InvalidData, "Expected type to be #{TYPE}, got #{type.inspect}" unless type == TYPE @version = data.fetch("version") @expires = Time.iso8601 data.fetch("expires") @targets = data.fetch("targets").to_h { |k, v| [k, Target.new(v, k)] } @delegations = Delegations.new(data.fetch("delegations", {})) @unrecognized_fields = data.fetch("unrecognized_fields", {}) end |
Instance Attribute Details
#delegations ⇒ Object (readonly)
Returns the value of attribute delegations.
25 26 27 |
# File 'lib/sigstore/tuf/targets.rb', line 25 def delegations @delegations end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
25 26 27 |
# File 'lib/sigstore/tuf/targets.rb', line 25 def targets @targets end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
25 26 27 |
# File 'lib/sigstore/tuf/targets.rb', line 25 def version @version end |
Instance Method Details
#expired?(reference_time) ⇒ Boolean
39 40 41 |
# File 'lib/sigstore/tuf/targets.rb', line 39 def expired?(reference_time) @expires < reference_time end |
#verify_delegate(type, bytes, signatures) ⇒ Object
43 44 45 46 |
# File 'lib/sigstore/tuf/targets.rb', line 43 def verify_delegate(type, bytes, signatures) role = @delegations.fetch(type) role.verify_delegate(type, bytes, signatures) end |