public function import(array $users = array(), $realm = 'Restricted area')
    {
        //realm must be a string
        Argument::i()->test(2, 'string');
        
        $this->realm = $realm;
        $self = $this;
        
        return function (Registry $request, Registry $response) use ($users, $self) {
            //get digest
            $digest = $request->get('server', 'PHP_AUTH_DIGEST');
            
            //if no digest
            if (empty($digest)) {
                //this throws anyways
                return $self->dialog();
            }
            
            // analyze the PHP_AUTH_DIGEST variable
            $data = $self->digest($digest);
            
            //if no username
            if (!isset($users[$data['username']])) {
                //this throws anyways
                return $self->dialog();
            }
            
            // generate the valid response
            $signature = $self->getSignature($users, $data);
            
            //if it doesnt match
            if ($data['response'] !== $signature) {
                //this throws anyways
                return $self->dialog();
            }
        };
    }