Class: KRB5::Entry

Inherits:
Object
  • Object
show all
Includes:
Mixin::Packer
Defined in:
lib/krb5/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin::Packer

#pack_bytes, #pack_int16, #pack_int32, #pack_int8

Constructor Details

#initialize(keytab) ⇒ Entry

Returns a new instance of Entry.



21
22
23
# File 'lib/krb5/entry.rb', line 21

def initialize(keytab)
  @keytab = keytab
end

Instance Attribute Details

#bytesSting?

Place to store byte array for #to_bytes

Returns:

  • (Sting, nil)


19
20
21
# File 'lib/krb5/entry.rb', line 19

def bytes
  @bytes
end

#enctypeObject

Returns the value of attribute enctype.



13
14
15
# File 'lib/krb5/entry.rb', line 13

def enctype
  @enctype
end

#keyObject

Returns the value of attribute key.



14
15
16
# File 'lib/krb5/entry.rb', line 14

def key
  @key
end

#keytabKRB5::Keytab

Returns:



8
9
10
# File 'lib/krb5/entry.rb', line 8

def keytab
  @keytab
end

#kvno32Object

Returns the value of attribute kvno32.



15
16
17
# File 'lib/krb5/entry.rb', line 15

def kvno32
  @kvno32
end

#kvno8Object

Returns the value of attribute kvno8.



12
13
14
# File 'lib/krb5/entry.rb', line 12

def kvno8
  @kvno8
end

#principalObject

Returns the value of attribute principal.



10
11
12
# File 'lib/krb5/entry.rb', line 10

def principal
  @principal
end

#timestampObject

Returns the value of attribute timestamp.



11
12
13
# File 'lib/krb5/entry.rb', line 11

def timestamp
  @timestamp
end

Instance Method Details

#==(other) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/krb5/entry.rb', line 51

def ==(other)
  %i[principal timestamp kvno8 enctype key kvno32].each do |state|
    return false unless other.send(state) == self.send(state)
  end

  true
end

#kvnoInteger

The 32-bit key version overrides the 8-bit key version.

Returns:

  • (Integer)

    key version number



27
28
29
# File 'lib/krb5/entry.rb', line 27

def kvno
  kvno32 ? kvno32 : kvno8
end

#to_bytesObject

entry ::=

principal
timestamp (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]


39
40
41
42
43
44
45
46
47
48
49
# File 'lib/krb5/entry.rb', line 39

def to_bytes
  pack_bytes(principal.to_bytes)
  pack_int32(timestamp.strftime('%s').to_i)
  pack_int8(kvno8)
  pack_int16(enctype)
  pack_int16(key.length)
  pack_bytes(key)
  pack_int32(kvno32) if kvno32

  @bytes.join
end