class SamlAuthenticatable::SamlMappedAttributes

Public Class Methods

new(attributes, attribute_map) click to toggle source
# File lib/devise_saml_authenticatable/saml_mapped_attributes.rb, line 3
def initialize(attributes, attribute_map)
  @attributes = attributes
  @attribute_map = attribute_map
end

Public Instance Methods

resource_keys() click to toggle source
# File lib/devise_saml_authenticatable/saml_mapped_attributes.rb, line 12
def resource_keys
  @attribute_map.values
end
saml_attribute_keys() click to toggle source
# File lib/devise_saml_authenticatable/saml_mapped_attributes.rb, line 8
def saml_attribute_keys
  @attribute_map.keys
end
value_by_resource_key(key) click to toggle source
# File lib/devise_saml_authenticatable/saml_mapped_attributes.rb, line 16
def value_by_resource_key(key)
  str_key = String(key)

  # Find all of the SAML attributes that map to the resource key
  attribute_map_for_key = @attribute_map.select { |_, resource_key| String(resource_key) == str_key }

  saml_value = nil

  # Find the first non-nil value
  attribute_map_for_key.each_key do |saml_key|
    saml_value = value_by_saml_attribute_key(saml_key)

    break unless saml_value.nil?
  end

  saml_value
end
value_by_saml_attribute_key(key) click to toggle source
# File lib/devise_saml_authenticatable/saml_mapped_attributes.rb, line 34
def value_by_saml_attribute_key(key)
  @attributes[String(key)]
end