Adding the authentication token stuff.
This commit is contained in:
		
							
								
								
									
										165
									
								
								include/casa_auth_token.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								include/casa_auth_token.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,165 @@ | |||||||
|  | /*********************************************************************** | ||||||
|  |  *  File: casa_auth_token.h | ||||||
|  |  *  Author: Juan Carlos Luciani (jluciani@novell.com) | ||||||
|  |  *  | ||||||
|  |  *  Abstract: Defines the interface between the authentication token | ||||||
|  |  *  module and its providers. | ||||||
|  |  *  | ||||||
|  |  *  Copyright (C) 2005 Novell, Inc. | ||||||
|  |  * | ||||||
|  |  *  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 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, write to the Free | ||||||
|  |  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||||
|  |  *  | ||||||
|  |  *  To contact Novell about this file by physical or electronic mail,  | ||||||
|  |  *  you may find current contact information at www.novell.com.  | ||||||
|  |  ***********************************************************************/ | ||||||
|  |  | ||||||
|  | #ifndef _CASA_AUTH_TOKEN_H_ | ||||||
|  | #define _CASA_AUTH_TOKEN_H_ | ||||||
|  |  | ||||||
|  | #if defined(__cplusplus) || defined(c_plusplus) | ||||||
|  | extern "C"  | ||||||
|  | { | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //===[ Include files ]===================================================== | ||||||
|  |  | ||||||
|  | #include <micasa_types.h> | ||||||
|  | #include <casa_status.h> | ||||||
|  |  | ||||||
|  | //===[ Type definitions ]================================================== | ||||||
|  |  | ||||||
|  | #ifndef SSCS_CALL | ||||||
|  | #if defined(WIN32) | ||||||
|  | #define SSCS_CALL __stdcall | ||||||
|  | #else | ||||||
|  | #define SSCS_CALL | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //===[ Function prototypes ]=============================================== | ||||||
|  |  | ||||||
|  | //===[ Global variables ]================================================== | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //++======================================================================= | ||||||
|  | extern CasaStatus SSCS_CALL | ||||||
|  | GetAuthTokenCredentials( | ||||||
|  |    IN       const char  *pServiceName, | ||||||
|  |    INOUT    const char  *pUserNameBuf, | ||||||
|  |    INOUT    int         *pUserNameBufLen, | ||||||
|  |    INOUT    const char  *pTokenBuf, | ||||||
|  |    INOUT    int         *pTokenBufLen); | ||||||
|  | // | ||||||
|  | // Arguments:   | ||||||
|  | //    pServiceName - | ||||||
|  | //       Pointer to NULL terminated string that contains the | ||||||
|  | //       name of the service to which the client is trying to | ||||||
|  | //       authenticate. | ||||||
|  | //                | ||||||
|  | //    pUserNameBuf - | ||||||
|  | //       Pointer to buffer that will receive a string with the | ||||||
|  | //       username that should used when authenticating to the | ||||||
|  | //       service. The length of this buffer is specified by the | ||||||
|  | //       pUserNameBufLen parameter. Note that the string | ||||||
|  | //       returned will be NULL terminated. | ||||||
|  | // | ||||||
|  | //    pUserNameBufLen - | ||||||
|  | //       Pointer to integer that contains the length of the | ||||||
|  | //       buffer pointed at by pUserNameBuf. Upon return of the | ||||||
|  | //       function, the integer will contain the actual length | ||||||
|  | //       of the username string (including the NULL terminator) | ||||||
|  | //       if the function successfully completes or the buffer | ||||||
|  | //       length required if the function fails because the buffer | ||||||
|  | //       pointed at by either pUserNameBuf or pTokenBuf is not | ||||||
|  | //       large enough. | ||||||
|  | //                | ||||||
|  | //    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 either pUserNameBuf | ||||||
|  | //       or pTokenBuf is not large enough. Please note that the | ||||||
|  | //       authentication token | ||||||
|  | //    | ||||||
|  | // Returns: | ||||||
|  | //    Casa Status | ||||||
|  | //                            | ||||||
|  | // Description: | ||||||
|  | //    Get authentication token credentials to authenticate user to specified | ||||||
|  | //    service. | ||||||
|  | //=======================================================================-- | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //++======================================================================= | ||||||
|  | extern CasaStatus SSCS_CALL | ||||||
|  | ValidateAuthTokenCredentials( | ||||||
|  |    IN       const char  *pServiceName, | ||||||
|  |    IN       const char  *pUserName, | ||||||
|  |    IN       const int   userNameLen, | ||||||
|  |    IN       const char  *pTokenBuf, | ||||||
|  |    IN       const int   tokenBufLen); | ||||||
|  | // | ||||||
|  | // Arguments:   | ||||||
|  | //    pServiceName - | ||||||
|  | //       Pointer to NULL terminated string that contains the | ||||||
|  | //       name of the service to which the client is trying to | ||||||
|  | //       authenticate. | ||||||
|  | //                | ||||||
|  | //    pUserName - | ||||||
|  | //       Pointer to string with the username that is being | ||||||
|  | //       authenticated to the service. The length of the name | ||||||
|  | //       is specified by the pUserNameLen parameter. Note that | ||||||
|  | //       the string does not need to be NULL terminated. | ||||||
|  | // | ||||||
|  | //    userNameLen - | ||||||
|  | //       Length of the user name contained within the buffer | ||||||
|  | //       pointed at by pUserNameBuf (Does not include the NULL | ||||||
|  | //       terminator). If this parameter is set to -1 then the | ||||||
|  | //       function assumes that the username string is NULL | ||||||
|  | //       terminated. | ||||||
|  | //                | ||||||
|  | //    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. | ||||||
|  | // | ||||||
|  | //    tokenBufLen - | ||||||
|  | //       Length of the data contained within the buffer pointed | ||||||
|  | //       at by pTokenBuf. | ||||||
|  | //    | ||||||
|  | // Returns: | ||||||
|  | //    Casa status. | ||||||
|  | //                            | ||||||
|  | // Description: | ||||||
|  | //    Validates authentication token credentials. | ||||||
|  | // | ||||||
|  | //=======================================================================-- | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #if defined(__cplusplus) || defined(c_plusplus) | ||||||
|  | } | ||||||
|  | #endif // #if defined(__cplusplus) || defined(c_plusplus) | ||||||
|  |  | ||||||
|  | #endif // #ifndef _CASA_AUTH_TOKEN_H_ | ||||||
|  |  | ||||||
							
								
								
									
										204
									
								
								include/casa_status.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										204
									
								
								include/casa_status.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,204 @@ | |||||||
|  | /*********************************************************************** | ||||||
|  |  *  File: casa_status.h | ||||||
|  |  *  | ||||||
|  |  *  Abstract: Defines the statuses used within CASA. | ||||||
|  |  *  | ||||||
|  |  *  Copyright (C) 2005 Novell, Inc. | ||||||
|  |  * | ||||||
|  |  *  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 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, write to the Free | ||||||
|  |  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||||||
|  |  *  | ||||||
|  |  *  To contact Novell about this file by physical or electronic mail,  | ||||||
|  |  *  you may find current contact information at www.novell.com.  | ||||||
|  |  ***********************************************************************/ | ||||||
|  |  | ||||||
|  | #ifndef _CASA_STATUS_H_ | ||||||
|  | #define _CASA_STATUS_H_ | ||||||
|  |  | ||||||
|  | #if defined(__cplusplus) || defined(c_plusplus) | ||||||
|  | extern "C"  | ||||||
|  | { | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | //===[ Header files specific to this module ]============================== | ||||||
|  |  | ||||||
|  | #include <micasa_types.h> | ||||||
|  |  | ||||||
|  | //===[ External data                        ]============================== | ||||||
|  |  | ||||||
|  | //===[ External prototypes                  ]============================== | ||||||
|  |  | ||||||
|  | //===[ Type definitions                     ]============================== | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // CasaStatus type | ||||||
|  | // | ||||||
|  | // | ||||||
|  | //  The layed out of status values is as follows: | ||||||
|  | // | ||||||
|  | //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 | ||||||
|  | //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 | ||||||
|  | //  +---+-+-+-+---------------------+-------------------------------+ | ||||||
|  | //  |Sev|r|r|r|   Facility          |                Code           | | ||||||
|  | //  +---+-+-+-+---------------------+-------------------------------+ | ||||||
|  | // | ||||||
|  | //  where | ||||||
|  | // | ||||||
|  | //      Sev - is the severity code | ||||||
|  | // | ||||||
|  | //          00 - Success | ||||||
|  | //          01 - Informational | ||||||
|  | //          10 - Warning | ||||||
|  | //          11 - Error | ||||||
|  | // | ||||||
|  | //      r - is a reserved bit for internal use | ||||||
|  | // | ||||||
|  | //      Facility - is the facility code | ||||||
|  | // | ||||||
|  | //      Code - is the facility's status code | ||||||
|  | // | ||||||
|  | typedef uint32_t CasaStatus; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //===[ Manifest constants                   ]============================== | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Define severity codes to be used with CasaStatusBuild macro | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define CASA_SEVERITY_SUCCESS            0x0 | ||||||
|  | #define CASA_SEVERITY_INFORMATIONAL      0x1 | ||||||
|  | #define CASA_SEVERITY_WARNING            0x2 | ||||||
|  | #define CASA_SEVERITY_ERROR              0x3 | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Define the facility codes | ||||||
|  | // | ||||||
|  | //      Facility codes will start at 0x800 and then work backwards | ||||||
|  | //      in an effort to avoid conflict with other system components. | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CASA_FACILITY_AUTHTOKEN                  0x7FF | ||||||
|  | #define  CASA_FACILITY_KRB5TOKEN                  0x7FE | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Codes above FACILITY_SPECIFIC are component specific status codes. | ||||||
|  | // Facility specific status codes are defined in the facilities' header file. | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define FACILITY_SPECIFIC                       0x00001000 | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Codes below FACILITY_SPECIFIC are common status codes shared by all components. | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define CASA_STATUS_SUCCESS                    ((CasaStatus)0x00000000)     // Call completed successfully | ||||||
|  | #define CASA_STATUS_UNSUCCESSFUL               ((CasaStatus)0x00000001)     // Call completed unsuccessfully | ||||||
|  | #define CASA_STATUS_INVALID_HANDLE             ((CasaStatus)0x00000002)     // An invalid handle was specified | ||||||
|  | #define CASA_STATUS_INVALID_PARAMETER          ((CasaStatus)0x00000003)     // An invalid parameter to function was specified | ||||||
|  | #define CASA_STATUS_INSUFFICIENT_RESOURCES     ((CasaStatus)0x00000004) | ||||||
|  | #define CASA_STATUS_ACCESS_DENIED              ((CasaStatus)0x00000005)     // Caller does not have required access rights for operation | ||||||
|  | #define CASA_STATUS_BUFFER_OVERFLOW            ((CasaStatus)0x00000006)     // The data was too large to fit into the specified buffer | ||||||
|  | #define CASA_STATUS_NO_DATA                    ((CasaStatus)0x00000007) | ||||||
|  | #define CASA_STATUS_NO_MORE_ENTRIES            ((CasaStatus)0x00000008)     // No more entries to enumerate | ||||||
|  | #define CASA_STATUS_TIMEOUT                    ((CasaStatus)0x00000009)     // Timed out waiting on resource | ||||||
|  | #define CASA_STATUS_OBJECT_NOT_FOUND           ((CasaStatus)0x0000000A) | ||||||
|  | #define CASA_STATUS_CANCELLED                  ((CasaStatus)0x0000000B)     // Request cancelled | ||||||
|  | #define CASA_STATUS_NOT_IMPLEMENTED            ((CasaStatus)0x0000000C) | ||||||
|  | #define CASA_STATUS_PENDING                    ((CasaStatus)0x0000000D)     // The request is being processed | ||||||
|  | #define CASA_STATUS_INVALID_STATE              ((CasaStatus)0x0000000E) | ||||||
|  | #define CASA_STATUS_INVALID_REQUEST            ((CasaStatus)0x0000000F) | ||||||
|  | #define CASA_STATUS_ALREADY_REGISTERED         ((CasaStatus)0x00000010) | ||||||
|  | #define CASA_STATUS_ABORTED                    ((CasaStatus)0x00000011) | ||||||
|  | #define CASA_STATUS_REQUEST_NOT_FOUND          ((CasaStatus)0x00000012)     // Unable to cancel request because it was not found | ||||||
|  | #define CASA_STATUS_OBJECT_ALREADY_EXISTS      ((CasaStatus)0x00000013)     // The object being created already exists. | ||||||
|  | #define CASA_STATUS_UNSUPPORTED_PROTOCOL       ((CasaStatus)0x00000014)     // The object is only accessable through a unsupported protocol. | ||||||
|  | #define CASA_STATUS_REJECTED                   ((CasaStatus)0x00000015) | ||||||
|  | #define CASA_STATUS_ACCESS_VIOLATION           ((CasaStatus)0x00000016) | ||||||
|  | #define CASA_STATUS_NOT_SUPPORTED              ((CasaStatus)0x00000017) | ||||||
|  | #define CASA_STATUS_NO_PROVIDERS               ((CasaStatus)0x00000018)     // No providers are available. | ||||||
|  | #define CASA_STATUS_CONFLICT                   ((CasaStatus)0x00000019) | ||||||
|  | #define CASA_STATUS_INSUFFICIENT_STORAGE       ((CasaStatus)0x0000001A) | ||||||
|  | #define CASA_STATUS_AUTHENTICATION_FAILURE     ((CasaStatus)0x0000001B) | ||||||
|  | #define CASA_STATUS_CONFIGURATION_ERROR        ((CasaStatus)0x0000001C) | ||||||
|  | #define CASA_STATUS_LIBRARY_LOAD_FAILURE       ((CasaStatus)0x0000001D) | ||||||
|  |  | ||||||
|  | //===[ Macro definitions                    ]============================== | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for building status error codes | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CasaStatusBuild(severity, facility, errorcode) \ | ||||||
|  |          ((CasaStatus)(((severity) << 30) | ((facility) << 16) | (errorcode))) | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for retrieving the facility | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CasaStatusFacility(status) \ | ||||||
|  |          ((CasaStatus)(((CasaStatus)(status) >> 16) & (CasaStatus)0x07FF)) | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for retrieving severity | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CasaStatusSeverity(status) \ | ||||||
|  |          ((CasaStatus)(((CasaStatus)(status)) >> 30)) | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for retrieving status code | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CasaStatusCode(status) \ | ||||||
|  |          ((CasaStatus)((CasaStatus)(status) & (CasaStatus)0x0000FFFF)) | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for checking status code for success | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CASA_SUCCESS(status) \ | ||||||
|  |          ((CasaStatus)(status) >> 30 != CASA_SEVERITY_ERROR) | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for checking status code for information | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CASA_INFORMATION(status) \ | ||||||
|  |          ((CasaStatus)(status) >> 30 == CASA_SEVERITY_INFORMATIONAL) | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for checking status code for warning | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CASA_WARNING(status) \ | ||||||
|  |          ((CasaStatus)(status) >> 30 == CASA_SEVERITY_WARNING) | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Macro for checking status code for error | ||||||
|  | // | ||||||
|  |  | ||||||
|  | #define  CASA_ERROR(status) \ | ||||||
|  |          ((CasaStatus)(status) >> 30 == CASA_SEVERITY_ERROR) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | //===[ Function Prototypes                  ]============================== | ||||||
|  |  | ||||||
|  | //===[ Global Variables                     ]============================== | ||||||
|  |  | ||||||
|  | #endif // _CASA_STATUS_H_ | ||||||
|  |  | ||||||
|  | //========================================================================= | ||||||
|  | //========================================================================= | ||||||
|  | // casa_status.h | ||||||
		Reference in New Issue
	
	Block a user