Sha256: 0fa30a4760823931a87e0473517d70efdba3c0ebbdce4114f0671a7d0adc0f1f

Contents?: true

Size: 1.81 KB

Versions: 7

Compression:

Stored size: 1.81 KB

Contents

# -*- coding: binary -*-

module Rex
  module Proto
    module Kerberos
      module Model
        # This class provides a representation of a principal, an asset (e.g., a
        # workstation user or a network server) on a network.
        class Element

          include Rex::Proto::Kerberos::Crypto
          include Rex::Proto::Kerberos::Model

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

          # Retrieves the element class fields
          #
          # @return [Array]
          def self.attributes
            @attributes
          end

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

          def initialize(options = {})
            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

          # Retrieves the element instance fields
          #
          # @return [Array]
          def attributes
            self.class.attributes
          end

          # Decodes the Rex::Proto::Kerberos::Model::Element from the input. This
          # method has been designed to be overridden by subclasses.
          #
          # @raise [NoMethodError]
          def decode(input)
            raise ::NoMethodError, 'Method designed to be overridden'
          end

          # Encodes the Rex::Proto::Kerberos::Model::Element into an ASN.1 String. This
          # method has been designed to be overridden by subclasses.
          #
          # @raise [NoMethodError]
          def encode
            raise ::NoMethodError, 'Method designed to be overridden'
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rex-2.0.13 lib/rex/proto/kerberos/model/element.rb
rex-2.0.12 lib/rex/proto/kerberos/model/element.rb
rex-2.0.11 lib/rex/proto/kerberos/model/element.rb
rex-2.0.10 lib/rex/proto/kerberos/model/element.rb
rex-2.0.9 lib/rex/proto/kerberos/model/element.rb
rex-2.0.8 lib/rex/proto/kerberos/model/element.rb
rex-2.0.7 lib/rex/proto/kerberos/model/element.rb