Class: Rex::Proto::Kerberos::Model::PrincipalName

Inherits:
Element
  • Object
show all
Defined in:
lib/rex/proto/kerberos/model/principal_name.rb

Overview

This class provides a representation of a principal, an asset (e.g., a workstation user or a network server) on a network.

Constant Summary

Constants included from Rex::Proto::Kerberos::Model

AP_REP, AP_REQ, AS_REP, AS_REQ, AUTHENTICATOR, ENC_KRB_CRED_PART, KRB_CRED, KRB_ERROR, TGS_REP, TGS_REQ, TICKET, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

attr_accessor, attributes, #attributes, decode, #initialize

Constructor Details

This class inherits a constructor from Rex::Proto::Kerberos::Model::Element

Instance Attribute Details

#name_stringArray<String>

Returns A sequence of strings that form a name.

Returns:

  • (Array<String>)

    A sequence of strings that form a name.



16
17
18
# File 'lib/rex/proto/kerberos/model/principal_name.rb', line 16

def name_string
  @name_string
end

#name_typeInteger

Returns The type of name.

Returns:

  • (Integer)

    The type of name



13
14
15
# File 'lib/rex/proto/kerberos/model/principal_name.rb', line 13

def name_type
  @name_type
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
21
# File 'lib/rex/proto/kerberos/model/principal_name.rb', line 18

def ==(other)
  name_type == other.name_type &&
    name_string == other.name_string
end

#decode(input) ⇒ self

Decodes a Rex::Proto::Kerberos::Model::PrincipalName

Parameters:

  • input (String, OpenSSL::ASN1::Sequence)

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rex/proto/kerberos/model/principal_name.rb', line 28

def decode(input)
  case input
  when String
    decode_string(input)
  when OpenSSL::ASN1::Sequence
    decode_asn1(input)
  else
    raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode Principal Name, invalid input'
  end

  self
end

#encodeString

Encodes a Rex::Proto::Kerberos::Model::PrincipalName into an ASN.1 String

Returns:

  • (String)


45
46
47
48
49
50
51
# File 'lib/rex/proto/kerberos/model/principal_name.rb', line 45

def encode
  integer_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_name_type], 0, :CONTEXT_SPECIFIC)
  string_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_name_string], 1, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new([integer_asn1, string_asn1])

  seq.to_der
end

#to_sObject



53
54
55
# File 'lib/rex/proto/kerberos/model/principal_name.rb', line 53

def to_s
  name_string.join('/')
end