Sha256: d8b081ca5359ab53d3b0a1e2c49faf02058f828df83164120c6b8db0448f8b27

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 Bytes

Contents

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

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

      def discover!(cache_options = {})
        SWD.discover!(
          :principal => identifier,
          :service => Provider::SERVICE_URI,
          :host => host,
          :port => port,
          :cache => cache_options
        )
      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'

Version data entries

1 entries across 1 versions & 1 rubygems

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