Class: Rex::Proto::Kerberos::Model::PrincipalName
- 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_AP_REP_PART, ENC_KRB_CRED_PART, KRB_CRED, KRB_ERROR, TGS_REP, TGS_REQ, TICKET, VERSION
Instance Attribute Summary collapse
-
#name_string ⇒ Array<String>
A sequence of strings that form a name.
-
#name_type ⇒ Integer
The type of name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#decode(input) ⇒ self
Decodes a Rex::Proto::Kerberos::Model::PrincipalName.
-
#encode ⇒ String
Encodes a Rex::Proto::Kerberos::Model::PrincipalName into an ASN.1 String.
- #to_s ⇒ Object
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_string ⇒ Array<String>
Returns 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_type ⇒ Integer
Returns 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
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 |
#encode ⇒ String
Encodes a Rex::Proto::Kerberos::Model::PrincipalName into an ASN.1 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_s ⇒ Object
53 54 55 |
# File 'lib/rex/proto/kerberos/model/principal_name.rb', line 53 def to_s name_string.join('/') end |