CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/proto/kerberos/model/element.rb
Views: 11766
1
# -*- coding: binary -*-
2
3
module Rex
4
module Proto
5
module Kerberos
6
module Model
7
# This class provides a representation of a principal, an asset (e.g., a
8
# workstation user or a network server) on a network.
9
class Element
10
11
include Rex::Proto::Kerberos::Crypto
12
include Rex::Proto::Kerberos::Model
13
14
def self.attr_accessor(*vars)
15
@attributes ||= []
16
@attributes.concat vars
17
super(*vars)
18
end
19
20
# Retrieves the element class fields
21
#
22
# @return [Array]
23
def self.attributes
24
@attributes
25
end
26
27
def self.decode(input)
28
elem = self.new
29
elem.decode(input)
30
end
31
32
def initialize(options = {})
33
raise ArgumentError, "Invalid options, expected hash, got #{options.class}" unless options.is_a?(Hash)
34
35
self.class.attributes.each do |attr|
36
if options.has_key?(attr)
37
m = (attr.to_s + '=').to_sym
38
self.send(m, options[attr])
39
end
40
end
41
end
42
43
# Retrieves the element instance fields
44
#
45
# @return [Array]
46
def attributes
47
self.class.attributes
48
end
49
50
# Decodes the Rex::Proto::Kerberos::Model::Element from the input. This
51
# method has been designed to be overridden by subclasses.
52
#
53
# @raise [NoMethodError]
54
def decode(input)
55
raise ::NoMethodError, 'Method designed to be overridden'
56
end
57
58
# Encodes the Rex::Proto::Kerberos::Model::Element into an ASN.1 String. This
59
# method has been designed to be overridden by subclasses.
60
#
61
# @raise [NoMethodError]
62
def encode
63
raise ::NoMethodError, 'Method designed to be overridden'
64
end
65
end
66
end
67
end
68
end
69
end
70
71