Class: OpenIDConnect::Discovery::Principal

Inherits:
Object
  • Object
show all
Defined in:
lib/openid_connect/discovery/principal.rb,
lib/openid_connect/discovery/principal/uri.rb,
lib/openid_connect/discovery/principal/xri.rb,
lib/openid_connect/discovery/principal/email.rb

Direct Known Subclasses

Email, URI, XRI

Defined Under Namespace

Classes: Email, URI, XRI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/openid_connect/discovery/principal.rb', line 4

def host
  @host
end

#identifierObject (readonly)

Returns the value of attribute identifier.



4
5
6
# File 'lib/openid_connect/discovery/principal.rb', line 4

def identifier
  @identifier
end

Class Method Details

.parse(identifier) ⇒ Object

Raises:



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/openid_connect/discovery/principal.rb', line 6

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

Instance Method Details

#discover!(cache_options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/openid_connect/discovery/principal.rb', line 19

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