# File lib/openid/server.rb, line 321
    def check_trust_root(args)
      return_to = args['openid.return_to']
      raise ArgumentError.new('no return_to specified') if return_to.nil?
      
      trust_root = args['openid.trust_root']

      # only check trust_root against return_to if one is given
      unless trust_root.nil?
        tr = OpenID::TrustRoot.parse(trust_root)
        
        if tr.nil?          
          raise ArgumentError, "Malformed trust root (#{trust_root})"
        end

        unless tr.validate_url(return_to)
          e = "return_to(#{return_to}) not valid" + \
          " against trust_root(#{trust_root})"
          raise ArgumentError, e
        end
      end

      return return_to
    end