/***********************************************************************
 * 
 *  Copyright (C) 2006 Novell, Inc. All Rights Reserved.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; version 2.1
 *  of the License.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, Novell, Inc.
 * 
 *  To contact Novell about this file by physical or electronic mail, 
 *  you may find current contact information at www.novell.com.
 * 
 *  Author: Juan Carlos Luciani <jluciani@novell.com>
 *
 ***********************************************************************/


#ifndef _MECH_IF_H_
#define _MECH_IF_H_


//===[ Include files ]=====================================================

//===[ Type definitions ]==================================================

//===[ Function prototypes ]===============================================

//===[ Global variables ]==================================================

/**************************************************************************
***************************************************************************
**                                                                       **
**    Definitions common to all interfaces                               **
**                                                                       **
***************************************************************************
**************************************************************************/


//++=======================================================================
typedef
int       
(SSCS_CALL *PFN_AddReference)(
   IN       const void  *pIfInstance);
//
// Arguments:  
//    pIfInstance -
//       Pointer to interface object.
//   
// Returns:
//    Interface reference count.
//                           
// Description:
//    Increases interface reference count.
//=======================================================================--


//++=======================================================================
typedef
void       
(SSCS_CALL *PFN_ReleaseReference)(
   IN       const void  *pIfInstance);
//
// Arguments:  
//    pIfInstance -
//       Pointer to interface object.
//   
// Returns:
//    Nothing.
//                           
// Description:
//    Decreases interface reference count. The interface is deallocated if
//    the reference count becomes zero.
//=======================================================================--



/**************************************************************************
***************************************************************************
**                                                                       **
**    Configuration Object Interface Definitions                         **
**                                                                       **
***************************************************************************
**************************************************************************/


//++=======================================================================
typedef
char*
(SSCS_CALL *PFN_GetEntryValue)(
   IN       const void  *pIfInstance,
   IN       const char  *pKeyName);
//
// Arguments:  
//    pIfInstance -
//       Pointer to interface object.
//   
//    pKeyName -
//       Pointer to NULL terminated string that contains the
//       name of the key whose value is being requested.
//               
// Returns:
//    Pointer to NULL terminated string with value being requested or NULL.
//                           
// Description:
//    Gets value associated with a key for the configuration object.
//=======================================================================--


//
// Config Interface Object
// 
typedef struct _ConfigIf
{
   PFN_AddReference                    addReference;
   PFN_ReleaseReference                releaseReference;
   PFN_GetEntryValue                   getEntryValue;

} ConfigIf, *PConfigIf;



/**************************************************************************
***************************************************************************
**                                                                       **
**    Authentication Mechanism Token Interface Definitions               **
**                                                                       **
***************************************************************************
**************************************************************************/


//++=======================================================================
typedef
CasaStatus 
(SSCS_CALL *PFN_GetAuthToken)(
   IN       const void        *pIfInstance,
   IN       const char        *pContext,
   IN       const char        *pMechInfo,
   INOUT    char              *pTokenBuf,
   INOUT    int               *pTokenBufLen);
//
// Arguments:  
//    pIfInstance -
//       Pointer to interface object.
//   
//    pServiceConfigIf -
//       Pointer to service config object to which the client is trying to
//       authenticate.
//               
//    pContext -
//       Pointer to null terminated string containing mechanism specific
//       context information. Another name for context is Authentication
//       Realm.
//
//    pMechInfo -
//       Pointer to null terminated string containing mechanism specific
//       information. This is information is provided by the server to
//       aid the mechanism to generate an authentication token. For
//       example, the mechanism information for a Kerberos mechanism
//       may be the service principal name to which the user will be
//       authenticating.
//               
//    pTokenBuf -
//       Pointer to buffer that will receive the authentication
//       token. The length of this buffer is specified by the
//       pTokenBufLen parameter. Note that the the authentication
//       token will be in the form of a NULL terminated string.
//
//    pTokenBufLen -
//       Pointer to integer that contains the length of the
//       buffer pointed at by pTokenBuf. Upon return of the
//       function, the integer will contain the actual length
//       of the authentication token if the function successfully
//       completes or the buffer length required if the function
//       fails because the buffer pointed at by pUserNameBuf is
//       not large enough.
//   
// Returns:
//    Casa Status
//                           
// Description:
//    Get authentication token to authenticate user to specified service.
//=======================================================================--


//
// AuthMechToken Interface Object
// 
typedef struct _AuthTokenIf
{
   PFN_AddReference                    addReference;
   PFN_ReleaseReference                releaseReference;
   PFN_GetAuthToken                    getAuthToken;

} AuthTokenIf, *PAuthTokenIf;


//++=======================================================================
typedef
CasaStatus
(SSCS_CALL *PFN_GetAuthTokenIfRtn)(
   IN       const ConfigIf    *pModuleConfigIf,
   INOUT    AuthTokenIf       **ppAuthTokenIf);
//
// Arguments:  
//    pModuleConfigIf -
//       Pointer to configuration interface instance for the module.
//               
//    ppAuthTokenIf -
//       Pointer to variable that will receive pointer to AuthTokenIf
//       instance.
//
// Returns:
//    Casa Status
//                           
// Description:
//    Gets authentication token interface instance.
//=======================================================================--

#define GET_AUTH_TOKEN_INTERFACE_RTN_SYMBOL  "GetAuthTokenInterface"
#define GET_AUTH_TOKEN_INTERFACE_RTN         GetAuthTokenInterface


#endif // #ifndef _MECH_IF_H_