Class: KRB5::Keytab
- Inherits:
-
Object
- Object
- KRB5::Keytab
- Includes:
- Mixin::Packer
- Defined in:
- lib/krb5/keytab.rb
Instance Attribute Summary collapse
-
#bytes ⇒ Sting?
Place to store byte array for #to_bytes.
-
#entries ⇒ Array<KRB5::Entry>
Keytab entries.
-
#source_bytes ⇒ String?
If parsed, contains source bytes.
-
#version ⇒ Integer
Keytab version.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize ⇒ Keytab
constructor
A new instance of Keytab.
- #save(filename) ⇒ Object
-
#to_bytes ⇒ Object
keytab ::= 5 (8 bits) version (8 bits) entry1 length (32 bits) entry1 (entry) entry2 length (32 bits) entry2 (entry) …
Methods included from Mixin::Packer
#pack_bytes, #pack_int16, #pack_int32, #pack_int8
Constructor Details
#initialize ⇒ Keytab
Returns a new instance of Keytab.
24 25 26 |
# File 'lib/krb5/keytab.rb', line 24 def initialize @entries = [] end |
Instance Attribute Details
#bytes ⇒ Sting?
Place to store byte array for #to_bytes
22 23 24 |
# File 'lib/krb5/keytab.rb', line 22 def bytes @bytes end |
#entries ⇒ Array<KRB5::Entry>
Keytab entries
14 15 16 |
# File 'lib/krb5/keytab.rb', line 14 def entries @entries end |
#source_bytes ⇒ String?
If parsed, contains source bytes
18 19 20 |
# File 'lib/krb5/keytab.rb', line 18 def source_bytes @source_bytes end |
#version ⇒ Integer
Keytab version
10 11 12 |
# File 'lib/krb5/keytab.rb', line 10 def version @version end |
Class Method Details
.load(filename) ⇒ Object
28 29 30 31 |
# File 'lib/krb5/keytab.rb', line 28 def self.load(filename) keytab_data = File.binread(filename) KRB5::KeytabParser.parse(keytab_data) end |
Instance Method Details
#==(other) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/krb5/keytab.rb', line 80 def ==(other) i[version entries].each do |state| return false unless other.send(state) == self.send(state) end true end |
#save(filename) ⇒ Object
33 34 35 |
# File 'lib/krb5/keytab.rb', line 33 def save(filename) File.binwrite(filename, to_bytes) end |
#to_bytes ⇒ Object
keytab ::=
5 (8 bits)
version (8 bits)
entry1 length (32 bits)
entry1 (entry)
entry2 length (32 bits)
entry2 (entry)
...
entry ::=
principal
(32 bits)
key version (8 bits)
enctype (16 bits)
key length (16 bits)
key contents
key version (32 bits) [in release 1.14 and later]
principal ::=
count of components (16 bits) [includes realm in version 1]
realm (data)
component1 (data)
component2 (data)
...
name type (32 bits) [omitted in version 1]
data ::=
length (16 bits)
value (length bytes)
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/krb5/keytab.rb', line 66 def to_bytes # First byte is always a 5 pack_int8(5) pack_int8(version) entries.each do |entry| entry_bytes = entry.to_bytes pack_int32(entry_bytes.length) pack_bytes(entry_bytes) end @bytes.join end |