Class: Saro::Dat::DatCertificate
- Inherits:
-
Object
- Object
- Saro::Dat::DatCertificate
- Defined in:
- lib/saro/dat/dat_certificate.rb
Instance Attribute Summary collapse
-
#cid ⇒ Object
readonly
Returns the value of attribute cid.
-
#crypto_key ⇒ Object
readonly
Returns the value of attribute crypto_key.
-
#dat_issue_begin ⇒ Object
readonly
Returns the value of attribute dat_issue_begin.
-
#dat_issue_end ⇒ Object
readonly
Returns the value of attribute dat_issue_end.
-
#dat_ttl ⇒ Object
readonly
Returns the value of attribute dat_ttl.
-
#signature_key ⇒ Object
readonly
Returns the value of attribute signature_key.
Class Method Summary collapse
Instance Method Summary collapse
- #expired? ⇒ Boolean
- #exports(option) ⇒ Object
- #has_signing_key? ⇒ Boolean
-
#initialize(cid, signature_key, crypto_key, dat_issue_begin, dat_issue_end, dat_ttl) ⇒ DatCertificate
constructor
A new instance of DatCertificate.
- #issuable? ⇒ Boolean
Constructor Details
#initialize(cid, signature_key, crypto_key, dat_issue_begin, dat_issue_end, dat_ttl) ⇒ DatCertificate
Returns a new instance of DatCertificate.
12 13 14 15 16 17 18 19 |
# File 'lib/saro/dat/dat_certificate.rb', line 12 def initialize(cid, signature_key, crypto_key, dat_issue_begin, dat_issue_end, dat_ttl) @cid = cid @signature_key = signature_key @crypto_key = crypto_key @dat_issue_begin = dat_issue_begin @dat_issue_end = dat_issue_end @dat_ttl = dat_ttl end |
Instance Attribute Details
#cid ⇒ Object (readonly)
Returns the value of attribute cid.
10 11 12 |
# File 'lib/saro/dat/dat_certificate.rb', line 10 def cid @cid end |
#crypto_key ⇒ Object (readonly)
Returns the value of attribute crypto_key.
10 11 12 |
# File 'lib/saro/dat/dat_certificate.rb', line 10 def crypto_key @crypto_key end |
#dat_issue_begin ⇒ Object (readonly)
Returns the value of attribute dat_issue_begin.
10 11 12 |
# File 'lib/saro/dat/dat_certificate.rb', line 10 def dat_issue_begin @dat_issue_begin end |
#dat_issue_end ⇒ Object (readonly)
Returns the value of attribute dat_issue_end.
10 11 12 |
# File 'lib/saro/dat/dat_certificate.rb', line 10 def dat_issue_end @dat_issue_end end |
#dat_ttl ⇒ Object (readonly)
Returns the value of attribute dat_ttl.
10 11 12 |
# File 'lib/saro/dat/dat_certificate.rb', line 10 def dat_ttl @dat_ttl end |
#signature_key ⇒ Object (readonly)
Returns the value of attribute signature_key.
10 11 12 |
# File 'lib/saro/dat/dat_certificate.rb', line 10 def signature_key @signature_key end |
Class Method Details
.imports(format_str) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/saro/dat/dat_certificate.rb', line 31 def self.imports(format_str) split = format_str.split(".") raise ArgumentError, "Invalid Certificate format" if split.length != 8 cid = split[0].to_i(16) sig_key = Saro::Dat::DatSignatureKey.imports(split[1], split[2]) cry_key = Saro::Dat::DatCryptoKey.imports(split[3], Saro::Dat::Util.decode_base64_url(split[4])) new( cid, sig_key, cry_key, split[5].to_i, split[6].to_i, split[7].to_i ) end |
Instance Method Details
#expired? ⇒ Boolean
50 51 52 |
# File 'lib/saro/dat/dat_certificate.rb', line 50 def expired? Time.now.to_i > (@dat_issue_end + @dat_ttl) end |
#exports(option) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/saro/dat/dat_certificate.rb', line 21 def exports(option) cid_hex = @cid.to_s(16) sig_alg = @signature_key.algorithm sig_key = @signature_key.exports(option) cry_alg = @crypto_key.algorithm cry_key = Saro::Dat::Util.encode_base64_url_str(@crypto_key.exports) "#{cid_hex}.#{sig_alg}.#{sig_key}.#{cry_alg}.#{cry_key}.#{@dat_issue_begin}.#{@dat_issue_end}.#{@dat_ttl}" end |
#has_signing_key? ⇒ Boolean
54 55 56 |
# File 'lib/saro/dat/dat_certificate.rb', line 54 def has_signing_key? @signature_key.has_signing_key? end |
#issuable? ⇒ Boolean
45 46 47 48 |
# File 'lib/saro/dat/dat_certificate.rb', line 45 def issuable? now = Time.now.to_i has_signing_key? && @dat_issue_begin <= now && now <= @dat_issue_end end |