Class: RubySMB::Gss::SpnegoNegTokenInit

Inherits:
RASN1::Model
  • Object
show all
Defined in:
lib/ruby_smb/gss/spnego_neg_token_init.rb

Constant Summary collapse

NEG_HINTS_NAME =

The placeholder hintName a Windows server sends, reproduced so the advertisement matches what a client expects.

'not_defined_in_RFC4178@please_ignore'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(mech_types) ⇒ String

Build the NegTokenInit a server sends to advertise the mechanisms it supports, including the Microsoft negHints placeholder so the token is shaped as a Windows server's is.

Parameters:

  • mech_types (Array<OpenSSL::ASN1::ObjectId>) —

    the mechanisms to advertise, in preference order.

Returns:

  • (String) —

    the DER encoded token.



67
68
69
70
71
72
73
# File 'lib/ruby_smb/gss/spnego_neg_token_init.rb', line 67

def self.build(mech_types)
  token = new
  token[:gssapi][:oid].value = Gss::OID_SPNEGO.oid
  token[:gssapi][:neg_token_init][:mech_type_list][:mech_type] = mech_types.map { |mech| MechType.new(value: mech.oid) }
  token[:gssapi][:neg_token_init][:neg_hints][:hint_name] = NEG_HINTS_NAME
  token.to_der
end

Instance Method Details

#mech_token ⇒ String?

Returns the mechanism token the initiator carried, or nil if it carried none.

Returns:

  • (String, nil) —

    the mechanism token the initiator carried, or nil if it carried none.



76
77
78
# File 'lib/ruby_smb/gss/spnego_neg_token_init.rb', line 76

def mech_token
  self[:gssapi][:neg_token_init][:mech_token].value
end