Class: KRB5::Principal
- Inherits:
-
Object
- Object
- KRB5::Principal
- Includes:
- Mixin::Packer
- Defined in:
- lib/krb5/principal.rb
Instance Attribute Summary collapse
-
#bytes ⇒ Sting?
Place to store byte array for #to_bytes.
-
#components ⇒ Object
Returns the value of attribute components.
- #keytab ⇒ KRB5::Keytab
-
#name_type ⇒ Object
Returns the value of attribute name_type.
-
#realm ⇒ Object
Returns the value of attribute realm.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(keytab) ⇒ Principal
constructor
A new instance of Principal.
- #pack_count_of_components ⇒ Object
-
#to_bytes ⇒ Object
principal ::= count of components (16 bits) [includes realm in version 1] realm (data) component1 (data) component2 (data) …
- #to_s ⇒ Object
Methods included from Mixin::Packer
#pack_bytes, #pack_int16, #pack_int32, #pack_int8
Constructor Details
#initialize(keytab) ⇒ Principal
Returns a new instance of Principal.
16 17 18 19 |
# File 'lib/krb5/principal.rb', line 16 def initialize(keytab) @keytab = keytab @components = [] end |
Instance Attribute Details
#bytes ⇒ Sting?
Place to store byte array for #to_bytes
14 15 16 |
# File 'lib/krb5/principal.rb', line 14 def bytes @bytes end |
#components ⇒ Object
Returns the value of attribute components.
10 11 12 |
# File 'lib/krb5/principal.rb', line 10 def components @components end |
#name_type ⇒ Object
Returns the value of attribute name_type.
10 11 12 |
# File 'lib/krb5/principal.rb', line 10 def name_type @name_type end |
#realm ⇒ Object
Returns the value of attribute realm.
10 11 12 |
# File 'lib/krb5/principal.rb', line 10 def realm @realm end |
Instance Method Details
#==(other) ⇒ Object
54 55 56 57 58 59 60 |
# 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 ⇒ Object
45 46 47 48 49 50 51 52 |
# 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 ⇒ Object
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]
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/krb5/principal.rb', line 32 def to_bytes pack_count_of_components pack_int16(realm.length) pack_bytes(realm) components.each do |component| pack_int16(component.length) pack_bytes(component) end pack_int32(name_type) @bytes.join end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/krb5/principal.rb', line 21 def to_s components.join('/') + "@" + realm end |