hi, i am trying to write a wrapper class for httpserv.
unfortunately i have problems implementing the digest auth.

function THttpConnection.AuthDigestGetParams always returns false here:

    t1 := EncodeTime(1, 0, 0, 0);
    t2 := Now;
    try
        LastTime := RFC822ToDateTime(Trim(Base64Decode(FAuthDigestNonce)));
    except
        Exit;
    end;

    if (LastTime + t1) > t2 then
        Result := TRUE;    // THAT IS NOT THE CASE IN MY CODE

what is happening here ? the overbyte example always returns true even
i dont find the difference.

my code:
constructor TmyWebServer.Create;
begin
  FSrv := THttpServer.Create(nil);
  FAuthPages := TAuthPages.Create;
  with FSrv do begin
    Port := inttostr(ListenPort);
    OnGetDocument := HttpServerOnGetDocument;
    OnPostDocument := HttpServerOnPostDocument;
    OnPostedData := HttpServerOnPostedData;
    OnAuthGetType := HttpServerOnAuthGetType;
    OnAuthGetPassword := HttpServerOnAuthGetPassword;
    ClientClass := TMyHttpConnection;
    Start;
  end;
end;

procedure TMyWebServer.HttpServerOnAuthGetType( Sender, Client: TObject);
var
  i : integer;
begin
  if (assigned(FAuthPages)) and (FAuthPages.Count > 0) then
    with TMyHttpConnection(Client) do
      for i := 0 to FAuthPages.Count - 1 do     // this checks if te
//      pageurl is saved in a list
        with FAuthPages.AsRecord(i) do
          if (CompareText (sPageUrl,Path) = 0) then
          begin
             AuthType := atDigest;
             AuthRealm := extractfilename(sPageUrl);
          end;
end;

procedure TmyWebServer.HttpServerOnAuthGetPassword(Sender: TObject; Client: 
TObject; var Password: String);
var
  i: integer;
begin
  // this proc is never cALLED
  if (assigned(FAuthPages)) and (FAuthPages.Count > 0) then
    with TMyHttpConnection(Client) do
      for i := 0 to FAuthPages.Count - 1 do
        with FAuthPages.AsRecord(i) do
          if (CompareText (sPageUrl,Path) = 0) then
            if (CompareText (sUser,AuthUserName) = 0) then
            begin
               password := sPassword;
               exit;
            end;
end;



-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to