Sha256: 93acab7dadd390653c8dd291a3acd15615764c1034b69050f37523c28fe8ba6d

Contents?: true

Size: 1.2 KB

Versions: 12

Compression:

Stored size: 1.2 KB

Contents

class Acme::Client::Resources::Authorization
  HTTP01 = Acme::Client::Resources::Challenges::HTTP01
  DNS01 = Acme::Client::Resources::Challenges::DNS01
  TLSSNI01 = Acme::Client::Resources::Challenges::TLSSNI01

  attr_reader :client, :uri, :domain, :status, :expires, :http01, :dns01, :tls_sni01

  def initialize(client, uri, response)
    @client = client
    @uri = uri
    assign_attributes(response.body)
  end

  def verify_status
    response = @client.connection.get(@uri)

    assign_attributes(response.body)
    status
  end

  private

  def assign_attributes(body)
    @expires = Time.iso8601(body['expires']) if body.key? 'expires'
    @domain = body['identifier']['value']
    @status = body['status']
    assign_challenges(body['challenges'])
  end

  def assign_challenges(challenges)
    challenges.each do |attributes|
      challenge = case attributes.fetch('type')
                  when 'http-01'
                    @http01 ||= HTTP01.new(self)
                  when 'dns-01'
                    @dns01 ||= DNS01.new(self)
                  when 'tls-sni-01'
                    @tls_sni01 ||= TLSSNI01.new(self)
      end

      challenge.assign_attributes(attributes) if challenge
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
acme-client-1.0.0 lib/acme/client/resources/authorization.rb
acme-client-0.6.3 lib/acme/client/resources/authorization.rb
acme-client-0.6.2 lib/acme/client/resources/authorization.rb
acme-client-0.6.1 lib/acme/client/resources/authorization.rb
acme-client-0.6.0 lib/acme/client/resources/authorization.rb
acme-client-0.5.5 lib/acme/client/resources/authorization.rb
acme-client-0.5.4 lib/acme/client/resources/authorization.rb
acme-client-0.5.3 lib/acme/client/resources/authorization.rb
acme-client-0.5.2 lib/acme/client/resources/authorization.rb
acme-client-0.5.1 lib/acme/client/resources/authorization.rb
acme-client-0.5.0 lib/acme/client/resources/authorization.rb
leap_cli-1.9 vendor/acme-client/lib/acme/client/resources/authorization.rb