Class: Rex::Proto::Kerberos::Model::S4uUserId
- Defined in:
- lib/rex/proto/kerberos/model/s4u_user_id.rb
Overview
This class provides a representation of the S4UUserID structure as defined in the Kerberos protocol.
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
-
#cname ⇒ Rex::Proto::Kerberos::Model::PrincipalName?
The principal name (optional).
-
#crealm ⇒ String
The realm.
-
#nonce ⇒ Integer
The nonce in KDC-REQ-BODY.
-
#options ⇒ String?
The options (optional).
-
#subject_certificate ⇒ String?
The subject certificate (optional).
Instance Method Summary collapse
-
#decode(input) ⇒ self
Decodes the S4UUserID from an input.
-
#encode ⇒ String
Encodes the S4UUserID into an ASN.1 String.
-
#initialize(name, impersonate_type, realm, nonce) ⇒ S4uUserId
constructor
A new instance of S4uUserId.
Methods inherited from Element
attr_accessor, attributes, #attributes, decode
Constructor Details
#initialize(name, impersonate_type, realm, nonce) ⇒ S4uUserId
Returns a new instance of S4uUserId.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 38 def initialize(name, impersonate_type, realm, nonce) self.nonce = nonce # Set cname name_type based on dMSA flag self.cname = Rex::Proto::Kerberos::Model::PrincipalName.new( name_type: impersonate_type == 'dmsa' ? NameType::NT_PRINCIPAL : NameType::NT_ENTERPRISE, name_string: [name] ) self.crealm = realm # Default options self. = impersonate_type == 'dmsa' ? ::Rex::Proto::Kerberos::Model::PaS4uX509UserOptions::UNCONDITIONAL_DELEGATION | ::Rex::Proto::Kerberos::Model::PaS4uX509UserOptions::SIGN_REPLY : ::Rex::Proto::Kerberos::Model::PaS4uX509UserOptions::SIGN_REPLY end |
Instance Attribute Details
#cname ⇒ Rex::Proto::Kerberos::Model::PrincipalName?
Returns The principal name (optional).
15 16 17 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 15 def cname @cname end |
#crealm ⇒ String
Returns The realm.
18 19 20 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 18 def crealm @crealm end |
#nonce ⇒ Integer
Returns The nonce in KDC-REQ-BODY.
12 13 14 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 12 def nonce @nonce end |
#options ⇒ String?
Returns The options (optional).
24 25 26 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 24 def @options end |
#subject_certificate ⇒ String?
Returns The subject certificate (optional).
21 22 23 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 21 def subject_certificate @subject_certificate end |
Instance Method Details
#decode(input) ⇒ self
Decodes the S4UUserID from an input
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 56 def decode(input) case input when String decode_string(input) when OpenSSL::ASN1::ASN1Data decode_asn1(input) else raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode S4UUserID, invalid input' end self end |
#encode ⇒ String
Encodes the S4UUserID into an ASN.1 String
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rex/proto/kerberos/model/s4u_user_id.rb', line 72 def encode elems = [] elems << OpenSSL::ASN1::ASN1Data.new([encode_nonce], 0, :CONTEXT_SPECIFIC) elems << OpenSSL::ASN1::ASN1Data.new([encode_cname], 1, :CONTEXT_SPECIFIC) if cname elems << OpenSSL::ASN1::ASN1Data.new([encode_crealm], 2, :CONTEXT_SPECIFIC) elems << OpenSSL::ASN1::ASN1Data.new([encode_subject_certificate], 3, :CONTEXT_SPECIFIC) if subject_certificate # Convert options to a byte array = [self.].pack('N') # Pack as a big-endian unsigned 32-bit integer elems << OpenSSL::ASN1::ASN1Data.new([OpenSSL::ASN1::BitString.new()], 4, :CONTEXT_SPECIFIC) seq = OpenSSL::ASN1::Sequence.new(elems) seq.to_der end |