Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/proto/kerberos/model/last_request.rb
Views: 11766
# -*- coding: binary -*-12module Rex3module Proto4module Kerberos5module Model6# This class provides a representation of request time7class LastRequest < Element89# @!attribute type10# @return [Integer] The type of value11attr_accessor :type12# @!attribute value13# @return [Time] the time of the last request14attr_accessor :value1516# Decodes a Rex::Proto::Kerberos::Model::LastRequest17#18# @param input [String, OpenSSL::ASN1::Sequence] the input to decode from19# @return [self] if decoding succeeds20# @raise [Rex::Proto::Kerberos::Model::Error::KerberosDecodingError] if decoding doesn't succeed21def decode(input)22case input23when String24decode_string(input)25when OpenSSL::ASN1::Sequence26decode_asn1(input)27else28raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode LastRequest, invalid input'29end3031self32end3334# Rex::Proto::Kerberos::Model::LastRequest encoding isn't supported35#36# @raise [NotImplementedError]37def encode38raise ::NotImplementedError, 'LastRequest encoding not supported'39end4041private4243# Decodes a Rex::Proto::Kerberos::Model::LastReque from an String44#45# @param input [String] the input to decode from46def decode_string(input)47asn1 = OpenSSL::ASN1.decode(input)4849decode_asn1(asn1)50end5152# Decodes a Rex::Proto::Kerberos::Model::EncryptionKey from an53# OpenSSL::ASN1::Sequence54#55# @param input [OpenSSL::ASN1::Sequence] the input to decode from56def decode_asn1(input)57seq_values = input.value58self.type = decode_type(seq_values[0])59self.value = decode_value(seq_values[1])60end6162# Decodes the key_type from an OpenSSL::ASN1::ASN1Data63#64# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from65# @return [Integer]66def decode_type(input)67input.value[0].value.to_i68end6970# Decodes the value from an OpenSSL::ASN1::ASN1Data71#72# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from73# @return [Time]74def decode_value(input)75input.value[0].value76end77end78end79end80end81end828384