Sha256: b2cfdaeec8262b9b2d8cc363306dd2bfb74f2fcd5333be6c06914a958c53d6c2

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

require 'swd'

module OpenIDConnect
  module Discovery
    class Principal
      attr_reader :identifier, :host

      def self.parse(identifier)
        raise InvalidIdentifier.new('Identifier Required') if identifier.blank?
        type = case identifier
        when /^(=|@|!)/
          XRI
        when /@/
          Email
        else
          URI
        end
        type.new identifier
      end

      def discover!
        SWD.discover!(
          :principal => identifier,
          :service => Provider::SERVICE_URI,
          :host => host
        )
      rescue SWD::Exception => e
        raise DiscoveryFailed.new(e.message)
      end
    end
  end
end

require 'openid_connect/discovery/principal/email'
require 'openid_connect/discovery/principal/uri'
require 'openid_connect/discovery/principal/xri'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openid_connect-0.0.14 lib/openid_connect/discovery/principal.rb