# File lib/openid/server.rb, line 620
      def sign(response)
        # get a deep copy of the response
        signed_response = Marshal.load(Marshal.dump(response))
        assoc_handle = response.request.assoc_handle

        if assoc_handle
          assoc = self.get_association(assoc_handle, false)
          unless assoc
            # no assoc for handle, fall back to dumb mode
            signed_response.fields['invalidate_handle'] = assoc_handle
            assoc = self.create_association(true)
          end
        else
          # dumb mode
          assoc = self.create_association(true)
        end
        
        signed_response.fields['assoc_handle'] = assoc.handle
        assoc.add_signature(signed_response.signed,
                            signed_response.fields, '')
        return signed_response
      end