# File lib/openid/message.rb, line 475
    def add_alias(namespace_uri, desired_alias, implicit=false)
      # Check that desired_alias is not an openid protocol field as
      # per the spec.
      Util.assert(!OPENID_PROTOCOL_FIELDS.include?(desired_alias),
             "#{desired_alias} is not an allowed namespace alias")

      # check that there is not a namespace already defined for the
      # desired alias
      current_namespace_uri = @alias_to_namespace.fetch(desired_alias, nil)
      if current_namespace_uri and current_namespace_uri != namespace_uri
        raise IndexError, "Cannot map #{namespace_uri} to alias #{desired_alias}. #{current_namespace_uri} is already mapped to alias #{desired_alias}"
      end

      # Check that desired_alias does not contain a period as per the
      # spec.
      if desired_alias.is_a?(String)
          Util.assert(desired_alias.index('.').nil?,
                 "#{desired_alias} must not contain a dot")
      end

      # check that there is not already a (different) alias for this
      # namespace URI.
      _alias = @namespace_to_alias[namespace_uri]
      if _alias and _alias != desired_alias
        raise IndexError, "Cannot map #{namespace_uri} to alias #{desired_alias}. It is already mapped to alias #{_alias}"
      end

      @alias_to_namespace[desired_alias] = namespace_uri
      @namespace_to_alias[namespace_uri] = desired_alias
      @implicit_namespaces << namespace_uri if implicit
      return desired_alias
    end