protected function positiveResponse($identity, $attributes)
    {
        # We generate a private association if there is none established.
        if(!$this->assoc) {
            $this->generateAssociation();
            $this->assoc['private'] = true;
        }
        
        # We set openid.identity (and openid.claimed_id if necessary) to our $identity
        if($this->data['openid_identity'] == $this->data['openid_claimed_id'] || $this->select_id) {
            $this->data['openid_claimed_id'] = $identity;
        }
        $this->data['openid_identity'] = $identity;
        
        # Preparing fields to be signed
        $params = array(
            'op_endpoint'    => $this->serverLocation,
            'claimed_id'     => $this->data['openid_claimed_id'],
            'identity'       => $this->data['openid_identity'],
            'return_to'      => $this->data['openid_return_to'],
            'realm'          => $this->data['openid_realm'],
            'response_nonce' => gmdate("Y-m-d\TH:i:s\Z"),
            'assoc_handle'   => $this->assoc['handle'],
            );
        
        $params += $this->responseAttributes($attributes);
        
        # Has the RP used an invalid association handle?
        if (isset($this->data['openid_assoc_handle'])
            && $this->data['openid_assoc_handle'] != $this->assoc['handle']
        ) {
            $params['invalidate_handle'] = $this->data['openid_assoc_handle'];
        }
        
        # Signing the $params
        $sig = hash_hmac($this->assoc['hash'], $this->keyValueForm($params), $this->assoc['mac'], true);
        $req = array(
            'openid.mode'   => 'id_res',
            'openid.signed' => implode(',', array_keys($params)),
            'openid.sig'    => base64_encode($sig),
            );
        
        # Saving the nonce and commiting the association.
        $this->assoc['nonce'] = $params['response_nonce'];
        $this->setAssoc($this->assoc['handle'], $this->assoc);
        
        # Preparing and sending the response itself
        foreach($params as $name => $value) {
            $req['openid.' . $name] = $value;
        }
        
        $this->redirect($this->response($req));
    }