Class: Dnsruby::RR::CERT
- Inherits:
-
Dnsruby::RR
- Object
- Dnsruby::RR
- Dnsruby::RR::CERT
- Defined in:
- lib/dnsruby/resource/CERT.rb
Overview
Class for DNS Certificate (CERT) resource records. (see RFC 2538)
RFC 2782
Defined Under Namespace
Classes: CertificateTypes
Constant Summary collapse
Constants inherited from Dnsruby::RR
Instance Attribute Summary collapse
-
#alg ⇒ Object
Returns the algorithm used by the certificate.
-
#cert ⇒ Object
Returns the data comprising the certificate itself (in raw binary form).
-
#certtype ⇒ Object
Returns the format code for the certificate.
-
#keytag ⇒ Object
Returns the key tag for the public key in the certificate.
Attributes inherited from Dnsruby::RR
#klass, #name, #rdata, #ttl, #type
Class Method Summary collapse
-
.decode_rdata(msg) ⇒ Object
:nodoc: all.
Instance Method Summary collapse
-
#encode_rdata(msg, canonical = false) ⇒ Object
:nodoc: all.
-
#from_data(data) ⇒ Object
:nodoc: all.
-
#from_hash(hash) ⇒ Object
:nodoc: all.
-
#from_string(input) ⇒ Object
:nodoc: all.
-
#rdata_to_string ⇒ Object
:nodoc: all.
Methods inherited from Dnsruby::RR
#<=>, #==, #clone, create, #eql?, find_class, get_class, get_num, #hash, implemented_rrs, #init_defaults, new_from_data, new_from_hash, new_from_string, #rdlength, #sameRRset, #to_s
Instance Attribute Details
#alg ⇒ Object
Returns the algorithm used by the certificate
30 31 32 |
# File 'lib/dnsruby/resource/CERT.rb', line 30 def alg @alg end |
#cert ⇒ Object
Returns the data comprising the certificate itself (in raw binary form)
32 33 34 |
# File 'lib/dnsruby/resource/CERT.rb', line 32 def cert @cert end |
#certtype ⇒ Object
Returns the format code for the certificate
26 27 28 |
# File 'lib/dnsruby/resource/CERT.rb', line 26 def certtype @certtype end |
#keytag ⇒ Object
Returns the key tag for the public key in the certificate
28 29 30 |
# File 'lib/dnsruby/resource/CERT.rb', line 28 def keytag @keytag end |
Class Method Details
.decode_rdata(msg) ⇒ Object
:nodoc: all
98 99 100 101 102 |
# File 'lib/dnsruby/resource/CERT.rb', line 98 def self.decode_rdata(msg) #:nodoc: all certtype, keytag, alg = msg.get_unpack('nnc') cert = msg.get_bytes return self.new([certtype, keytag, alg, cert]) end |
Instance Method Details
#encode_rdata(msg, canonical = false) ⇒ Object
:nodoc: all
93 94 95 96 |
# File 'lib/dnsruby/resource/CERT.rb', line 93 def encode_rdata(msg, canonical=false) #:nodoc: all msg.put_pack('nnc', @certtype.code, @keytag, @alg.code) msg.put_bytes(@cert) end |
#from_data(data) ⇒ Object
:nodoc: all
49 50 51 52 53 54 |
# File 'lib/dnsruby/resource/CERT.rb', line 49 def from_data(data) #:nodoc: all @certtype = CertificateTypes::new(data[0]) @keytag = data[1] @alg = Dnsruby::Algorithms.new(data[2]) @cert= data[3] end |
#from_hash(hash) ⇒ Object
:nodoc: all
56 57 58 59 60 61 |
# File 'lib/dnsruby/resource/CERT.rb', line 56 def from_hash(hash) #:nodoc: all @certtype = CertificateTypes::new(hash[:certtype]) @keytag = hash[:keytag] @alg = Dnsruby::Algorithms.new(hash[:alg]) @cert= hash[:cert] end |
#from_string(input) ⇒ Object
:nodoc: all
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/dnsruby/resource/CERT.rb', line 63 def from_string(input) #:nodoc: all if (input != "") names = input.split(" ") begin @certtype = CertificateTypes::new(names[0]) rescue ArgumentError @certtype = CertificateTypes::new(names[0].to_i) end @keytag = names[1].to_i begin @alg = Dnsruby::Algorithms.new(names[2]) rescue ArgumentError @alg = Dnsruby::Algorithms.new(names[2].to_i) end buf = "" (names.length - 3).times {|index| buf += names[index + 3] } buf.gsub!(/\n/, "") buf.gsub!(/ /, "") @cert = buf.unpack("m*").first end end |
#rdata_to_string ⇒ Object
:nodoc: all
89 90 91 |
# File 'lib/dnsruby/resource/CERT.rb', line 89 def rdata_to_string #:nodoc: all return "#{@certtype.string} #{@keytag} #{@alg.string} #{[@cert.to_s].pack("m*").gsub("\n", "")}" end |