W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1999

Re: Doing basic authentication

From: Raffaele Sena <raff@nuvomedia.com>
Date: Thu, 17 Jun 1999 15:06:50 -0700
Message-ID: <005601beb90d$b33a2c00$52c0a8c0@nuvomedia.com>
To: "Marco Ariano" <marco.ariano@pipercreek.com>, <www-lib@w3.org>
> I'm writing a very simple HTTP 1.1 client Windows using libwww.  I need
> to handle basic authentication.  My app has no user interface and every
> request will have the same authentication.  After browsing through the
> code, documentation and examples, here's what I think I need to do.  I'd
> appreciate it very much if someone would let me know if I'm on the right
> track or way off base.
>
> I'm using a default profile so HTCredentialsFilter is registered for
> me.  I think all I need to do is call HTRequest_addCredentials() for
> every request.  I'll generate the arguments using code borrowed from
> BOOL basic_credentials() as found in HTAABrow.c.

Marco,

    I don't know if you are on the right track or not,
    but another thing you can do that can be a little easier is
    to declare your application as interactive, implement all the
    callbacks for user interaction as returning no data, and
    implemente the callback for the user and password request to
    return your fixed data.

    Here is a quick example for such a callback:

        PUBLIC BOOL prompt_callback (HTRequest * request, HTAlertOpcode op,
                       int msgnum, const char * dfault, void * input,
                       HTAlertPar * reply)
        {
            if (op == HT_A_USER_PW) {
                HTAlert_setReplyMessage(reply, my_user);
                HTAlert_setReplySecret(reply,  my_password);
                return YES;
            }

            /* we are really NOT that interactive */
            return NO;
        }

    And you can register the callback in your application initialization code:

        HTAlert_setInteractive(YES);
        HTAlert_add(prompt_callback, HT_A_CONFIRM);
        HTAlert_add(prompt_callback, HT_A_PROMPT);
        HTAlert_add(prompt_callback, HT_A_SECRET);
        HTAlert_add(prompt_callback, HT_A_USER_PW);

Hope this helps,

    Raffaele
Received on Thursday, 17 June 1999 18:05:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:29 GMT