summaryrefslogtreecommitdiff
path: root/lib/nickserver/request_handlers/fingerprint_handler.rb
blob: ac3c3c83cfa04bda9f3498cbdbb49bd0f3309bf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'nickserver/request_handlers/base'
require 'nickserver/hkp/source'
require 'nickserver/error_response'

module Nickserver
  module RequestHandlers
    class FingerprintHandler < Base

      def handle
        return unless fingerprint
        if fingerprint.length == 40 && !fingerprint[/\H/]
          source.get_key_by_fingerprint(fingerprint)
        else
          ErrorResponse.new('Fingerprint invalid: ' + fingerprint)
        end
      end

      protected

      def fingerprint
        request.fingerprint
      end

      def source
        Nickserver::Hkp::Source.new adapter
      end

    end
  end
end