class KRB5::Principal

Attributes

bytes[RW]

Place to store byte array for to_bytes @return [Sting, nil]

components[RW]
keytab[RW]

@return [KRB5::Keytab]

name_type[RW]
realm[RW]

Public Class Methods

new(keytab) click to toggle source
# File lib/krb5/principal.rb, line 16
def initialize(keytab)
  @keytab = keytab
  @components = []
end

Public Instance Methods

==(other) click to toggle source
# File lib/krb5/principal.rb, line 54
def ==(other)
  %i[realm components name_type].each do |state|
    return false unless other.send(state) == self.send(state)
  end

  true
end
pack_count_of_components() click to toggle source
# File lib/krb5/principal.rb, line 45
def pack_count_of_components
  if keytab.version == 1
    # Component length includes realm in v1 Keytabs
    pack_int16(components.length + 1)
  elsif keytab.version == 2
    pack_int16(components.length)
  end
end
to_bytes() click to toggle source

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]
# File lib/krb5/principal.rb, line 32
def to_bytes
  @bytes = []

  pack_count_of_components
  pack_data(realm)
  components.each do |component|
    pack_data(component)
  end
  pack_int32(name_type)

  @bytes.join
end
to_s() click to toggle source
# File lib/krb5/principal.rb, line 21
def to_s
  components.join('/') + "@" + realm
end