Class: Rex::Proto::Kerberos::Model::Element

Inherits:
Object
  • Object
show all
Includes:
Crypto, Rex::Proto::Kerberos::Model
Defined in:
lib/rex/proto/kerberos/model/element.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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Element

Returns a new instance of Element.

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
# File 'lib/rex/proto/kerberos/model/element.rb', line 32

def initialize(options = {})
  raise ArgumentError, "Invalid options, expected hash, got #{options.class}" unless options.is_a?(Hash)

  self.class.attributes.each do |attr|
    if options.has_key?(attr)
      m = (attr.to_s + '=').to_sym
      self.send(m, options[attr])
    end
  end
end

Class Method Details

.attr_accessor(*vars) ⇒ Object



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

def self.attr_accessor(*vars)
  @attributes ||= []
  @attributes.concat vars
  super(*vars)
end

.attributesArray

Retrieves the element class fields

Returns:

  • (Array)


23
24
25
# File 'lib/rex/proto/kerberos/model/element.rb', line 23

def self.attributes
  @attributes
end

.decode(input) ⇒ Object



27
28
29
30
# File 'lib/rex/proto/kerberos/model/element.rb', line 27

def self.decode(input)
  elem = self.new
  elem.decode(input)
end

Instance Method Details

#attributesArray

Retrieves the element instance fields

Returns:

  • (Array)


46
47
48
# File 'lib/rex/proto/kerberos/model/element.rb', line 46

def attributes
  self.class.attributes
end

#decode(input) ⇒ Object

Decodes the Rex::Proto::Kerberos::Model::Element from the input. This method has been designed to be overridden by subclasses.

Raises:

  • (NoMethodError)


54
55
56
# File 'lib/rex/proto/kerberos/model/element.rb', line 54

def decode(input)
  raise ::NoMethodError, 'Method designed to be overridden'
end

#encodeObject

Encodes the Rex::Proto::Kerberos::Model::Element into an ASN.1 String. This method has been designed to be overridden by subclasses.

Raises:

  • (NoMethodError)


62
63
64
# File 'lib/rex/proto/kerberos/model/element.rb', line 62

def encode
  raise ::NoMethodError, 'Method designed to be overridden'
end