/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/
#ifndef XPTAUTH_H
#define XPTAUTH_H

#include "xpttypes.h"

#define MAX_DIGEST_SIZE 80
#define MAX_REALM_SIZE	80
#define MAX_NONCE_SIZE	65
#define MAX_USER_SIZE	32
#define MAX_PWD_SIZE	32
#define MAX_CNONCE_SIZE 10
#define MAX_NC_SIZE	10
#define MAX_QOP_SIZE	10
#define MAX_OPAQUE_SIZE 32
#define MAX_DOMAIN_SIZE 256

/********************************************************/
/* Authentication info, Basic and Digest authentication */
/********************************************************/
typedef enum
	 {
	 AUTH_NONE = 0,
	 AUTH_BASIC = 1,
	 AUTH_DIGEST = 2
	 } HttpAuthenticationType_t;	    // required authentication

typedef enum
	 {
	 DEST_NONE = 0,
	 DEST_SERVER = 1,
	 DEST_PROXY  = 2
	 } HttpAuthenticationDest_t;	    // authentication destination

typedef struct
   {
   int cbSize;
   CString_t szUser;
   CString_t szPassword;
   CString_t szRealm;
   CString_t szCNonce;
   CString_t szNC;
   } HttpAuthenticationUserData_t, *HttpAuthenticationUserDataPtr_t;


typedef struct
   {
   int cbSize;
   CString_t szNonce;
   CString_t szNC;
   CString_t szQop;
   } HttpAuthenticationInfo_t, *HttpAuthenticationInfoPtr_t;

typedef struct
   {
   int cbSize;
   CString_t szRealm;
   CString_t szNonce;
   CString_t szOpaque;
   CString_t szDomain;
   CString_t szQop;
   Bool_t    bStale;
   } HttpAuthenticationData_t, *HttpAuthenticationDataPtr_t;

typedef void * HttpAuthenticationPtr_t;

HttpAuthenticationPtr_t authInit (void);
void authTerminate (HttpAuthenticationPtr_t auth);

Bool_t authSetDigest (HttpAuthenticationPtr_t auth,
		      HttpAuthenticationDest_t dest,
		      CString_t szDigest);
Bool_t authCalcDigest (HttpAuthenticationPtr_t auth,
		       HttpAuthenticationDest_t dest,
		       CString_t szURI,
		       CString_t szMode);
CString_t authGetDigest (HttpAuthenticationPtr_t auth,
			 HttpAuthenticationDest_t dest);

Bool_t authSetType (HttpAuthenticationPtr_t auth,
		    HttpAuthenticationDest_t dest,
		    HttpAuthenticationType_t type);
HttpAuthenticationType_t authGetType (HttpAuthenticationPtr_t auth,
				      HttpAuthenticationDest_t dest);


Bool_t authSetUserData (HttpAuthenticationPtr_t auth,
			HttpAuthenticationDest_t dest,
			HttpAuthenticationUserDataPtr_t pUserData);

Bool_t authGetUserData (HttpAuthenticationPtr_t auth,
			HttpAuthenticationDest_t dest,
			HttpAuthenticationUserDataPtr_t pUserData);

Bool_t authSetAuthenticationInfo (HttpAuthenticationPtr_t auth,
				  HttpAuthenticationDest_t dest,
				  HttpAuthenticationInfoPtr_t pAuthInfo);


Bool_t authSetAuthenticationData (HttpAuthenticationPtr_t auth,
				  HttpAuthenticationDest_t dest,
				  HttpAuthenticationDataPtr_t pAuthData);

Bool_t authGetAuthenticationData (HttpAuthenticationPtr_t auth,
				  HttpAuthenticationDest_t dest,
				  HttpAuthenticationDataPtr_t pAuthData);

#endif

/* eof */
