1*7f2fe78bSCy Schubert /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2*7f2fe78bSCy Schubert /* include/CredentialsCache.h */ 3*7f2fe78bSCy Schubert /* 4*7f2fe78bSCy Schubert * Copyright 1998-2006 Massachusetts Institute of Technology. 5*7f2fe78bSCy Schubert * All Rights Reserved. 6*7f2fe78bSCy Schubert * 7*7f2fe78bSCy Schubert * Export of this software from the United States of America may 8*7f2fe78bSCy Schubert * require a specific license from the United States Government. 9*7f2fe78bSCy Schubert * It is the responsibility of any person or organization contemplating 10*7f2fe78bSCy Schubert * export to obtain such a license before exporting. 11*7f2fe78bSCy Schubert * 12*7f2fe78bSCy Schubert * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 13*7f2fe78bSCy Schubert * distribute this software and its documentation for any purpose and 14*7f2fe78bSCy Schubert * without fee is hereby granted, provided that the above copyright 15*7f2fe78bSCy Schubert * notice appear in all copies and that both that copyright notice and 16*7f2fe78bSCy Schubert * this permission notice appear in supporting documentation, and that 17*7f2fe78bSCy Schubert * the name of M.I.T. not be used in advertising or publicity pertaining 18*7f2fe78bSCy Schubert * to distribution of the software without specific, written prior 19*7f2fe78bSCy Schubert * permission. Furthermore if you modify this software you must label 20*7f2fe78bSCy Schubert * your software as modified software and not distribute it in such a 21*7f2fe78bSCy Schubert * fashion that it might be confused with the original M.I.T. software. 22*7f2fe78bSCy Schubert * M.I.T. makes no representations about the suitability of 23*7f2fe78bSCy Schubert * this software for any purpose. It is provided "as is" without express 24*7f2fe78bSCy Schubert * or implied warranty. 25*7f2fe78bSCy Schubert */ 26*7f2fe78bSCy Schubert 27*7f2fe78bSCy Schubert #ifndef __CREDENTIALSCACHE__ 28*7f2fe78bSCy Schubert #define __CREDENTIALSCACHE__ 29*7f2fe78bSCy Schubert 30*7f2fe78bSCy Schubert #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) 31*7f2fe78bSCy Schubert #include <TargetConditionals.h> 32*7f2fe78bSCy Schubert 33*7f2fe78bSCy Schubert /* Notifications which are sent when the ccache collection or a ccache change. 34*7f2fe78bSCy Schubert * Notifications are sent to the distributed notification center. 35*7f2fe78bSCy Schubert * The object for kCCAPICacheCollectionChangedNotification is NULL. 36*7f2fe78bSCy Schubert * The object for kCCAPICCacheChangedNotification is a CFString containing the 37*7f2fe78bSCy Schubert * name of the ccache. 38*7f2fe78bSCy Schubert * 39*7f2fe78bSCy Schubert * Note: Notifications are not sent if the CCacheServer crashes. */ 40*7f2fe78bSCy Schubert #define kCCAPICacheCollectionChangedNotification CFSTR ("CCAPICacheCollectionChangedNotification") 41*7f2fe78bSCy Schubert #define kCCAPICCacheChangedNotification CFSTR ("CCAPICCacheChangedNotification") 42*7f2fe78bSCy Schubert #endif 43*7f2fe78bSCy Schubert 44*7f2fe78bSCy Schubert #if defined(_WIN32) 45*7f2fe78bSCy Schubert #include <winsock.h> 46*7f2fe78bSCy Schubert #include "win-mac.h" 47*7f2fe78bSCy Schubert #else 48*7f2fe78bSCy Schubert #include <stdint.h> 49*7f2fe78bSCy Schubert #endif 50*7f2fe78bSCy Schubert 51*7f2fe78bSCy Schubert #ifdef __cplusplus 52*7f2fe78bSCy Schubert extern "C" { 53*7f2fe78bSCy Schubert #endif /* __cplusplus */ 54*7f2fe78bSCy Schubert 55*7f2fe78bSCy Schubert #if defined(__APPLE__) && (defined(__ppc__) || defined(__ppc64__) || defined(__i386__) || defined(__x86_64__)) 56*7f2fe78bSCy Schubert #pragma pack(push,2) 57*7f2fe78bSCy Schubert #endif 58*7f2fe78bSCy Schubert 59*7f2fe78bSCy Schubert #if defined(_WIN32) 60*7f2fe78bSCy Schubert #define CCACHE_API __declspec(dllexport) 61*7f2fe78bSCy Schubert 62*7f2fe78bSCy Schubert #if _INTEGRAL_MAX_BITS >= 64 && _MSC_VER >= 1500 && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T) 63*7f2fe78bSCy Schubert #if defined(_TIME_T_DEFINED) || defined(_INC_IO) || defined(_INC_TIME) || defined(_INC_WCHAR) 64*7f2fe78bSCy Schubert #error time_t has been defined as a 64-bit integer which is incompatible with Kerberos on this platform. 65*7f2fe78bSCy Schubert #endif /* _TIME_T_DEFINED */ 66*7f2fe78bSCy Schubert #define _USE_32BIT_TIME_T 67*7f2fe78bSCy Schubert #endif 68*7f2fe78bSCy Schubert #else 69*7f2fe78bSCy Schubert #define CCACHE_API 70*7f2fe78bSCy Schubert #endif 71*7f2fe78bSCy Schubert 72*7f2fe78bSCy Schubert /*! 73*7f2fe78bSCy Schubert * \mainpage Credentials Cache API (CCAPI) Documentation 74*7f2fe78bSCy Schubert * 75*7f2fe78bSCy Schubert * \section toc Table of Contents 76*7f2fe78bSCy Schubert * 77*7f2fe78bSCy Schubert * \li \ref introduction 78*7f2fe78bSCy Schubert * \li \ref error_handling 79*7f2fe78bSCy Schubert * \li \ref synchronization_atomicity 80*7f2fe78bSCy Schubert * \li \ref memory_management 81*7f2fe78bSCy Schubert * \li \ref opaque_types 82*7f2fe78bSCy Schubert * 83*7f2fe78bSCy Schubert * \li \ref ccapi_constants_reference 84*7f2fe78bSCy Schubert * \li \ref ccapi_types_reference 85*7f2fe78bSCy Schubert * 86*7f2fe78bSCy Schubert * \li \ref cc_context_reference 87*7f2fe78bSCy Schubert * \li \ref cc_context_f "cc_context_t Functions" 88*7f2fe78bSCy Schubert * 89*7f2fe78bSCy Schubert * \li \ref cc_ccache_reference 90*7f2fe78bSCy Schubert * \li \ref cc_ccache_f "cc_ccache_t Functions" 91*7f2fe78bSCy Schubert * 92*7f2fe78bSCy Schubert * \li \ref cc_credentials_reference 93*7f2fe78bSCy Schubert * \li \ref cc_credentials_f "cc_credentials_t Functions" 94*7f2fe78bSCy Schubert * 95*7f2fe78bSCy Schubert * \li \ref cc_ccache_iterator_reference 96*7f2fe78bSCy Schubert * \li \ref cc_ccache_iterator_f "cc_ccache_iterator_t Functions" 97*7f2fe78bSCy Schubert * 98*7f2fe78bSCy Schubert * \li \ref cc_credentials_iterator_reference 99*7f2fe78bSCy Schubert * \li \ref cc_credentials_iterator_f "cc_credentials_iterator_t Functions" 100*7f2fe78bSCy Schubert * 101*7f2fe78bSCy Schubert * \li \ref cc_string_reference 102*7f2fe78bSCy Schubert * \li \ref cc_string_f "cc_string_t Functions" 103*7f2fe78bSCy Schubert * 104*7f2fe78bSCy Schubert * \section introduction Introduction 105*7f2fe78bSCy Schubert * 106*7f2fe78bSCy Schubert * This is the specification for an API which provides Credentials Cache 107*7f2fe78bSCy Schubert * services for Kerberos v5 (and previously v4). The idea behind this API is 108*7f2fe78bSCy Schubert * that multiple Kerberos implementations can share a single collection of 109*7f2fe78bSCy Schubert * credentials caches, mediated by this API specification. On the Mac OS and 110*7f2fe78bSCy Schubert * Microsoft Windows platforms this will allow single-login, even when more 111*7f2fe78bSCy Schubert * than one Kerberos shared library is in use on a particular system. 112*7f2fe78bSCy Schubert * 113*7f2fe78bSCy Schubert * Abstractly, a credentials cache collection contains one or more credentials 114*7f2fe78bSCy Schubert * caches, or ccaches. A ccache is uniquely identified by its name, which is 115*7f2fe78bSCy Schubert * a string internal to the API and not intended to be presented to users. 116*7f2fe78bSCy Schubert * The user presentable identifier of a ccache is its principal. 117*7f2fe78bSCy Schubert * 118*7f2fe78bSCy Schubert * Unlike the previous versions of the API, version 3 of the API could store 119*7f2fe78bSCy Schubert * credentials for multiple Kerberos versions in the same ccache. 120*7f2fe78bSCy Schubert * 121*7f2fe78bSCy Schubert * At any given time, one ccache is the "default" ccache. The exact meaning 122*7f2fe78bSCy Schubert * of a default ccache is OS-specific; refer to implementation requirements 123*7f2fe78bSCy Schubert * for details. 124*7f2fe78bSCy Schubert * 125*7f2fe78bSCy Schubert * \section error_handling Error Handling 126*7f2fe78bSCy Schubert * 127*7f2fe78bSCy Schubert * All functions of the API return some of the error constants listed FIXME; 128*7f2fe78bSCy Schubert * the exact list of error constants returned by any API function is provided 129*7f2fe78bSCy Schubert * in the function descriptions below. 130*7f2fe78bSCy Schubert * 131*7f2fe78bSCy Schubert * When returning an error constant other than ccNoError or ccIteratorEnd, API 132*7f2fe78bSCy Schubert * functions never modify any of the values passed in by reference. 133*7f2fe78bSCy Schubert * 134*7f2fe78bSCy Schubert * \section synchronization_atomicity Synchronization and Atomicity 135*7f2fe78bSCy Schubert * 136*7f2fe78bSCy Schubert * Every function in the API is atomic. In order to make a series of calls 137*7f2fe78bSCy Schubert * atomic, callers should lock the ccache or cache collection they are working 138*7f2fe78bSCy Schubert * with to advise other callers not to modify that container. Note that 139*7f2fe78bSCy Schubert * advisory locks are per container so even if you have a read lock on the cache 140*7f2fe78bSCy Schubert * collection other callers can obtain write locks on ccaches in that cache 141*7f2fe78bSCy Schubert * collection. 142*7f2fe78bSCy Schubert * 143*7f2fe78bSCy Schubert * Note that iterators do not iterate over ccaches and credentials atomically 144*7f2fe78bSCy Schubert * because locking ccaches and the cache collection over every iteration would 145*7f2fe78bSCy Schubert * degrade performance considerably under high load. However, iterators do 146*7f2fe78bSCy Schubert * guarantee a consistent view of items they are iterating over. Iterators 147*7f2fe78bSCy Schubert * will never return duplicate entries or skip entries when items are removed 148*7f2fe78bSCy Schubert * or added to the container they are iterating over. 149*7f2fe78bSCy Schubert * 150*7f2fe78bSCy Schubert * An application can always lock a ccache or the cache collection to guarantee 151*7f2fe78bSCy Schubert * that other callers participating in the advisory locking system do not 152*7f2fe78bSCy Schubert * modify the ccache or cache collection. 153*7f2fe78bSCy Schubert * 154*7f2fe78bSCy Schubert * Implementations should not use copy-on-write techniques to implement locks 155*7f2fe78bSCy Schubert * because those techniques imply that same parts of the ccache collection 156*7f2fe78bSCy Schubert * remain visible to some callers even though they are not present in the 157*7f2fe78bSCy Schubert * collection, which is a potential security risk. For example, a copy-on-write 158*7f2fe78bSCy Schubert * technique might make a copy of the entire collection when a read lock is 159*7f2fe78bSCy Schubert * acquired, so as to allow the owner of the lock to access the collection in 160*7f2fe78bSCy Schubert * an apparently unmodified state, while also allowing others to make 161*7f2fe78bSCy Schubert * modifications to the collection. However, this would also enable the owner 162*7f2fe78bSCy Schubert * of the lock to indefinitely (until the expiration time) use credentials that 163*7f2fe78bSCy Schubert * have actually been deleted from the collection. 164*7f2fe78bSCy Schubert * 165*7f2fe78bSCy Schubert * \section memory_management Object Memory Management 166*7f2fe78bSCy Schubert * 167*7f2fe78bSCy Schubert * The lifetime of an object returned by the API is until release() is called 168*7f2fe78bSCy Schubert * for it. Releasing one object has no effect on existence of any other object. 169*7f2fe78bSCy Schubert * For example, a ccache obtained within a context continue to exist when the 170*7f2fe78bSCy Schubert * context is released. 171*7f2fe78bSCy Schubert * 172*7f2fe78bSCy Schubert * Every object returned by the API (cc_context_t, cc_ccache_t, cc_ccache_iterator_t, 173*7f2fe78bSCy Schubert * cc_credentials_t, cc_credentials_iterator_t, cc_string_t) is owned by the 174*7f2fe78bSCy Schubert * caller of the API, and it is the responsibility of the caller to call release() 175*7f2fe78bSCy Schubert * for every object to prevent memory leaks. 176*7f2fe78bSCy Schubert * 177*7f2fe78bSCy Schubert * \section opaque_types Opaque Types 178*7f2fe78bSCy Schubert * 179*7f2fe78bSCy Schubert * All of the opaque high-level types in CCache API are implemented as structures 180*7f2fe78bSCy Schubert * of function pointers and private data. To perform some operation on a type, the 181*7f2fe78bSCy Schubert * caller of the API has to first obtain an instance of that type, and then call the 182*7f2fe78bSCy Schubert * appropriate function pointer from that instance. For example, to call 183*7f2fe78bSCy Schubert * get_change_time() on a cc_context_t, one would call cc_initialize() which creates 184*7f2fe78bSCy Schubert * a new cc_context_t and then call its get_change_time(), like this: 185*7f2fe78bSCy Schubert * 186*7f2fe78bSCy Schubert * \code 187*7f2fe78bSCy Schubert * cc_context_t context; 188*7f2fe78bSCy Schubert * cc_int32 err = cc_initialize (&context, ccapi_version_3, nil, nil); 189*7f2fe78bSCy Schubert * if (err == ccNoError) 190*7f2fe78bSCy Schubert * time = context->functions->get_change_time (context) 191*7f2fe78bSCy Schubert * \endcode 192*7f2fe78bSCy Schubert * 193*7f2fe78bSCy Schubert * All API functions also have convenience preprocessor macros, which make the API 194*7f2fe78bSCy Schubert * seem completely function-based. For example, cc_context_get_change_time 195*7f2fe78bSCy Schubert * (context, time) is equivalent to context->functions->get_change_time 196*7f2fe78bSCy Schubert * (context, time). The convenience macros follow the following naming convention: 197*7f2fe78bSCy Schubert * 198*7f2fe78bSCy Schubert * The API function some_function() 199*7f2fe78bSCy Schubert * \code 200*7f2fe78bSCy Schubert * cc_type_t an_object; 201*7f2fe78bSCy Schubert * result = an_object->functions->some_function (opaque_pointer, args) 202*7f2fe78bSCy Schubert * \endcode 203*7f2fe78bSCy Schubert * 204*7f2fe78bSCy Schubert * has an equivalent convenience macro of the form cc_type_some_function(): 205*7f2fe78bSCy Schubert * \code 206*7f2fe78bSCy Schubert * cc_type_t an_object; 207*7f2fe78bSCy Schubert * result = cc_type_some_function (an_object, args) 208*7f2fe78bSCy Schubert * \endcode 209*7f2fe78bSCy Schubert * 210*7f2fe78bSCy Schubert * The specifications below include the names for both the functions and the 211*7f2fe78bSCy Schubert * convenience macros, in that order. For clarity, it is recommended that clients 212*7f2fe78bSCy Schubert * using the API use the convenience macros, but that is merely a stylistic choice. 213*7f2fe78bSCy Schubert * 214*7f2fe78bSCy Schubert * Implementing the API in this manner allows us to extend and change the interface 215*7f2fe78bSCy Schubert * in the future, while preserving compatibility with older clients. 216*7f2fe78bSCy Schubert * 217*7f2fe78bSCy Schubert * For example, consider the case when the signature or the semantics of a cc_ccache_t 218*7f2fe78bSCy Schubert * function is changed. The API version number is incremented. The library 219*7f2fe78bSCy Schubert * implementation contains both a function with the old signature and semantics and 220*7f2fe78bSCy Schubert * a function with the new signature and semantics. When a context is created, the API 221*7f2fe78bSCy Schubert * version number used in that context is stored in the context, and therefore it can 222*7f2fe78bSCy Schubert * be used whenever a ccache is created in that context. When a ccache is created in a 223*7f2fe78bSCy Schubert * context with the old API version number, the function pointer structure for the 224*7f2fe78bSCy Schubert * ccache is filled with pointers to functions implementing the old semantics; when a 225*7f2fe78bSCy Schubert * ccache is created in a context with the new API version number, the function pointer 226*7f2fe78bSCy Schubert * structure for the ccache is filled with poitners to functions implementing the new 227*7f2fe78bSCy Schubert * semantics. 228*7f2fe78bSCy Schubert * 229*7f2fe78bSCy Schubert * Similarly, if a function is added to the API, the version number in the context can 230*7f2fe78bSCy Schubert * be used to decide whether to include the implementation of the new function in the 231*7f2fe78bSCy Schubert * appropriate function pointer structure or not. 232*7f2fe78bSCy Schubert */ 233*7f2fe78bSCy Schubert 234*7f2fe78bSCy Schubert /*! 235*7f2fe78bSCy Schubert * \defgroup ccapi_constants_reference Constants 236*7f2fe78bSCy Schubert * @{ 237*7f2fe78bSCy Schubert */ 238*7f2fe78bSCy Schubert 239*7f2fe78bSCy Schubert /*! 240*7f2fe78bSCy Schubert * API version numbers 241*7f2fe78bSCy Schubert * 242*7f2fe78bSCy Schubert * These constants are passed into cc_initialize() to indicate the version 243*7f2fe78bSCy Schubert * of the API the caller wants to use. 244*7f2fe78bSCy Schubert * 245*7f2fe78bSCy Schubert * CCAPI v1 and v2 are deprecated and should not be used. 246*7f2fe78bSCy Schubert */ 247*7f2fe78bSCy Schubert enum { 248*7f2fe78bSCy Schubert ccapi_version_2 = 2, 249*7f2fe78bSCy Schubert ccapi_version_3 = 3, 250*7f2fe78bSCy Schubert ccapi_version_4 = 4, 251*7f2fe78bSCy Schubert ccapi_version_5 = 5, 252*7f2fe78bSCy Schubert ccapi_version_6 = 6, 253*7f2fe78bSCy Schubert ccapi_version_7 = 7, 254*7f2fe78bSCy Schubert ccapi_version_max = ccapi_version_7 255*7f2fe78bSCy Schubert }; 256*7f2fe78bSCy Schubert 257*7f2fe78bSCy Schubert /*! 258*7f2fe78bSCy Schubert * Error codes 259*7f2fe78bSCy Schubert */ 260*7f2fe78bSCy Schubert enum { 261*7f2fe78bSCy Schubert 262*7f2fe78bSCy Schubert ccNoError = 0, /*!< Success. */ 263*7f2fe78bSCy Schubert 264*7f2fe78bSCy Schubert ccIteratorEnd = 201, /*!< Iterator is done iterating. */ 265*7f2fe78bSCy Schubert ccErrBadParam, /*!< Bad parameter (NULL or invalid pointer where valid pointer expected). */ 266*7f2fe78bSCy Schubert ccErrNoMem, /*!< Not enough memory to complete the operation. */ 267*7f2fe78bSCy Schubert ccErrInvalidContext, /*!< Context is invalid (e.g., it was released). */ 268*7f2fe78bSCy Schubert ccErrInvalidCCache, /*!< CCache is invalid (e.g., it was released or destroyed). */ 269*7f2fe78bSCy Schubert 270*7f2fe78bSCy Schubert /* 206 */ 271*7f2fe78bSCy Schubert ccErrInvalidString, /*!< String is invalid (e.g., it was released). */ 272*7f2fe78bSCy Schubert ccErrInvalidCredentials, /*!< Credentials are invalid (e.g., they were released), or they have a bad version. */ 273*7f2fe78bSCy Schubert ccErrInvalidCCacheIterator, /*!< CCache iterator is invalid (e.g., it was released). */ 274*7f2fe78bSCy Schubert ccErrInvalidCredentialsIterator, /*!< Credentials iterator is invalid (e.g., it was released). */ 275*7f2fe78bSCy Schubert ccErrInvalidLock, /*!< Lock is invalid (e.g., it was released). */ 276*7f2fe78bSCy Schubert 277*7f2fe78bSCy Schubert /* 211 */ 278*7f2fe78bSCy Schubert ccErrBadName, /*!< Bad credential cache name format. */ 279*7f2fe78bSCy Schubert ccErrBadCredentialsVersion, /*!< Credentials version is invalid. */ 280*7f2fe78bSCy Schubert ccErrBadAPIVersion, /*!< Unsupported API version. */ 281*7f2fe78bSCy Schubert ccErrContextLocked, /*!< Context is already locked. */ 282*7f2fe78bSCy Schubert ccErrContextUnlocked, /*!< Context is not locked by the caller. */ 283*7f2fe78bSCy Schubert 284*7f2fe78bSCy Schubert /* 216 */ 285*7f2fe78bSCy Schubert ccErrCCacheLocked, /*!< CCache is already locked. */ 286*7f2fe78bSCy Schubert ccErrCCacheUnlocked, /*!< CCache is not locked by the caller. */ 287*7f2fe78bSCy Schubert ccErrBadLockType, /*!< Bad lock type. */ 288*7f2fe78bSCy Schubert ccErrNeverDefault, /*!< CCache was never default. */ 289*7f2fe78bSCy Schubert ccErrCredentialsNotFound, /*!< Matching credentials not found in the ccache. */ 290*7f2fe78bSCy Schubert 291*7f2fe78bSCy Schubert /* 221 */ 292*7f2fe78bSCy Schubert ccErrCCacheNotFound, /*!< Matching ccache not found in the collection. */ 293*7f2fe78bSCy Schubert ccErrContextNotFound, /*!< Matching cache collection not found. */ 294*7f2fe78bSCy Schubert ccErrServerUnavailable, /*!< CCacheServer is unavailable. */ 295*7f2fe78bSCy Schubert ccErrServerInsecure, /*!< CCacheServer has detected that it is running as the wrong user. */ 296*7f2fe78bSCy Schubert ccErrServerCantBecomeUID, /*!< CCacheServer failed to start running as the user. */ 297*7f2fe78bSCy Schubert 298*7f2fe78bSCy Schubert /* 226 */ 299*7f2fe78bSCy Schubert ccErrTimeOffsetNotSet, /*!< KDC time offset not set for this ccache. */ 300*7f2fe78bSCy Schubert ccErrBadInternalMessage, /*!< The client and CCacheServer can't communicate (e.g., a version mismatch). */ 301*7f2fe78bSCy Schubert ccErrNotImplemented, /*!< API function not supported by this implementation. */ 302*7f2fe78bSCy Schubert ccErrClientNotFound /*!< CCacheServer has no record of the caller's process (e.g., the server crashed). */ 303*7f2fe78bSCy Schubert }; 304*7f2fe78bSCy Schubert 305*7f2fe78bSCy Schubert /*! 306*7f2fe78bSCy Schubert * Credentials versions 307*7f2fe78bSCy Schubert * 308*7f2fe78bSCy Schubert * These constants are used in several places in the API to discern Kerberos 309*7f2fe78bSCy Schubert * versions. Not all values are valid inputs and outputs for all functions; 310*7f2fe78bSCy Schubert * function specifications below detail the allowed values. 311*7f2fe78bSCy Schubert * 312*7f2fe78bSCy Schubert * Kerberos version constants will always be a bit-field, and can be 313*7f2fe78bSCy Schubert * tested as such; for example the following test will tell you if 314*7f2fe78bSCy Schubert * a ccacheVersion includes v5 credentials: 315*7f2fe78bSCy Schubert * 316*7f2fe78bSCy Schubert * if ((ccacheVersion & cc_credentials_v5) != 0) 317*7f2fe78bSCy Schubert */ 318*7f2fe78bSCy Schubert enum cc_credential_versions { 319*7f2fe78bSCy Schubert /* cc_credentials_v4 = 1, */ 320*7f2fe78bSCy Schubert cc_credentials_v5 = 2, 321*7f2fe78bSCy Schubert /* cc_credentials_v4_v5 = 3 */ 322*7f2fe78bSCy Schubert }; 323*7f2fe78bSCy Schubert 324*7f2fe78bSCy Schubert /*! 325*7f2fe78bSCy Schubert * Lock types 326*7f2fe78bSCy Schubert * 327*7f2fe78bSCy Schubert * These constants are used in the locking functions to describe the 328*7f2fe78bSCy Schubert * type of lock requested. Note that all CCAPI locks are advisory 329*7f2fe78bSCy Schubert * so only callers using the lock calls will be blocked by each other. 330*7f2fe78bSCy Schubert * This is because locking functions were introduced after the CCAPI 331*7f2fe78bSCy Schubert * came into common use and we did not want to break existing callers. 332*7f2fe78bSCy Schubert */ 333*7f2fe78bSCy Schubert enum cc_lock_types { 334*7f2fe78bSCy Schubert cc_lock_read = 0, 335*7f2fe78bSCy Schubert cc_lock_write = 1, 336*7f2fe78bSCy Schubert cc_lock_upgrade = 2, 337*7f2fe78bSCy Schubert cc_lock_downgrade = 3 338*7f2fe78bSCy Schubert }; 339*7f2fe78bSCy Schubert 340*7f2fe78bSCy Schubert /*! 341*7f2fe78bSCy Schubert * Locking Modes 342*7f2fe78bSCy Schubert * 343*7f2fe78bSCy Schubert * These constants are used in the advisory locking functions to 344*7f2fe78bSCy Schubert * describe whether or not the lock function should block waiting for 345*7f2fe78bSCy Schubert * a lock or return an error immediately. For example, attempting to 346*7f2fe78bSCy Schubert * acquire a lock with a non-blocking call will result in an error if the 347*7f2fe78bSCy Schubert * lock cannot be acquired; otherwise, the call will block until the lock 348*7f2fe78bSCy Schubert * can be acquired. 349*7f2fe78bSCy Schubert */ 350*7f2fe78bSCy Schubert enum cc_lock_modes { 351*7f2fe78bSCy Schubert cc_lock_noblock = 0, 352*7f2fe78bSCy Schubert cc_lock_block = 1 353*7f2fe78bSCy Schubert }; 354*7f2fe78bSCy Schubert 355*7f2fe78bSCy Schubert /*!@}*/ 356*7f2fe78bSCy Schubert 357*7f2fe78bSCy Schubert /*! 358*7f2fe78bSCy Schubert * \defgroup ccapi_types_reference Basic Types 359*7f2fe78bSCy Schubert * @{ 360*7f2fe78bSCy Schubert */ 361*7f2fe78bSCy Schubert 362*7f2fe78bSCy Schubert /*! Unsigned 32-bit integer type */ 363*7f2fe78bSCy Schubert typedef uint32_t cc_uint32; 364*7f2fe78bSCy Schubert /*! Signed 32-bit integer type */ 365*7f2fe78bSCy Schubert typedef int32_t cc_int32; 366*7f2fe78bSCy Schubert #if defined (WIN32) 367*7f2fe78bSCy Schubert typedef __int64 cc_int64; 368*7f2fe78bSCy Schubert typedef unsigned __int64 cc_uint64; 369*7f2fe78bSCy Schubert #else 370*7f2fe78bSCy Schubert /*! Unsigned 64-bit integer type */ 371*7f2fe78bSCy Schubert typedef int64_t cc_int64; 372*7f2fe78bSCy Schubert /*! Signed 64-bit integer type */ 373*7f2fe78bSCy Schubert typedef uint64_t cc_uint64; 374*7f2fe78bSCy Schubert #endif 375*7f2fe78bSCy Schubert /*! 376*7f2fe78bSCy Schubert * The cc_time_t type is used to represent a time in seconds. The time must 377*7f2fe78bSCy Schubert * be stored as the number of seconds since midnight GMT on January 1, 1970. 378*7f2fe78bSCy Schubert */ 379*7f2fe78bSCy Schubert typedef cc_uint32 cc_time_t; 380*7f2fe78bSCy Schubert 381*7f2fe78bSCy Schubert /*!@}*/ 382*7f2fe78bSCy Schubert 383*7f2fe78bSCy Schubert /*! 384*7f2fe78bSCy Schubert * \defgroup cc_context_reference cc_context_t Overview 385*7f2fe78bSCy Schubert * @{ 386*7f2fe78bSCy Schubert * 387*7f2fe78bSCy Schubert * The cc_context_t type gives the caller access to a ccache collection. 388*7f2fe78bSCy Schubert * Before being able to call any functions in the CCache API, the caller 389*7f2fe78bSCy Schubert * needs to acquire an instance of cc_context_t by calling cc_initialize(). 390*7f2fe78bSCy Schubert * 391*7f2fe78bSCy Schubert * For API function documentation see \ref cc_context_f. 392*7f2fe78bSCy Schubert */ 393*7f2fe78bSCy Schubert struct cc_context_f; 394*7f2fe78bSCy Schubert typedef struct cc_context_f cc_context_f; 395*7f2fe78bSCy Schubert 396*7f2fe78bSCy Schubert struct cc_context_d { 397*7f2fe78bSCy Schubert const cc_context_f *functions; 398*7f2fe78bSCy Schubert #if TARGET_OS_MAC 399*7f2fe78bSCy Schubert const cc_context_f *vector_functions; 400*7f2fe78bSCy Schubert #endif 401*7f2fe78bSCy Schubert }; 402*7f2fe78bSCy Schubert typedef struct cc_context_d cc_context_d; 403*7f2fe78bSCy Schubert typedef cc_context_d *cc_context_t; 404*7f2fe78bSCy Schubert 405*7f2fe78bSCy Schubert /*!@}*/ 406*7f2fe78bSCy Schubert 407*7f2fe78bSCy Schubert /*! 408*7f2fe78bSCy Schubert * \defgroup cc_ccache_reference cc_ccache_t Overview 409*7f2fe78bSCy Schubert * @{ 410*7f2fe78bSCy Schubert * 411*7f2fe78bSCy Schubert * The cc_ccache_t type represents a reference to a ccache. 412*7f2fe78bSCy Schubert * Callers can access a ccache and the credentials stored in it 413*7f2fe78bSCy Schubert * via a cc_ccache_t. A cc_ccache_t can be acquired via 414*7f2fe78bSCy Schubert * cc_context_open_ccache(), cc_context_open_default_ccache(), or 415*7f2fe78bSCy Schubert * cc_ccache_iterator_next(). 416*7f2fe78bSCy Schubert * 417*7f2fe78bSCy Schubert * For API function documentation see \ref cc_ccache_f. 418*7f2fe78bSCy Schubert */ 419*7f2fe78bSCy Schubert struct cc_ccache_f; 420*7f2fe78bSCy Schubert typedef struct cc_ccache_f cc_ccache_f; 421*7f2fe78bSCy Schubert 422*7f2fe78bSCy Schubert struct cc_ccache_d { 423*7f2fe78bSCy Schubert const cc_ccache_f *functions; 424*7f2fe78bSCy Schubert #if TARGET_OS_MAC 425*7f2fe78bSCy Schubert const cc_ccache_f *vector_functions; 426*7f2fe78bSCy Schubert #endif 427*7f2fe78bSCy Schubert }; 428*7f2fe78bSCy Schubert typedef struct cc_ccache_d cc_ccache_d; 429*7f2fe78bSCy Schubert typedef cc_ccache_d *cc_ccache_t; 430*7f2fe78bSCy Schubert 431*7f2fe78bSCy Schubert /*!@}*/ 432*7f2fe78bSCy Schubert 433*7f2fe78bSCy Schubert /*! 434*7f2fe78bSCy Schubert * \defgroup cc_ccache_iterator_reference cc_ccache_iterator_t Overview 435*7f2fe78bSCy Schubert * @{ 436*7f2fe78bSCy Schubert * 437*7f2fe78bSCy Schubert * The cc_ccache_iterator_t type represents an iterator that 438*7f2fe78bSCy Schubert * iterates over a set of ccaches and returns them in all in some 439*7f2fe78bSCy Schubert * order. A new instance of this type can be obtained by calling 440*7f2fe78bSCy Schubert * cc_context_new_ccache_iterator(). 441*7f2fe78bSCy Schubert * 442*7f2fe78bSCy Schubert * For API function documentation see \ref cc_ccache_iterator_f. 443*7f2fe78bSCy Schubert */ 444*7f2fe78bSCy Schubert struct cc_ccache_iterator_f; 445*7f2fe78bSCy Schubert typedef struct cc_ccache_iterator_f cc_ccache_iterator_f; 446*7f2fe78bSCy Schubert 447*7f2fe78bSCy Schubert struct cc_ccache_iterator_d { 448*7f2fe78bSCy Schubert const cc_ccache_iterator_f *functions; 449*7f2fe78bSCy Schubert #if TARGET_OS_MAC 450*7f2fe78bSCy Schubert const cc_ccache_iterator_f *vector_functions; 451*7f2fe78bSCy Schubert #endif 452*7f2fe78bSCy Schubert }; 453*7f2fe78bSCy Schubert typedef struct cc_ccache_iterator_d cc_ccache_iterator_d; 454*7f2fe78bSCy Schubert typedef cc_ccache_iterator_d *cc_ccache_iterator_t; 455*7f2fe78bSCy Schubert /*!@}*/ 456*7f2fe78bSCy Schubert 457*7f2fe78bSCy Schubert /*! 458*7f2fe78bSCy Schubert * \defgroup cc_credentials_reference cc_credentials_t Overview 459*7f2fe78bSCy Schubert * @{ 460*7f2fe78bSCy Schubert * 461*7f2fe78bSCy Schubert * The cc_credentials_t type is used to store a single set of credentials for 462*7f2fe78bSCy Schubert * Kerberos v5. In addition to its only function, release(), it contains a 463*7f2fe78bSCy Schubert * pointer to a cc_credentials_union structure. A cc_credentials_union 464*7f2fe78bSCy Schubert * structure contains an integer of the enumerator type 465*7f2fe78bSCy Schubert * cc_credentials_version, which is #cc_credentials_v5, and a pointer union, 466*7f2fe78bSCy Schubert * which contains a cc_credentials_v5_t pointer, depending on the value in 467*7f2fe78bSCy Schubert * version. 468*7f2fe78bSCy Schubert * 469*7f2fe78bSCy Schubert * Variables of the type cc_credentials_t are allocated by the CCAPI 470*7f2fe78bSCy Schubert * implementation, and should be released with their release() 471*7f2fe78bSCy Schubert * function. API functions which receive credentials structures 472*7f2fe78bSCy Schubert * from the caller always accept cc_credentials_union, which is 473*7f2fe78bSCy Schubert * allocated by the caller, and accordingly disposed by the caller. 474*7f2fe78bSCy Schubert * 475*7f2fe78bSCy Schubert * For API functions see \ref cc_credentials_f. 476*7f2fe78bSCy Schubert */ 477*7f2fe78bSCy Schubert 478*7f2fe78bSCy Schubert /*! 479*7f2fe78bSCy Schubert * The CCAPI data structure. This structure is similar to a krb5_data structure. 480*7f2fe78bSCy Schubert * In a v5 credentials structure, cc_data structures are used 481*7f2fe78bSCy Schubert * to store tagged variable-length binary data. Specifically, 482*7f2fe78bSCy Schubert * for cc_credentials_v5.ticket and 483*7f2fe78bSCy Schubert * cc_credentials_v5.second_ticket, the cc_data.type field must 484*7f2fe78bSCy Schubert * be zero. For the cc_credentials_v5.addresses, 485*7f2fe78bSCy Schubert * cc_credentials_v5.authdata, and cc_credentials_v5.keyblock, 486*7f2fe78bSCy Schubert * the cc_data.type field should be the address type, 487*7f2fe78bSCy Schubert * authorization data type, and encryption type, as defined by 488*7f2fe78bSCy Schubert * the Kerberos v5 protocol definition. 489*7f2fe78bSCy Schubert */ 490*7f2fe78bSCy Schubert struct cc_data { 491*7f2fe78bSCy Schubert /*! The type of the data as defined by the krb5_data structure. */ 492*7f2fe78bSCy Schubert cc_uint32 type; 493*7f2fe78bSCy Schubert /*! The length of \a data. */ 494*7f2fe78bSCy Schubert cc_uint32 length; 495*7f2fe78bSCy Schubert /*! The data buffer. */ 496*7f2fe78bSCy Schubert void* data; 497*7f2fe78bSCy Schubert }; 498*7f2fe78bSCy Schubert typedef struct cc_data cc_data; 499*7f2fe78bSCy Schubert 500*7f2fe78bSCy Schubert /*! 501*7f2fe78bSCy Schubert * If a cc_credentials_t variable is used to store Kerberos v5 c 502*7f2fe78bSCy Schubert * redentials, and then credentials.credentials_v5 points to a 503*7f2fe78bSCy Schubert * v5 credentials structure. This structure is similar to a 504*7f2fe78bSCy Schubert * krb5_creds structure. 505*7f2fe78bSCy Schubert */ 506*7f2fe78bSCy Schubert struct cc_credentials_v5_t { 507*7f2fe78bSCy Schubert /*! A properly quoted string representation of the client principal. */ 508*7f2fe78bSCy Schubert char* client; 509*7f2fe78bSCy Schubert /*! A properly quoted string representation of the service principal. */ 510*7f2fe78bSCy Schubert char* server; 511*7f2fe78bSCy Schubert /*! Session encryption key info. */ 512*7f2fe78bSCy Schubert cc_data keyblock; 513*7f2fe78bSCy Schubert /*! The time when the ticket was issued. */ 514*7f2fe78bSCy Schubert cc_time_t authtime; 515*7f2fe78bSCy Schubert /*! The time when the ticket becomes valid. */ 516*7f2fe78bSCy Schubert cc_time_t starttime; 517*7f2fe78bSCy Schubert /*! The time when the ticket expires. */ 518*7f2fe78bSCy Schubert cc_time_t endtime; 519*7f2fe78bSCy Schubert /*! The time when the ticket becomes no longer renewable (if renewable). */ 520*7f2fe78bSCy Schubert cc_time_t renew_till; 521*7f2fe78bSCy Schubert /*! 1 if the ticket is encrypted in another ticket's key, or 0 otherwise. */ 522*7f2fe78bSCy Schubert cc_uint32 is_skey; 523*7f2fe78bSCy Schubert /*! Ticket flags, as defined by the Kerberos 5 API. */ 524*7f2fe78bSCy Schubert cc_uint32 ticket_flags; 525*7f2fe78bSCy Schubert /*! The the list of network addresses of hosts that are allowed to authenticate 526*7f2fe78bSCy Schubert * using this ticket. */ 527*7f2fe78bSCy Schubert cc_data** addresses; 528*7f2fe78bSCy Schubert /*! Ticket data. */ 529*7f2fe78bSCy Schubert cc_data ticket; 530*7f2fe78bSCy Schubert /*! Second ticket data. */ 531*7f2fe78bSCy Schubert cc_data second_ticket; 532*7f2fe78bSCy Schubert /*! Authorization data. */ 533*7f2fe78bSCy Schubert cc_data** authdata; 534*7f2fe78bSCy Schubert }; 535*7f2fe78bSCy Schubert typedef struct cc_credentials_v5_t cc_credentials_v5_t; 536*7f2fe78bSCy Schubert 537*7f2fe78bSCy Schubert struct cc_credentials_union { 538*7f2fe78bSCy Schubert /*! The credentials version of this credentials object. */ 539*7f2fe78bSCy Schubert cc_uint32 version; 540*7f2fe78bSCy Schubert /*! The credentials. */ 541*7f2fe78bSCy Schubert union { 542*7f2fe78bSCy Schubert /*! If \a version is #cc_credentials_v5, a pointer to a cc_credentials_v5_t. */ 543*7f2fe78bSCy Schubert cc_credentials_v5_t* credentials_v5; 544*7f2fe78bSCy Schubert } credentials; 545*7f2fe78bSCy Schubert }; 546*7f2fe78bSCy Schubert typedef struct cc_credentials_union cc_credentials_union; 547*7f2fe78bSCy Schubert 548*7f2fe78bSCy Schubert struct cc_credentials_f; 549*7f2fe78bSCy Schubert typedef struct cc_credentials_f cc_credentials_f; 550*7f2fe78bSCy Schubert 551*7f2fe78bSCy Schubert struct cc_credentials_d { 552*7f2fe78bSCy Schubert const cc_credentials_union *data; 553*7f2fe78bSCy Schubert const cc_credentials_f *functions; 554*7f2fe78bSCy Schubert #if TARGET_OS_MAC 555*7f2fe78bSCy Schubert const cc_credentials_f *otherFunctions; 556*7f2fe78bSCy Schubert #endif 557*7f2fe78bSCy Schubert }; 558*7f2fe78bSCy Schubert typedef struct cc_credentials_d cc_credentials_d; 559*7f2fe78bSCy Schubert typedef cc_credentials_d *cc_credentials_t; 560*7f2fe78bSCy Schubert /*!@}*/ 561*7f2fe78bSCy Schubert 562*7f2fe78bSCy Schubert /*! 563*7f2fe78bSCy Schubert * \defgroup cc_credentials_iterator_reference cc_credentials_iterator_t 564*7f2fe78bSCy Schubert * @{ 565*7f2fe78bSCy Schubert * The cc_credentials_iterator_t type represents an iterator that 566*7f2fe78bSCy Schubert * iterates over a set of credentials. A new instance of this type 567*7f2fe78bSCy Schubert * can be obtained by calling cc_ccache_new_credentials_iterator(). 568*7f2fe78bSCy Schubert * 569*7f2fe78bSCy Schubert * For API function documentation see \ref cc_credentials_iterator_f. 570*7f2fe78bSCy Schubert */ 571*7f2fe78bSCy Schubert struct cc_credentials_iterator_f; 572*7f2fe78bSCy Schubert typedef struct cc_credentials_iterator_f cc_credentials_iterator_f; 573*7f2fe78bSCy Schubert 574*7f2fe78bSCy Schubert struct cc_credentials_iterator_d { 575*7f2fe78bSCy Schubert const cc_credentials_iterator_f *functions; 576*7f2fe78bSCy Schubert #if TARGET_OS_MAC 577*7f2fe78bSCy Schubert const cc_credentials_iterator_f *vector_functions; 578*7f2fe78bSCy Schubert #endif 579*7f2fe78bSCy Schubert }; 580*7f2fe78bSCy Schubert typedef struct cc_credentials_iterator_d cc_credentials_iterator_d; 581*7f2fe78bSCy Schubert typedef cc_credentials_iterator_d *cc_credentials_iterator_t; 582*7f2fe78bSCy Schubert /*!@}*/ 583*7f2fe78bSCy Schubert 584*7f2fe78bSCy Schubert /*! 585*7f2fe78bSCy Schubert * \defgroup cc_string_reference cc_string_t Overview 586*7f2fe78bSCy Schubert * @{ 587*7f2fe78bSCy Schubert * The cc_string_t represents a C string returned by the API. 588*7f2fe78bSCy Schubert * It has a pointer to the string data and a release() function. 589*7f2fe78bSCy Schubert * This type is used for both principal names and ccache names 590*7f2fe78bSCy Schubert * returned by the API. Principal names may contain UTF-8 encoded 591*7f2fe78bSCy Schubert * strings for internationalization purposes. 592*7f2fe78bSCy Schubert * 593*7f2fe78bSCy Schubert * For API function documentation see \ref cc_string_f. 594*7f2fe78bSCy Schubert */ 595*7f2fe78bSCy Schubert struct cc_string_f; 596*7f2fe78bSCy Schubert typedef struct cc_string_f cc_string_f; 597*7f2fe78bSCy Schubert 598*7f2fe78bSCy Schubert struct cc_string_d { 599*7f2fe78bSCy Schubert const char *data; 600*7f2fe78bSCy Schubert const cc_string_f *functions; 601*7f2fe78bSCy Schubert #if TARGET_OS_MAC 602*7f2fe78bSCy Schubert const cc_string_f *vector_functions; 603*7f2fe78bSCy Schubert #endif 604*7f2fe78bSCy Schubert }; 605*7f2fe78bSCy Schubert typedef struct cc_string_d cc_string_d; 606*7f2fe78bSCy Schubert typedef cc_string_d *cc_string_t; 607*7f2fe78bSCy Schubert /*!@}*/ 608*7f2fe78bSCy Schubert 609*7f2fe78bSCy Schubert /*! 610*7f2fe78bSCy Schubert * Function pointer table for cc_context_t. For more information see 611*7f2fe78bSCy Schubert * \ref cc_context_reference. 612*7f2fe78bSCy Schubert */ 613*7f2fe78bSCy Schubert struct cc_context_f { 614*7f2fe78bSCy Schubert /*! 615*7f2fe78bSCy Schubert * \param io_context the context object to free. 616*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 617*7f2fe78bSCy Schubert * \brief \b cc_context_release(): Release memory associated with a cc_context_t. 618*7f2fe78bSCy Schubert */ 619*7f2fe78bSCy Schubert cc_int32 (*release) (cc_context_t io_context); 620*7f2fe78bSCy Schubert 621*7f2fe78bSCy Schubert /*! 622*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection to examine. 623*7f2fe78bSCy Schubert * \param out_time on exit, the time of the most recent change for the entire ccache collection. 624*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 625*7f2fe78bSCy Schubert * \brief \b cc_context_get_change_time(): Get the last time the cache collection changed. 626*7f2fe78bSCy Schubert * 627*7f2fe78bSCy Schubert * This function returns the time of the most recent change for the entire ccache collection. 628*7f2fe78bSCy Schubert * By maintaining a local copy the caller can deduce whether or not the ccache collection has 629*7f2fe78bSCy Schubert * been modified since the previous call to cc_context_get_change_time(). 630*7f2fe78bSCy Schubert * 631*7f2fe78bSCy Schubert * The time returned by cc_context_get_changed_time() increases whenever: 632*7f2fe78bSCy Schubert * 633*7f2fe78bSCy Schubert * \li a ccache is created 634*7f2fe78bSCy Schubert * \li a ccache is destroyed 635*7f2fe78bSCy Schubert * \li a credential is stored 636*7f2fe78bSCy Schubert * \li a credential is removed 637*7f2fe78bSCy Schubert * \li a ccache principal is changed 638*7f2fe78bSCy Schubert * \li the default ccache is changed 639*7f2fe78bSCy Schubert * 640*7f2fe78bSCy Schubert * \note In order to be able to compare two values returned by cc_context_get_change_time(), 641*7f2fe78bSCy Schubert * the caller must use the same context to acquire them. Callers should maintain a single 642*7f2fe78bSCy Schubert * context in memory for cc_context_get_change_time() calls rather than creating a new 643*7f2fe78bSCy Schubert * context for every call. 644*7f2fe78bSCy Schubert * 645*7f2fe78bSCy Schubert * \sa wait_for_change 646*7f2fe78bSCy Schubert */ 647*7f2fe78bSCy Schubert cc_int32 (*get_change_time) (cc_context_t in_context, 648*7f2fe78bSCy Schubert cc_time_t *out_time); 649*7f2fe78bSCy Schubert 650*7f2fe78bSCy Schubert /*! 651*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 652*7f2fe78bSCy Schubert * \param out_name on exit, the name of the default ccache. 653*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 654*7f2fe78bSCy Schubert * \brief \b cc_context_get_default_ccache_name(): Get the name of the default ccache. 655*7f2fe78bSCy Schubert * 656*7f2fe78bSCy Schubert * This function returns the name of the default ccache. When the default ccache 657*7f2fe78bSCy Schubert * exists, its name is returned. If there are no ccaches in the collection, and 658*7f2fe78bSCy Schubert * thus there is no default ccache, the name that the default ccache should have 659*7f2fe78bSCy Schubert * is returned. The ccache with that name will be used as the default ccache by 660*7f2fe78bSCy Schubert * all processes which initialized Kerberos libraries before the ccache was created. 661*7f2fe78bSCy Schubert * 662*7f2fe78bSCy Schubert * If there is no default ccache, and the client is creating a new ccache, it 663*7f2fe78bSCy Schubert * should be created with the default name. If there already is a default ccache, 664*7f2fe78bSCy Schubert * and the client wants to create a new ccache (as opposed to reusing an existing 665*7f2fe78bSCy Schubert * ccache), it should be created with any unique name; #create_new_ccache() 666*7f2fe78bSCy Schubert * can be used to accomplish that more easily. 667*7f2fe78bSCy Schubert * 668*7f2fe78bSCy Schubert * If the first ccache is created with a name other than the default name, then 669*7f2fe78bSCy Schubert * the processes already running will not notice the credentials stored in the 670*7f2fe78bSCy Schubert * new ccache, which is normally undesirable. 671*7f2fe78bSCy Schubert */ 672*7f2fe78bSCy Schubert cc_int32 (*get_default_ccache_name) (cc_context_t in_context, 673*7f2fe78bSCy Schubert cc_string_t *out_name); 674*7f2fe78bSCy Schubert 675*7f2fe78bSCy Schubert /*! 676*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 677*7f2fe78bSCy Schubert * \param in_name the name of the ccache to open. 678*7f2fe78bSCy Schubert * \param out_ccache on exit, a ccache object for the ccache 679*7f2fe78bSCy Schubert * \return On success, #ccNoError. If no ccache named \a in_name exists, 680*7f2fe78bSCy Schubert * #ccErrCCacheNotFound. On failure, an error code representing the failure. 681*7f2fe78bSCy Schubert * \brief \b cc_context_open_ccache(): Open a ccache. 682*7f2fe78bSCy Schubert * 683*7f2fe78bSCy Schubert * Opens an already existing ccache identified by its name. It returns a reference 684*7f2fe78bSCy Schubert * to the ccache in \a out_ccache. 685*7f2fe78bSCy Schubert * 686*7f2fe78bSCy Schubert * The list of all ccache names, principals, and credentials versions may be retrieved 687*7f2fe78bSCy Schubert * by calling cc_context_new_cache_iterator(), cc_ccache_get_name(), 688*7f2fe78bSCy Schubert * cc_ccache_get_principal(), and cc_ccache_get_cred_version(). 689*7f2fe78bSCy Schubert */ 690*7f2fe78bSCy Schubert cc_int32 (*open_ccache) (cc_context_t in_context, 691*7f2fe78bSCy Schubert const char *in_name, 692*7f2fe78bSCy Schubert cc_ccache_t *out_ccache); 693*7f2fe78bSCy Schubert 694*7f2fe78bSCy Schubert /*! 695*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 696*7f2fe78bSCy Schubert * \param out_ccache on exit, a ccache object for the default ccache 697*7f2fe78bSCy Schubert * \return On success, #ccNoError. If no default ccache exists, 698*7f2fe78bSCy Schubert * #ccErrCCacheNotFound. On failure, an error code representing the failure. 699*7f2fe78bSCy Schubert * \brief \b cc_context_open_default_ccache(): Open the default ccache. 700*7f2fe78bSCy Schubert * 701*7f2fe78bSCy Schubert * Opens the default ccache. It returns a reference to the ccache in *ccache. 702*7f2fe78bSCy Schubert * 703*7f2fe78bSCy Schubert * This function performs the same function as calling 704*7f2fe78bSCy Schubert * cc_context_get_default_ccache_name followed by cc_context_open_ccache, 705*7f2fe78bSCy Schubert * but it performs it atomically. 706*7f2fe78bSCy Schubert */ 707*7f2fe78bSCy Schubert cc_int32 (*open_default_ccache) (cc_context_t in_context, 708*7f2fe78bSCy Schubert cc_ccache_t *out_ccache); 709*7f2fe78bSCy Schubert 710*7f2fe78bSCy Schubert /*! 711*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 712*7f2fe78bSCy Schubert * \param in_name the name of the new ccache to create 713*7f2fe78bSCy Schubert * \param in_cred_vers the version of the credentials the new ccache will hold 714*7f2fe78bSCy Schubert * \param in_principal the client principal of the credentials the new ccache will hold 715*7f2fe78bSCy Schubert * \param out_ccache on exit, a ccache object for the newly created ccache 716*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 717*7f2fe78bSCy Schubert * \brief \b cc_context_create_ccache(): Create a new ccache. 718*7f2fe78bSCy Schubert * 719*7f2fe78bSCy Schubert * Create a new credentials cache. The ccache is uniquely identified by 720*7f2fe78bSCy Schubert * its name. The principal given is also associated with the ccache and 721*7f2fe78bSCy Schubert * the credentials version specified. A NULL name is not allowed (and 722*7f2fe78bSCy Schubert * ccErrBadName is returned if one is passed in). Only cc_credentials_v5 723*7f2fe78bSCy Schubert * can be an input value for cred_vers. 724*7f2fe78bSCy Schubert * 725*7f2fe78bSCy Schubert * If you want to create a new ccache (with a unique name), you should use 726*7f2fe78bSCy Schubert * cc_context_create_new_ccache() instead. If you want to create or reinitialize 727*7f2fe78bSCy Schubert * the default cache, you should use cc_context_create_default_ccache(). 728*7f2fe78bSCy Schubert * 729*7f2fe78bSCy Schubert * If name is non-NULL and there is already a ccache named name: 730*7f2fe78bSCy Schubert * 731*7f2fe78bSCy Schubert * \li the credentials in the ccache whose version is cred_vers are removed 732*7f2fe78bSCy Schubert * \li the principal (of the existing ccache) associated with cred_vers is set to principal 733*7f2fe78bSCy Schubert * \li a handle for the existing ccache is returned and all existing handles for the ccache remain valid 734*7f2fe78bSCy Schubert * 735*7f2fe78bSCy Schubert * If no ccache named name already exists: 736*7f2fe78bSCy Schubert * 737*7f2fe78bSCy Schubert * \li a new empty ccache is created 738*7f2fe78bSCy Schubert * \li the principal of the new ccache associated with cred_vers is set to principal 739*7f2fe78bSCy Schubert * \li a handle for the new ccache is returned 740*7f2fe78bSCy Schubert * 741*7f2fe78bSCy Schubert * For a new ccache, the name should be any unique string. The name is not 742*7f2fe78bSCy Schubert * intended to be presented to users. 743*7f2fe78bSCy Schubert * 744*7f2fe78bSCy Schubert * If the created ccache is the first ccache in the collection, it is made 745*7f2fe78bSCy Schubert * the default ccache. Note that normally it is undesirable to create the first 746*7f2fe78bSCy Schubert * ccache with a name different from the default ccache name (as returned by 747*7f2fe78bSCy Schubert * cc_context_get_default_ccache_name()); see the description of 748*7f2fe78bSCy Schubert * cc_context_get_default_ccache_name() for details. 749*7f2fe78bSCy Schubert * 750*7f2fe78bSCy Schubert * The principal should be a C string containing an unparsed Kerberos 751*7f2fe78bSCy Schubert * principal in the format of the appropriate Kerberos version, 752*7f2fe78bSCy Schubert * i.e. \verbatim foo/bar/@BAZ \endverbatim for Kerberos v5. 753*7f2fe78bSCy Schubert */ 754*7f2fe78bSCy Schubert cc_int32 (*create_ccache) (cc_context_t in_context, 755*7f2fe78bSCy Schubert const char *in_name, 756*7f2fe78bSCy Schubert cc_uint32 in_cred_vers, 757*7f2fe78bSCy Schubert const char *in_principal, 758*7f2fe78bSCy Schubert cc_ccache_t *out_ccache); 759*7f2fe78bSCy Schubert 760*7f2fe78bSCy Schubert /*! 761*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 762*7f2fe78bSCy Schubert * \param in_cred_vers the version of the credentials the new default ccache will hold 763*7f2fe78bSCy Schubert * \param in_principal the client principal of the credentials the new default ccache will hold 764*7f2fe78bSCy Schubert * \param out_ccache on exit, a ccache object for the newly created default ccache 765*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 766*7f2fe78bSCy Schubert * \brief \b cc_context_create_default_ccache(): Create a new default ccache. 767*7f2fe78bSCy Schubert * 768*7f2fe78bSCy Schubert * Create the default credentials cache. The behavior of this function is 769*7f2fe78bSCy Schubert * similar to that of cc_create_ccache(). If there is a default ccache 770*7f2fe78bSCy Schubert * (which is always the case except when there are no ccaches at all in 771*7f2fe78bSCy Schubert * the collection), it is initialized with the specified credentials version 772*7f2fe78bSCy Schubert * and principal, as per cc_create_ccache(); otherwise, a new ccache is 773*7f2fe78bSCy Schubert * created, and its name is the name returned by 774*7f2fe78bSCy Schubert * cc_context_get_default_ccache_name(). 775*7f2fe78bSCy Schubert */ 776*7f2fe78bSCy Schubert cc_int32 (*create_default_ccache) (cc_context_t in_context, 777*7f2fe78bSCy Schubert cc_uint32 in_cred_vers, 778*7f2fe78bSCy Schubert const char *in_principal, 779*7f2fe78bSCy Schubert cc_ccache_t *out_ccache); 780*7f2fe78bSCy Schubert 781*7f2fe78bSCy Schubert /*! 782*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 783*7f2fe78bSCy Schubert * \param in_cred_vers the version of the credentials the new ccache will hold 784*7f2fe78bSCy Schubert * \param in_principal the client principal of the credentials the new ccache will hold 785*7f2fe78bSCy Schubert * \param out_ccache on exit, a ccache object for the newly created ccache 786*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 787*7f2fe78bSCy Schubert * \brief \b cc_context_create_new_ccache(): Create a new uniquely named ccache. 788*7f2fe78bSCy Schubert * 789*7f2fe78bSCy Schubert * Create a new unique credentials cache. The behavior of this function 790*7f2fe78bSCy Schubert * is similar to that of cc_create_ccache(). If there are no ccaches, and 791*7f2fe78bSCy Schubert * therefore no default ccache, the new ccache is created with the default 792*7f2fe78bSCy Schubert * ccache name as would be returned by get_default_ccache_name(). If there 793*7f2fe78bSCy Schubert * are some ccaches, and therefore there is a default ccache, the new ccache 794*7f2fe78bSCy Schubert * is created with a new unique name. Clearly, this function never reinitializes 795*7f2fe78bSCy Schubert * a ccache, since it always uses a unique name. 796*7f2fe78bSCy Schubert */ 797*7f2fe78bSCy Schubert cc_int32 (*create_new_ccache) (cc_context_t in_context, 798*7f2fe78bSCy Schubert cc_uint32 in_cred_vers, 799*7f2fe78bSCy Schubert const char *in_principal, 800*7f2fe78bSCy Schubert cc_ccache_t *out_ccache); 801*7f2fe78bSCy Schubert 802*7f2fe78bSCy Schubert /*! 803*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 804*7f2fe78bSCy Schubert * \param out_iterator on exit, a ccache iterator object for the ccache collection. 805*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 806*7f2fe78bSCy Schubert * \brief \b cc_context_new_ccache_iterator(): Get an iterator for the cache collection. 807*7f2fe78bSCy Schubert * 808*7f2fe78bSCy Schubert * Used to allocate memory and initialize iterator. Successive calls to iterator's 809*7f2fe78bSCy Schubert * next() function will return ccaches in the collection. 810*7f2fe78bSCy Schubert * 811*7f2fe78bSCy Schubert * If changes are made to the collection while an iterator is being used 812*7f2fe78bSCy Schubert * on it, the iterator must return at least the intersection, and at most 813*7f2fe78bSCy Schubert * the union, of the set of ccaches that were present when the iteration 814*7f2fe78bSCy Schubert * began and the set of ccaches that are present when it ends. 815*7f2fe78bSCy Schubert */ 816*7f2fe78bSCy Schubert cc_int32 (*new_ccache_iterator) (cc_context_t in_context, 817*7f2fe78bSCy Schubert cc_ccache_iterator_t *out_iterator); 818*7f2fe78bSCy Schubert 819*7f2fe78bSCy Schubert /*! 820*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 821*7f2fe78bSCy Schubert * \param in_lock_type the type of lock to obtain. 822*7f2fe78bSCy Schubert * \param in_block whether or not the function should block if the lock cannot be obtained immediately. 823*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 824*7f2fe78bSCy Schubert * \brief \b cc_context_lock(): Lock the cache collection. 825*7f2fe78bSCy Schubert * 826*7f2fe78bSCy Schubert * Attempts to acquire an advisory lock for the ccache collection. Allowed values 827*7f2fe78bSCy Schubert * for lock_type are: 828*7f2fe78bSCy Schubert * 829*7f2fe78bSCy Schubert * \li cc_lock_read: a read lock. 830*7f2fe78bSCy Schubert * \li cc_lock_write: a write lock 831*7f2fe78bSCy Schubert * \li cc_lock_upgrade: upgrade an already-obtained read lock to a write lock 832*7f2fe78bSCy Schubert * \li cc_lock_downgrade: downgrade an already-obtained write lock to a read lock 833*7f2fe78bSCy Schubert * 834*7f2fe78bSCy Schubert * If block is cc_lock_block, lock() will not return until the lock is acquired. 835*7f2fe78bSCy Schubert * If block is cc_lock_noblock, lock() will return immediately, either acquiring 836*7f2fe78bSCy Schubert * the lock and returning ccNoError, or failing to acquire the lock and returning 837*7f2fe78bSCy Schubert * an error explaining why. 838*7f2fe78bSCy Schubert * 839*7f2fe78bSCy Schubert * Locks apply only to the list of ccaches, not the contents of those ccaches. To 840*7f2fe78bSCy Schubert * prevent callers participating in the advisory locking from changing the credentials 841*7f2fe78bSCy Schubert * in a cache you must also lock that ccache with cc_ccache_lock(). This is so 842*7f2fe78bSCy Schubert * that you can get the list of ccaches without preventing applications from 843*7f2fe78bSCy Schubert * simultaneously obtaining service tickets. 844*7f2fe78bSCy Schubert * 845*7f2fe78bSCy Schubert * To avoid having to deal with differences between thread semantics on different 846*7f2fe78bSCy Schubert * platforms, locks are granted per context, rather than per thread or per process. 847*7f2fe78bSCy Schubert * That means that different threads of execution have to acquire separate contexts 848*7f2fe78bSCy Schubert * in order to be able to synchronize with each other. 849*7f2fe78bSCy Schubert * 850*7f2fe78bSCy Schubert * The lock should be unlocked by using cc_context_unlock(). 851*7f2fe78bSCy Schubert * 852*7f2fe78bSCy Schubert * \note All locks are advisory. For example, callers which do not call 853*7f2fe78bSCy Schubert * cc_context_lock() and cc_context_unlock() will not be prevented from writing 854*7f2fe78bSCy Schubert * to the cache collection when you have a read lock. This is because the CCAPI 855*7f2fe78bSCy Schubert * locking was added after the first release and thus adding mandatory locks would 856*7f2fe78bSCy Schubert * have changed the user experience and performance of existing applications. 857*7f2fe78bSCy Schubert */ 858*7f2fe78bSCy Schubert cc_int32 (*lock) (cc_context_t in_context, 859*7f2fe78bSCy Schubert cc_uint32 in_lock_type, 860*7f2fe78bSCy Schubert cc_uint32 in_block); 861*7f2fe78bSCy Schubert 862*7f2fe78bSCy Schubert /*! 863*7f2fe78bSCy Schubert * \param in_context the context object for the cache collection. 864*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 865*7f2fe78bSCy Schubert * \brief \b cc_context_unlock(): Unlock the cache collection. 866*7f2fe78bSCy Schubert */ 867*7f2fe78bSCy Schubert cc_int32 (*unlock) (cc_context_t in_cc_context); 868*7f2fe78bSCy Schubert 869*7f2fe78bSCy Schubert /*! 870*7f2fe78bSCy Schubert * \param in_context a context object. 871*7f2fe78bSCy Schubert * \param in_compare_to_context a context object to compare with \a in_context. 872*7f2fe78bSCy Schubert * \param out_equal on exit, whether or not the two contexts refer to the same cache collection. 873*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 874*7f2fe78bSCy Schubert * \brief \b cc_context_compare(): Compare two context objects. 875*7f2fe78bSCy Schubert */ 876*7f2fe78bSCy Schubert cc_int32 (*compare) (cc_context_t in_cc_context, 877*7f2fe78bSCy Schubert cc_context_t in_compare_to_context, 878*7f2fe78bSCy Schubert cc_uint32 *out_equal); 879*7f2fe78bSCy Schubert 880*7f2fe78bSCy Schubert /*! 881*7f2fe78bSCy Schubert * \param in_context a context object. 882*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 883*7f2fe78bSCy Schubert * \brief \b cc_context_wait_for_change(): Wait for the next change in the cache collection. 884*7f2fe78bSCy Schubert * 885*7f2fe78bSCy Schubert * This function blocks until the next change is made to the cache collection 886*7f2fe78bSCy Schubert * ccache collection. By repeatedly calling cc_context_wait_for_change() from 887*7f2fe78bSCy Schubert * a worker thread the caller can effectively receive callbacks whenever the 888*7f2fe78bSCy Schubert * cache collection changes. This is considerably more efficient than polling 889*7f2fe78bSCy Schubert * with cc_context_get_change_time(). 890*7f2fe78bSCy Schubert * 891*7f2fe78bSCy Schubert * cc_context_wait_for_change() will return whenever: 892*7f2fe78bSCy Schubert * 893*7f2fe78bSCy Schubert * \li a ccache is created 894*7f2fe78bSCy Schubert * \li a ccache is destroyed 895*7f2fe78bSCy Schubert * \li a credential is stored 896*7f2fe78bSCy Schubert * \li a credential is removed 897*7f2fe78bSCy Schubert * \li a ccache principal is changed 898*7f2fe78bSCy Schubert * \li the default ccache is changed 899*7f2fe78bSCy Schubert * 900*7f2fe78bSCy Schubert * \note In order to make sure that the caller doesn't miss any changes, 901*7f2fe78bSCy Schubert * cc_context_wait_for_change() always returns immediately after the first time it 902*7f2fe78bSCy Schubert * is called on a new context object. Callers must use the same context object 903*7f2fe78bSCy Schubert * for successive calls to cc_context_wait_for_change() rather than creating a new 904*7f2fe78bSCy Schubert * context for every call. 905*7f2fe78bSCy Schubert * 906*7f2fe78bSCy Schubert * \sa get_change_time 907*7f2fe78bSCy Schubert */ 908*7f2fe78bSCy Schubert cc_int32 (*wait_for_change) (cc_context_t in_cc_context); 909*7f2fe78bSCy Schubert }; 910*7f2fe78bSCy Schubert 911*7f2fe78bSCy Schubert /*! 912*7f2fe78bSCy Schubert * Function pointer table for cc_ccache_t. For more information see 913*7f2fe78bSCy Schubert * \ref cc_ccache_reference. 914*7f2fe78bSCy Schubert */ 915*7f2fe78bSCy Schubert struct cc_ccache_f { 916*7f2fe78bSCy Schubert /*! 917*7f2fe78bSCy Schubert * \param io_ccache the ccache object to release. 918*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 919*7f2fe78bSCy Schubert * \brief \b cc_ccache_release(): Release memory associated with a cc_ccache_t object. 920*7f2fe78bSCy Schubert * \note Does not modify the ccache. If you wish to remove the ccache see cc_ccache_destroy(). 921*7f2fe78bSCy Schubert */ 922*7f2fe78bSCy Schubert cc_int32 (*release) (cc_ccache_t io_ccache); 923*7f2fe78bSCy Schubert 924*7f2fe78bSCy Schubert /*! 925*7f2fe78bSCy Schubert * \param io_ccache the ccache object to destroy and release. 926*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 927*7f2fe78bSCy Schubert * \brief \b cc_ccache_destroy(): Destroy a ccache. 928*7f2fe78bSCy Schubert * 929*7f2fe78bSCy Schubert * Destroy the ccache referred to by \a io_ccache and releases memory associated with 930*7f2fe78bSCy Schubert * the \a io_ccache object. After this call \a io_ccache becomes invalid. If 931*7f2fe78bSCy Schubert * \a io_ccache was the default ccache, the next ccache in the cache collection (if any) 932*7f2fe78bSCy Schubert * becomes the new default. 933*7f2fe78bSCy Schubert */ 934*7f2fe78bSCy Schubert cc_int32 (*destroy) (cc_ccache_t io_ccache); 935*7f2fe78bSCy Schubert 936*7f2fe78bSCy Schubert /*! 937*7f2fe78bSCy Schubert * \param io_ccache a ccache object to make the new default ccache. 938*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 939*7f2fe78bSCy Schubert * \brief \b cc_ccache_set_default(): Make a ccache the default ccache. 940*7f2fe78bSCy Schubert */ 941*7f2fe78bSCy Schubert cc_int32 (*set_default) (cc_ccache_t io_ccache); 942*7f2fe78bSCy Schubert 943*7f2fe78bSCy Schubert /*! 944*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 945*7f2fe78bSCy Schubert * \param out_credentials_version on exit, the credentials version of \a in_ccache. 946*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 947*7f2fe78bSCy Schubert * \brief \b cc_ccache_get_credentials_version(): Get the credentials version of a ccache. 948*7f2fe78bSCy Schubert * 949*7f2fe78bSCy Schubert * cc_ccache_get_credentials_version() returns one value of the enumerated 950*7f2fe78bSCy Schubert * type cc_credentials_vers. The return value is #cc_credentials_v5 (if 951*7f2fe78bSCy Schubert * ccache's v5 principal has been set). A ccache's principal is set with 952*7f2fe78bSCy Schubert * one of cc_context_create_ccache(), cc_context_create_new_ccache(), 953*7f2fe78bSCy Schubert * cc_context_create_default_ccache(), or cc_ccache_set_principal(). 954*7f2fe78bSCy Schubert */ 955*7f2fe78bSCy Schubert cc_int32 (*get_credentials_version) (cc_ccache_t in_ccache, 956*7f2fe78bSCy Schubert cc_uint32 *out_credentials_version); 957*7f2fe78bSCy Schubert 958*7f2fe78bSCy Schubert /*! 959*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 960*7f2fe78bSCy Schubert * \param out_name on exit, a cc_string_t representing the name of \a in_ccache. 961*7f2fe78bSCy Schubert * \a out_name must be released with cc_string_release(). 962*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 963*7f2fe78bSCy Schubert * \brief \b cc_ccache_get_name(): Get the name of a ccache. 964*7f2fe78bSCy Schubert */ 965*7f2fe78bSCy Schubert cc_int32 (*get_name) (cc_ccache_t in_ccache, 966*7f2fe78bSCy Schubert cc_string_t *out_name); 967*7f2fe78bSCy Schubert 968*7f2fe78bSCy Schubert /*! 969*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 970*7f2fe78bSCy Schubert * \param in_credentials_version the credentials version to get the principal for. 971*7f2fe78bSCy Schubert * \param out_principal on exit, a cc_string_t representing the principal of \a in_ccache. 972*7f2fe78bSCy Schubert * \a out_principal must be released with cc_string_release(). 973*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 974*7f2fe78bSCy Schubert * \brief \b cc_ccache_get_principal(): Get the principal of a ccache. 975*7f2fe78bSCy Schubert * 976*7f2fe78bSCy Schubert * Return the principal for the ccache that was set via cc_context_create_ccache(), 977*7f2fe78bSCy Schubert * cc_context_create_default_ccache(), cc_context_create_new_ccache(), or 978*7f2fe78bSCy Schubert * cc_ccache_set_principal(). 979*7f2fe78bSCy Schubert */ 980*7f2fe78bSCy Schubert cc_int32 (*get_principal) (cc_ccache_t in_ccache, 981*7f2fe78bSCy Schubert cc_uint32 in_credentials_version, 982*7f2fe78bSCy Schubert cc_string_t *out_principal); 983*7f2fe78bSCy Schubert 984*7f2fe78bSCy Schubert 985*7f2fe78bSCy Schubert /*! 986*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 987*7f2fe78bSCy Schubert * \param in_credentials_version the credentials version to set the principal for. 988*7f2fe78bSCy Schubert * \param in_principal a C string representing the new principal of \a in_ccache. 989*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 990*7f2fe78bSCy Schubert * \brief \b cc_ccache_set_principal(): Set the principal of a ccache. 991*7f2fe78bSCy Schubert * 992*7f2fe78bSCy Schubert * Set the a principal for ccache. 993*7f2fe78bSCy Schubert */ 994*7f2fe78bSCy Schubert cc_int32 (*set_principal) (cc_ccache_t io_ccache, 995*7f2fe78bSCy Schubert cc_uint32 in_credentials_version, 996*7f2fe78bSCy Schubert const char *in_principal); 997*7f2fe78bSCy Schubert 998*7f2fe78bSCy Schubert /*! 999*7f2fe78bSCy Schubert * \param io_ccache a ccache object. 1000*7f2fe78bSCy Schubert * \param in_credentials_union the credentials to store in \a io_ccache. 1001*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1002*7f2fe78bSCy Schubert * \brief \b cc_ccache_store_credentials(): Store credentials in a ccache. 1003*7f2fe78bSCy Schubert * 1004*7f2fe78bSCy Schubert * Store a copy of credentials in the ccache. 1005*7f2fe78bSCy Schubert * 1006*7f2fe78bSCy Schubert * See the description of the credentials types for the meaning of 1007*7f2fe78bSCy Schubert * cc_credentials_union fields. 1008*7f2fe78bSCy Schubert * 1009*7f2fe78bSCy Schubert * Before credentials of a specific credential type can be stored in a 1010*7f2fe78bSCy Schubert * ccache, the corresponding principal version has to be set. That is, 1011*7f2fe78bSCy Schubert * before you can store Kerberos v5 credentials in a ccache, the Kerberos 1012*7f2fe78bSCy Schubert * v5 principal has to be set either by cc_context_create_ccache(), 1013*7f2fe78bSCy Schubert * cc_context_create_default_ccache(), cc_context_create_new_ccache(), or 1014*7f2fe78bSCy Schubert * cc_ccache_set_principal(); otherwise, ccErrBadCredentialsVersion is 1015*7f2fe78bSCy Schubert * returned. 1016*7f2fe78bSCy Schubert */ 1017*7f2fe78bSCy Schubert cc_int32 (*store_credentials) (cc_ccache_t io_ccache, 1018*7f2fe78bSCy Schubert const cc_credentials_union *in_credentials_union); 1019*7f2fe78bSCy Schubert 1020*7f2fe78bSCy Schubert /*! 1021*7f2fe78bSCy Schubert * \param io_ccache a ccache object. 1022*7f2fe78bSCy Schubert * \param in_credentials the credentials to remove from \a io_ccache. 1023*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1024*7f2fe78bSCy Schubert * \brief \b cc_ccache_remove_credentials(): Remove credentials from a ccache. 1025*7f2fe78bSCy Schubert * 1026*7f2fe78bSCy Schubert * Removes credentials from a ccache. Note that credentials must be previously 1027*7f2fe78bSCy Schubert * acquired from the CCache API; only exactly matching credentials will be 1028*7f2fe78bSCy Schubert * removed. (This places the burden of determining exactly which credentials 1029*7f2fe78bSCy Schubert * to remove on the caller, but ensures there is no ambigity about which 1030*7f2fe78bSCy Schubert * credentials will be removed.) cc_credentials_t objects can be obtained by 1031*7f2fe78bSCy Schubert * iterating over the ccache's credentials with cc_ccache_new_credentials_iterator(). 1032*7f2fe78bSCy Schubert * 1033*7f2fe78bSCy Schubert * If found, the credentials are removed from the ccache. The credentials 1034*7f2fe78bSCy Schubert * parameter is not modified and should be freed by the caller. It is 1035*7f2fe78bSCy Schubert * legitimate to call this function while an iterator is traversing the 1036*7f2fe78bSCy Schubert * ccache, and the deletion of a credential already returned by 1037*7f2fe78bSCy Schubert * cc_credentials_iterator_next() will not disturb sequence of credentials 1038*7f2fe78bSCy Schubert * returned by cc_credentials_iterator_next(). 1039*7f2fe78bSCy Schubert */ 1040*7f2fe78bSCy Schubert cc_int32 (*remove_credentials) (cc_ccache_t io_ccache, 1041*7f2fe78bSCy Schubert cc_credentials_t in_credentials); 1042*7f2fe78bSCy Schubert 1043*7f2fe78bSCy Schubert /*! 1044*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 1045*7f2fe78bSCy Schubert * \param out_credentials_iterator a credentials iterator for \a io_ccache. 1046*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1047*7f2fe78bSCy Schubert * \brief \b cc_ccache_new_credentials_iterator(): Iterate over credentials in a ccache. 1048*7f2fe78bSCy Schubert * 1049*7f2fe78bSCy Schubert * Allocates memory for iterator and initializes it. Successive calls to 1050*7f2fe78bSCy Schubert * cc_credentials_iterator_next() will return credentials from the ccache. 1051*7f2fe78bSCy Schubert * 1052*7f2fe78bSCy Schubert * If changes are made to the ccache while an iterator is being used on it, 1053*7f2fe78bSCy Schubert * the iterator must return at least the intersection, and at most the union, 1054*7f2fe78bSCy Schubert * of the set of credentials that were in the ccache when the iteration began 1055*7f2fe78bSCy Schubert * and the set of credentials that are in the ccache when it ends. 1056*7f2fe78bSCy Schubert */ 1057*7f2fe78bSCy Schubert cc_int32 (*new_credentials_iterator) (cc_ccache_t in_ccache, 1058*7f2fe78bSCy Schubert cc_credentials_iterator_t *out_credentials_iterator); 1059*7f2fe78bSCy Schubert 1060*7f2fe78bSCy Schubert /*! 1061*7f2fe78bSCy Schubert * \param io_source_ccache a ccache object to move. 1062*7f2fe78bSCy Schubert * \param io_destination_ccache a ccache object replace with the contents of \a io_source_ccache. 1063*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1064*7f2fe78bSCy Schubert * \brief \b cc_ccache_move(): Move the contents of one ccache into another, destroying the source. 1065*7f2fe78bSCy Schubert * 1066*7f2fe78bSCy Schubert * cc_ccache_move() atomically copies the credentials, credential versions and principals 1067*7f2fe78bSCy Schubert * from one ccache to another. On successful completion \a io_source_ccache will be 1068*7f2fe78bSCy Schubert * released and the ccache it points to will be destroyed. Any credentials previously 1069*7f2fe78bSCy Schubert * in \a io_destination_ccache will be replaced with credentials from \a io_source_ccache. 1070*7f2fe78bSCy Schubert * The only part of \a io_destination_ccache which remains constant is the name. Any other 1071*7f2fe78bSCy Schubert * callers referring to \a io_destination_ccache will suddenly see new data in it. 1072*7f2fe78bSCy Schubert * 1073*7f2fe78bSCy Schubert * Typically cc_ccache_move() is used when the caller wishes to safely overwrite the 1074*7f2fe78bSCy Schubert * contents of a ccache with new data which requires several steps to generate. 1075*7f2fe78bSCy Schubert * cc_ccache_move() allows the caller to create a temporary ccache 1076*7f2fe78bSCy Schubert * (which can be destroyed if any intermediate step fails) and the atomically copy 1077*7f2fe78bSCy Schubert * the temporary cache into the destination. 1078*7f2fe78bSCy Schubert */ 1079*7f2fe78bSCy Schubert cc_int32 (*move) (cc_ccache_t io_source_ccache, 1080*7f2fe78bSCy Schubert cc_ccache_t io_destination_ccache); 1081*7f2fe78bSCy Schubert 1082*7f2fe78bSCy Schubert /*! 1083*7f2fe78bSCy Schubert * \param io_ccache the ccache object for the ccache you wish to lock. 1084*7f2fe78bSCy Schubert * \param in_lock_type the type of lock to obtain. 1085*7f2fe78bSCy Schubert * \param in_block whether or not the function should block if the lock cannot be obtained immediately. 1086*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1087*7f2fe78bSCy Schubert * \brief \b cc_ccache_lock(): Lock a ccache. 1088*7f2fe78bSCy Schubert * 1089*7f2fe78bSCy Schubert * Attempts to acquire an advisory lock for a ccache. Allowed values for lock_type are: 1090*7f2fe78bSCy Schubert * 1091*7f2fe78bSCy Schubert * \li cc_lock_read: a read lock. 1092*7f2fe78bSCy Schubert * \li cc_lock_write: a write lock 1093*7f2fe78bSCy Schubert * \li cc_lock_upgrade: upgrade an already-obtained read lock to a write lock 1094*7f2fe78bSCy Schubert * \li cc_lock_downgrade: downgrade an already-obtained write lock to a read lock 1095*7f2fe78bSCy Schubert * 1096*7f2fe78bSCy Schubert * If block is cc_lock_block, lock() will not return until the lock is acquired. 1097*7f2fe78bSCy Schubert * If block is cc_lock_noblock, lock() will return immediately, either acquiring 1098*7f2fe78bSCy Schubert * the lock and returning ccNoError, or failing to acquire the lock and returning 1099*7f2fe78bSCy Schubert * an error explaining why. 1100*7f2fe78bSCy Schubert * 1101*7f2fe78bSCy Schubert * To avoid having to deal with differences between thread semantics on different 1102*7f2fe78bSCy Schubert * platforms, locks are granted per ccache, rather than per thread or per process. 1103*7f2fe78bSCy Schubert * That means that different threads of execution have to acquire separate contexts 1104*7f2fe78bSCy Schubert * in order to be able to synchronize with each other. 1105*7f2fe78bSCy Schubert * 1106*7f2fe78bSCy Schubert * The lock should be unlocked by using cc_ccache_unlock(). 1107*7f2fe78bSCy Schubert * 1108*7f2fe78bSCy Schubert * \note All locks are advisory. For example, callers which do not call 1109*7f2fe78bSCy Schubert * cc_ccache_lock() and cc_ccache_unlock() will not be prevented from writing 1110*7f2fe78bSCy Schubert * to the ccache when you have a read lock. This is because the CCAPI 1111*7f2fe78bSCy Schubert * locking was added after the first release and thus adding mandatory locks would 1112*7f2fe78bSCy Schubert * have changed the user experience and performance of existing applications. 1113*7f2fe78bSCy Schubert */ 1114*7f2fe78bSCy Schubert cc_int32 (*lock) (cc_ccache_t io_ccache, 1115*7f2fe78bSCy Schubert cc_uint32 in_lock_type, 1116*7f2fe78bSCy Schubert cc_uint32 in_block); 1117*7f2fe78bSCy Schubert 1118*7f2fe78bSCy Schubert /*! 1119*7f2fe78bSCy Schubert * \param io_ccache a ccache object. 1120*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1121*7f2fe78bSCy Schubert * \brief \b cc_ccache_unlock(): Unlock a ccache. 1122*7f2fe78bSCy Schubert */ 1123*7f2fe78bSCy Schubert cc_int32 (*unlock) (cc_ccache_t io_ccache); 1124*7f2fe78bSCy Schubert 1125*7f2fe78bSCy Schubert /*! 1126*7f2fe78bSCy Schubert * \param in_ccache a cache object. 1127*7f2fe78bSCy Schubert * \param out_last_default_time on exit, the last time the ccache was default. 1128*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1129*7f2fe78bSCy Schubert * \brief \b cc_ccache_get_change_time(): Get the last time a ccache was the default ccache. 1130*7f2fe78bSCy Schubert * 1131*7f2fe78bSCy Schubert * This function returns the last time when the ccache was made the default ccache. 1132*7f2fe78bSCy Schubert * This allows clients to sort the ccaches by how recently they were default, which 1133*7f2fe78bSCy Schubert * is useful for user listing of ccaches. If the ccache was never default, 1134*7f2fe78bSCy Schubert * ccErrNeverDefault is returned. 1135*7f2fe78bSCy Schubert */ 1136*7f2fe78bSCy Schubert cc_int32 (*get_last_default_time) (cc_ccache_t in_ccache, 1137*7f2fe78bSCy Schubert cc_time_t *out_last_default_time); 1138*7f2fe78bSCy Schubert 1139*7f2fe78bSCy Schubert /*! 1140*7f2fe78bSCy Schubert * \param in_ccache a cache object. 1141*7f2fe78bSCy Schubert * \param out_change_time on exit, the last time the ccache changed. 1142*7f2fe78bSCy Schubert * \return On success, #ccNoError. If the ccache was never the default ccache, 1143*7f2fe78bSCy Schubert * #ccErrNeverDefault. Otherwise, an error code representing the failure. 1144*7f2fe78bSCy Schubert * \brief \b cc_ccache_get_change_time(): Get the last time a ccache changed. 1145*7f2fe78bSCy Schubert * 1146*7f2fe78bSCy Schubert * This function returns the time of the most recent change made to a ccache. 1147*7f2fe78bSCy Schubert * By maintaining a local copy the caller can deduce whether or not the ccache has 1148*7f2fe78bSCy Schubert * been modified since the previous call to cc_ccache_get_change_time(). 1149*7f2fe78bSCy Schubert * 1150*7f2fe78bSCy Schubert * The time returned by cc_ccache_get_change_time() increases whenever: 1151*7f2fe78bSCy Schubert * 1152*7f2fe78bSCy Schubert * \li a credential is stored 1153*7f2fe78bSCy Schubert * \li a credential is removed 1154*7f2fe78bSCy Schubert * \li a ccache principal is changed 1155*7f2fe78bSCy Schubert * \li the ccache becomes the default ccache 1156*7f2fe78bSCy Schubert * \li the ccache is no longer the default ccache 1157*7f2fe78bSCy Schubert * 1158*7f2fe78bSCy Schubert * \note In order to be able to compare two values returned by cc_ccache_get_change_time(), 1159*7f2fe78bSCy Schubert * the caller must use the same ccache object to acquire them. Callers should maintain a 1160*7f2fe78bSCy Schubert * single ccache object in memory for cc_ccache_get_change_time() calls rather than 1161*7f2fe78bSCy Schubert * creating a new ccache object for every call. 1162*7f2fe78bSCy Schubert * 1163*7f2fe78bSCy Schubert * \sa wait_for_change 1164*7f2fe78bSCy Schubert */ 1165*7f2fe78bSCy Schubert cc_int32 (*get_change_time) (cc_ccache_t in_ccache, 1166*7f2fe78bSCy Schubert cc_time_t *out_change_time); 1167*7f2fe78bSCy Schubert 1168*7f2fe78bSCy Schubert /*! 1169*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 1170*7f2fe78bSCy Schubert * \param in_compare_to_ccache a ccache object to compare with \a in_ccache. 1171*7f2fe78bSCy Schubert * \param out_equal on exit, whether or not the two ccaches refer to the same ccache. 1172*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1173*7f2fe78bSCy Schubert * \brief \b cc_ccache_compare(): Compare two ccache objects. 1174*7f2fe78bSCy Schubert */ 1175*7f2fe78bSCy Schubert cc_int32 (*compare) (cc_ccache_t in_ccache, 1176*7f2fe78bSCy Schubert cc_ccache_t in_compare_to_ccache, 1177*7f2fe78bSCy Schubert cc_uint32 *out_equal); 1178*7f2fe78bSCy Schubert 1179*7f2fe78bSCy Schubert /*! 1180*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 1181*7f2fe78bSCy Schubert * \param in_credentials_version the credentials version to get the time offset for. 1182*7f2fe78bSCy Schubert * \param out_time_offset on exit, the KDC time offset for \a in_ccache for credentials version 1183*7f2fe78bSCy Schubert * \a in_credentials_version. 1184*7f2fe78bSCy Schubert * \return On success, #ccNoError if a time offset was obtained or #ccErrTimeOffsetNotSet 1185*7f2fe78bSCy Schubert * if a time offset has not been set. On failure, an error code representing the failure. 1186*7f2fe78bSCy Schubert * \brief \b cc_ccache_get_kdc_time_offset(): Get the KDC time offset for credentials in a ccache. 1187*7f2fe78bSCy Schubert * \sa set_kdc_time_offset, clear_kdc_time_offset 1188*7f2fe78bSCy Schubert * 1189*7f2fe78bSCy Schubert * Sometimes the KDC and client's clocks get out of sync. cc_ccache_get_kdc_time_offset() 1190*7f2fe78bSCy Schubert * returns the difference between the KDC and client's clocks at the time credentials were 1191*7f2fe78bSCy Schubert * acquired. This offset allows callers to figure out how much time is left on a given 1192*7f2fe78bSCy Schubert * credential even though the end_time is based on the KDC's clock not the client's clock. 1193*7f2fe78bSCy Schubert */ 1194*7f2fe78bSCy Schubert cc_int32 (*get_kdc_time_offset) (cc_ccache_t in_ccache, 1195*7f2fe78bSCy Schubert cc_uint32 in_credentials_version, 1196*7f2fe78bSCy Schubert cc_time_t *out_time_offset); 1197*7f2fe78bSCy Schubert 1198*7f2fe78bSCy Schubert /*! 1199*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 1200*7f2fe78bSCy Schubert * \param in_credentials_version the credentials version to get the time offset for. 1201*7f2fe78bSCy Schubert * \param in_time_offset the new KDC time offset for \a in_ccache for credentials version 1202*7f2fe78bSCy Schubert * \a in_credentials_version. 1203*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1204*7f2fe78bSCy Schubert * \brief \b cc_ccache_set_kdc_time_offset(): Set the KDC time offset for credentials in a ccache. 1205*7f2fe78bSCy Schubert * \sa get_kdc_time_offset, clear_kdc_time_offset 1206*7f2fe78bSCy Schubert * 1207*7f2fe78bSCy Schubert * Sometimes the KDC and client's clocks get out of sync. cc_ccache_set_kdc_time_offset() 1208*7f2fe78bSCy Schubert * sets the difference between the KDC and client's clocks at the time credentials were 1209*7f2fe78bSCy Schubert * acquired. This offset allows callers to figure out how much time is left on a given 1210*7f2fe78bSCy Schubert * credential even though the end_time is based on the KDC's clock not the client's clock. 1211*7f2fe78bSCy Schubert */ 1212*7f2fe78bSCy Schubert cc_int32 (*set_kdc_time_offset) (cc_ccache_t io_ccache, 1213*7f2fe78bSCy Schubert cc_uint32 in_credentials_version, 1214*7f2fe78bSCy Schubert cc_time_t in_time_offset); 1215*7f2fe78bSCy Schubert 1216*7f2fe78bSCy Schubert /*! 1217*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 1218*7f2fe78bSCy Schubert * \param in_credentials_version the credentials version to get the time offset for. 1219*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1220*7f2fe78bSCy Schubert * \brief \b cc_ccache_clear_kdc_time_offset(): Clear the KDC time offset for credentials in a ccache. 1221*7f2fe78bSCy Schubert * \sa get_kdc_time_offset, set_kdc_time_offset 1222*7f2fe78bSCy Schubert * 1223*7f2fe78bSCy Schubert * Sometimes the KDC and client's clocks get out of sync. cc_ccache_clear_kdc_time_offset() 1224*7f2fe78bSCy Schubert * clears the difference between the KDC and client's clocks at the time credentials were 1225*7f2fe78bSCy Schubert * acquired. This offset allows callers to figure out how much time is left on a given 1226*7f2fe78bSCy Schubert * credential even though the end_time is based on the KDC's clock not the client's clock. 1227*7f2fe78bSCy Schubert */ 1228*7f2fe78bSCy Schubert cc_int32 (*clear_kdc_time_offset) (cc_ccache_t io_ccache, 1229*7f2fe78bSCy Schubert cc_uint32 in_credentials_version); 1230*7f2fe78bSCy Schubert 1231*7f2fe78bSCy Schubert /*! 1232*7f2fe78bSCy Schubert * \param in_ccache a ccache object. 1233*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1234*7f2fe78bSCy Schubert * \brief \b cc_ccache_wait_for_change(): Wait for the next change to a ccache. 1235*7f2fe78bSCy Schubert * 1236*7f2fe78bSCy Schubert * This function blocks until the next change is made to the ccache referenced by 1237*7f2fe78bSCy Schubert * \a in_ccache. By repeatedly calling cc_ccache_wait_for_change() from 1238*7f2fe78bSCy Schubert * a worker thread the caller can effectively receive callbacks whenever the 1239*7f2fe78bSCy Schubert * ccache changes. This is considerably more efficient than polling 1240*7f2fe78bSCy Schubert * with cc_ccache_get_change_time(). 1241*7f2fe78bSCy Schubert * 1242*7f2fe78bSCy Schubert * cc_ccache_wait_for_change() will return whenever: 1243*7f2fe78bSCy Schubert * 1244*7f2fe78bSCy Schubert * \li a credential is stored 1245*7f2fe78bSCy Schubert * \li a credential is removed 1246*7f2fe78bSCy Schubert * \li the ccache principal is changed 1247*7f2fe78bSCy Schubert * \li the ccache becomes the default ccache 1248*7f2fe78bSCy Schubert * \li the ccache is no longer the default ccache 1249*7f2fe78bSCy Schubert * 1250*7f2fe78bSCy Schubert * \note In order to make sure that the caller doesn't miss any changes, 1251*7f2fe78bSCy Schubert * cc_ccache_wait_for_change() always returns immediately after the first time it 1252*7f2fe78bSCy Schubert * is called on a new ccache object. Callers must use the same ccache object 1253*7f2fe78bSCy Schubert * for successive calls to cc_ccache_wait_for_change() rather than creating a new 1254*7f2fe78bSCy Schubert * ccache object for every call. 1255*7f2fe78bSCy Schubert * 1256*7f2fe78bSCy Schubert * \sa get_change_time 1257*7f2fe78bSCy Schubert */ 1258*7f2fe78bSCy Schubert cc_int32 (*wait_for_change) (cc_ccache_t in_ccache); 1259*7f2fe78bSCy Schubert }; 1260*7f2fe78bSCy Schubert 1261*7f2fe78bSCy Schubert /*! 1262*7f2fe78bSCy Schubert * Function pointer table for cc_string_t. For more information see 1263*7f2fe78bSCy Schubert * \ref cc_string_reference. 1264*7f2fe78bSCy Schubert */ 1265*7f2fe78bSCy Schubert struct cc_string_f { 1266*7f2fe78bSCy Schubert /*! 1267*7f2fe78bSCy Schubert * \param io_string the string object to release. 1268*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1269*7f2fe78bSCy Schubert * \brief \b cc_string_release(): Release memory associated with a cc_string_t object. 1270*7f2fe78bSCy Schubert */ 1271*7f2fe78bSCy Schubert cc_int32 (*release) (cc_string_t io_string); 1272*7f2fe78bSCy Schubert }; 1273*7f2fe78bSCy Schubert 1274*7f2fe78bSCy Schubert /*! 1275*7f2fe78bSCy Schubert * Function pointer table for cc_credentials_t. For more information see 1276*7f2fe78bSCy Schubert * \ref cc_credentials_reference. 1277*7f2fe78bSCy Schubert */ 1278*7f2fe78bSCy Schubert struct cc_credentials_f { 1279*7f2fe78bSCy Schubert /*! 1280*7f2fe78bSCy Schubert * \param io_credentials the credentials object to release. 1281*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1282*7f2fe78bSCy Schubert * \brief \b cc_credentials_release(): Release memory associated with a cc_credentials_t object. 1283*7f2fe78bSCy Schubert */ 1284*7f2fe78bSCy Schubert cc_int32 (*release) (cc_credentials_t io_credentials); 1285*7f2fe78bSCy Schubert 1286*7f2fe78bSCy Schubert /*! 1287*7f2fe78bSCy Schubert * \param in_credentials a credentials object. 1288*7f2fe78bSCy Schubert * \param in_compare_to_credentials a credentials object to compare with \a in_credentials. 1289*7f2fe78bSCy Schubert * \param out_equal on exit, whether or not the two credentials objects refer to the 1290*7f2fe78bSCy Schubert * same credentials in the cache collection. 1291*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1292*7f2fe78bSCy Schubert * \brief \b cc_credentials_compare(): Compare two credentials objects. 1293*7f2fe78bSCy Schubert */ 1294*7f2fe78bSCy Schubert cc_int32 (*compare) (cc_credentials_t in_credentials, 1295*7f2fe78bSCy Schubert cc_credentials_t in_compare_to_credentials, 1296*7f2fe78bSCy Schubert cc_uint32 *out_equal); 1297*7f2fe78bSCy Schubert }; 1298*7f2fe78bSCy Schubert 1299*7f2fe78bSCy Schubert /*! 1300*7f2fe78bSCy Schubert * Function pointer table for cc_ccache_iterator_t. For more information see 1301*7f2fe78bSCy Schubert * \ref cc_ccache_iterator_reference. 1302*7f2fe78bSCy Schubert */ 1303*7f2fe78bSCy Schubert struct cc_ccache_iterator_f { 1304*7f2fe78bSCy Schubert /*! 1305*7f2fe78bSCy Schubert * \param io_ccache_iterator the ccache iterator object to release. 1306*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1307*7f2fe78bSCy Schubert * \brief \b cc_ccache_iterator_release(): Release memory associated with a cc_ccache_iterator_t object. 1308*7f2fe78bSCy Schubert */ 1309*7f2fe78bSCy Schubert cc_int32 (*release) (cc_ccache_iterator_t io_ccache_iterator); 1310*7f2fe78bSCy Schubert 1311*7f2fe78bSCy Schubert /*! 1312*7f2fe78bSCy Schubert * \param in_ccache_iterator a ccache iterator object. 1313*7f2fe78bSCy Schubert * \param out_ccache on exit, the next ccache in the cache collection. 1314*7f2fe78bSCy Schubert * \return On success, #ccNoError if the next ccache in the cache collection was 1315*7f2fe78bSCy Schubert * obtained or #ccIteratorEnd if there are no more ccaches. 1316*7f2fe78bSCy Schubert * On failure, an error code representing the failure. 1317*7f2fe78bSCy Schubert * \brief \b cc_ccache_iterator_next(): Get the next ccache in the cache collection. 1318*7f2fe78bSCy Schubert */ 1319*7f2fe78bSCy Schubert cc_int32 (*next) (cc_ccache_iterator_t in_ccache_iterator, 1320*7f2fe78bSCy Schubert cc_ccache_t *out_ccache); 1321*7f2fe78bSCy Schubert 1322*7f2fe78bSCy Schubert /*! 1323*7f2fe78bSCy Schubert * \param in_ccache_iterator a ccache iterator object. 1324*7f2fe78bSCy Schubert * \param out_ccache_iterator on exit, a copy of \a in_ccache_iterator. 1325*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1326*7f2fe78bSCy Schubert * \brief \b cc_ccache_iterator_clone(): Make a copy of a ccache iterator. 1327*7f2fe78bSCy Schubert */ 1328*7f2fe78bSCy Schubert cc_int32 (*clone) (cc_ccache_iterator_t in_ccache_iterator, 1329*7f2fe78bSCy Schubert cc_ccache_iterator_t *out_ccache_iterator); 1330*7f2fe78bSCy Schubert }; 1331*7f2fe78bSCy Schubert 1332*7f2fe78bSCy Schubert /*! 1333*7f2fe78bSCy Schubert * Function pointer table for cc_credentials_iterator_t. For more information see 1334*7f2fe78bSCy Schubert * \ref cc_credentials_iterator_reference. 1335*7f2fe78bSCy Schubert */ 1336*7f2fe78bSCy Schubert struct cc_credentials_iterator_f { 1337*7f2fe78bSCy Schubert /*! 1338*7f2fe78bSCy Schubert * \param io_credentials_iterator the credentials iterator object to release. 1339*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1340*7f2fe78bSCy Schubert * \brief \b cc_credentials_iterator_release(): Release memory associated with a cc_credentials_iterator_t object. 1341*7f2fe78bSCy Schubert */ 1342*7f2fe78bSCy Schubert cc_int32 (*release) (cc_credentials_iterator_t io_credentials_iterator); 1343*7f2fe78bSCy Schubert 1344*7f2fe78bSCy Schubert /*! 1345*7f2fe78bSCy Schubert * \param in_credentials_iterator a credentials iterator object. 1346*7f2fe78bSCy Schubert * \param out_credentials on exit, the next credentials in the ccache. 1347*7f2fe78bSCy Schubert * \return On success, #ccNoError if the next credential in the ccache was obtained 1348*7f2fe78bSCy Schubert * or #ccIteratorEnd if there are no more credentials. 1349*7f2fe78bSCy Schubert * On failure, an error code representing the failure. 1350*7f2fe78bSCy Schubert * \brief \b cc_credentials_iterator_next(): Get the next credentials in the ccache. 1351*7f2fe78bSCy Schubert */ 1352*7f2fe78bSCy Schubert cc_int32 (*next) (cc_credentials_iterator_t in_credentials_iterator, 1353*7f2fe78bSCy Schubert cc_credentials_t *out_credentials); 1354*7f2fe78bSCy Schubert 1355*7f2fe78bSCy Schubert /*! 1356*7f2fe78bSCy Schubert * \ingroup cc_credentials_iterator_reference 1357*7f2fe78bSCy Schubert * \param in_credentials_iterator a credentials iterator object. 1358*7f2fe78bSCy Schubert * \param out_credentials_iterator on exit, a copy of \a in_credentials_iterator. 1359*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1360*7f2fe78bSCy Schubert * \brief \b cc_credentials_iterator_clone(): Make a copy of a credentials iterator. 1361*7f2fe78bSCy Schubert */ 1362*7f2fe78bSCy Schubert cc_int32 (*clone) (cc_credentials_iterator_t in_credentials_iterator, 1363*7f2fe78bSCy Schubert cc_credentials_iterator_t *out_credentials_iterator); 1364*7f2fe78bSCy Schubert }; 1365*7f2fe78bSCy Schubert 1366*7f2fe78bSCy Schubert /*! 1367*7f2fe78bSCy Schubert * \ingroup cc_context_reference 1368*7f2fe78bSCy Schubert * \param out_context on exit, a new context object. Must be free with cc_context_release(). 1369*7f2fe78bSCy Schubert * \param in_version the requested API version. This should be the maximum version the 1370*7f2fe78bSCy Schubert * application supports. 1371*7f2fe78bSCy Schubert * \param out_supported_version if non-NULL, on exit contains the maximum API version 1372*7f2fe78bSCy Schubert * supported by the implementation. 1373*7f2fe78bSCy Schubert * \param out_vendor if non-NULL, on exit contains a pointer to a read-only C string which 1374*7f2fe78bSCy Schubert * contains a string describing the vendor which implemented the credentials cache API. 1375*7f2fe78bSCy Schubert * \return On success, #ccNoError. On failure, an error code representing the failure. 1376*7f2fe78bSCy Schubert * May return CCAPI v2 error CC_BAD_API_VERSION if #ccapi_version_2 is passed in. 1377*7f2fe78bSCy Schubert * \brief Initialize a new cc_context. 1378*7f2fe78bSCy Schubert */ 1379*7f2fe78bSCy Schubert CCACHE_API cc_int32 cc_initialize (cc_context_t *out_context, 1380*7f2fe78bSCy Schubert cc_int32 in_version, 1381*7f2fe78bSCy Schubert cc_int32 *out_supported_version, 1382*7f2fe78bSCy Schubert char const **out_vendor); 1383*7f2fe78bSCy Schubert 1384*7f2fe78bSCy Schubert 1385*7f2fe78bSCy Schubert /*! \defgroup helper_macros CCAPI Function Helper Macros 1386*7f2fe78bSCy Schubert * @{ */ 1387*7f2fe78bSCy Schubert 1388*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f release() */ 1389*7f2fe78bSCy Schubert #define cc_context_release(context) \ 1390*7f2fe78bSCy Schubert ((context) -> functions -> release (context)) 1391*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f get_change_time() */ 1392*7f2fe78bSCy Schubert #define cc_context_get_change_time(context, change_time) \ 1393*7f2fe78bSCy Schubert ((context) -> functions -> get_change_time (context, change_time)) 1394*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f get_default_ccache_name() */ 1395*7f2fe78bSCy Schubert #define cc_context_get_default_ccache_name(context, name) \ 1396*7f2fe78bSCy Schubert ((context) -> functions -> get_default_ccache_name (context, name)) 1397*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f open_ccache() */ 1398*7f2fe78bSCy Schubert #define cc_context_open_ccache(context, name, ccache) \ 1399*7f2fe78bSCy Schubert ((context) -> functions -> open_ccache (context, name, ccache)) 1400*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f open_default_ccache() */ 1401*7f2fe78bSCy Schubert #define cc_context_open_default_ccache(context, ccache) \ 1402*7f2fe78bSCy Schubert ((context) -> functions -> open_default_ccache (context, ccache)) 1403*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f create_ccache() */ 1404*7f2fe78bSCy Schubert #define cc_context_create_ccache(context, name, version, principal, ccache) \ 1405*7f2fe78bSCy Schubert ((context) -> functions -> create_ccache (context, name, version, principal, ccache)) 1406*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f create_default_ccache() */ 1407*7f2fe78bSCy Schubert #define cc_context_create_default_ccache(context, version, principal, ccache) \ 1408*7f2fe78bSCy Schubert ((context) -> functions -> create_default_ccache (context, version, principal, ccache)) 1409*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f create_new_ccache() */ 1410*7f2fe78bSCy Schubert #define cc_context_create_new_ccache(context, version, principal, ccache) \ 1411*7f2fe78bSCy Schubert ((context) -> functions -> create_new_ccache (context, version, principal, ccache)) 1412*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f new_ccache_iterator() */ 1413*7f2fe78bSCy Schubert #define cc_context_new_ccache_iterator(context, iterator) \ 1414*7f2fe78bSCy Schubert ((context) -> functions -> new_ccache_iterator (context, iterator)) 1415*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f lock() */ 1416*7f2fe78bSCy Schubert #define cc_context_lock(context, type, block) \ 1417*7f2fe78bSCy Schubert ((context) -> functions -> lock (context, type, block)) 1418*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f unlock() */ 1419*7f2fe78bSCy Schubert #define cc_context_unlock(context) \ 1420*7f2fe78bSCy Schubert ((context) -> functions -> unlock (context)) 1421*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f compare() */ 1422*7f2fe78bSCy Schubert #define cc_context_compare(context, compare_to, equal) \ 1423*7f2fe78bSCy Schubert ((context) -> functions -> compare (context, compare_to, equal)) 1424*7f2fe78bSCy Schubert /*! Helper macro for cc_context_f wait_for_change() */ 1425*7f2fe78bSCy Schubert #define cc_context_wait_for_change(context) \ 1426*7f2fe78bSCy Schubert ((context) -> functions -> wait_for_change (context)) 1427*7f2fe78bSCy Schubert 1428*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f release() */ 1429*7f2fe78bSCy Schubert #define cc_ccache_release(ccache) \ 1430*7f2fe78bSCy Schubert ((ccache) -> functions -> release (ccache)) 1431*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f destroy() */ 1432*7f2fe78bSCy Schubert #define cc_ccache_destroy(ccache) \ 1433*7f2fe78bSCy Schubert ((ccache) -> functions -> destroy (ccache)) 1434*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f set_default() */ 1435*7f2fe78bSCy Schubert #define cc_ccache_set_default(ccache) \ 1436*7f2fe78bSCy Schubert ((ccache) -> functions -> set_default (ccache)) 1437*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f get_credentials_version() */ 1438*7f2fe78bSCy Schubert #define cc_ccache_get_credentials_version(ccache, version) \ 1439*7f2fe78bSCy Schubert ((ccache) -> functions -> get_credentials_version (ccache, version)) 1440*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f get_name() */ 1441*7f2fe78bSCy Schubert #define cc_ccache_get_name(ccache, name) \ 1442*7f2fe78bSCy Schubert ((ccache) -> functions -> get_name (ccache, name)) 1443*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f get_principal() */ 1444*7f2fe78bSCy Schubert #define cc_ccache_get_principal(ccache, version, principal) \ 1445*7f2fe78bSCy Schubert ((ccache) -> functions -> get_principal (ccache, version, principal)) 1446*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f set_principal() */ 1447*7f2fe78bSCy Schubert #define cc_ccache_set_principal(ccache, version, principal) \ 1448*7f2fe78bSCy Schubert ((ccache) -> functions -> set_principal (ccache, version, principal)) 1449*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f store_credentials() */ 1450*7f2fe78bSCy Schubert #define cc_ccache_store_credentials(ccache, credentials) \ 1451*7f2fe78bSCy Schubert ((ccache) -> functions -> store_credentials (ccache, credentials)) 1452*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f remove_credentials() */ 1453*7f2fe78bSCy Schubert #define cc_ccache_remove_credentials(ccache, credentials) \ 1454*7f2fe78bSCy Schubert ((ccache) -> functions -> remove_credentials (ccache, credentials)) 1455*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f new_credentials_iterator() */ 1456*7f2fe78bSCy Schubert #define cc_ccache_new_credentials_iterator(ccache, iterator) \ 1457*7f2fe78bSCy Schubert ((ccache) -> functions -> new_credentials_iterator (ccache, iterator)) 1458*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f lock() */ 1459*7f2fe78bSCy Schubert #define cc_ccache_lock(ccache, type, block) \ 1460*7f2fe78bSCy Schubert ((ccache) -> functions -> lock (ccache, type, block)) 1461*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f unlock() */ 1462*7f2fe78bSCy Schubert #define cc_ccache_unlock(ccache) \ 1463*7f2fe78bSCy Schubert ((ccache) -> functions -> unlock (ccache)) 1464*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f get_last_default_time() */ 1465*7f2fe78bSCy Schubert #define cc_ccache_get_last_default_time(ccache, last_default_time) \ 1466*7f2fe78bSCy Schubert ((ccache) -> functions -> get_last_default_time (ccache, last_default_time)) 1467*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f get_change_time() */ 1468*7f2fe78bSCy Schubert #define cc_ccache_get_change_time(ccache, change_time) \ 1469*7f2fe78bSCy Schubert ((ccache) -> functions -> get_change_time (ccache, change_time)) 1470*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f move() */ 1471*7f2fe78bSCy Schubert #define cc_ccache_move(source, destination) \ 1472*7f2fe78bSCy Schubert ((source) -> functions -> move (source, destination)) 1473*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f compare() */ 1474*7f2fe78bSCy Schubert #define cc_ccache_compare(ccache, compare_to, equal) \ 1475*7f2fe78bSCy Schubert ((ccache) -> functions -> compare (ccache, compare_to, equal)) 1476*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f get_kdc_time_offset() */ 1477*7f2fe78bSCy Schubert #define cc_ccache_get_kdc_time_offset(ccache, version, time_offset) \ 1478*7f2fe78bSCy Schubert ((ccache) -> functions -> get_kdc_time_offset (ccache, version, time_offset)) 1479*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f set_kdc_time_offset() */ 1480*7f2fe78bSCy Schubert #define cc_ccache_set_kdc_time_offset(ccache, version, time_offset) \ 1481*7f2fe78bSCy Schubert ((ccache) -> functions -> set_kdc_time_offset (ccache, version, time_offset)) 1482*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f clear_kdc_time_offset() */ 1483*7f2fe78bSCy Schubert #define cc_ccache_clear_kdc_time_offset(ccache, version) \ 1484*7f2fe78bSCy Schubert ((ccache) -> functions -> clear_kdc_time_offset (ccache, version)) 1485*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_f wait_for_change() */ 1486*7f2fe78bSCy Schubert #define cc_ccache_wait_for_change(ccache) \ 1487*7f2fe78bSCy Schubert ((ccache) -> functions -> wait_for_change (ccache)) 1488*7f2fe78bSCy Schubert 1489*7f2fe78bSCy Schubert /*! Helper macro for cc_string_f release() */ 1490*7f2fe78bSCy Schubert #define cc_string_release(string) \ 1491*7f2fe78bSCy Schubert ((string) -> functions -> release (string)) 1492*7f2fe78bSCy Schubert 1493*7f2fe78bSCy Schubert /*! Helper macro for cc_credentials_f release() */ 1494*7f2fe78bSCy Schubert #define cc_credentials_release(credentials) \ 1495*7f2fe78bSCy Schubert ((credentials) -> functions -> release (credentials)) 1496*7f2fe78bSCy Schubert /*! Helper macro for cc_credentials_f compare() */ 1497*7f2fe78bSCy Schubert #define cc_credentials_compare(credentials, compare_to, equal) \ 1498*7f2fe78bSCy Schubert ((credentials) -> functions -> compare (credentials, compare_to, equal)) 1499*7f2fe78bSCy Schubert 1500*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_iterator_f release() */ 1501*7f2fe78bSCy Schubert #define cc_ccache_iterator_release(iterator) \ 1502*7f2fe78bSCy Schubert ((iterator) -> functions -> release (iterator)) 1503*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_iterator_f next() */ 1504*7f2fe78bSCy Schubert #define cc_ccache_iterator_next(iterator, ccache) \ 1505*7f2fe78bSCy Schubert ((iterator) -> functions -> next (iterator, ccache)) 1506*7f2fe78bSCy Schubert /*! Helper macro for cc_ccache_iterator_f clone() */ 1507*7f2fe78bSCy Schubert #define cc_ccache_iterator_clone(iterator, new_iterator) \ 1508*7f2fe78bSCy Schubert ((iterator) -> functions -> clone (iterator, new_iterator)) 1509*7f2fe78bSCy Schubert 1510*7f2fe78bSCy Schubert /*! Helper macro for cc_credentials_iterator_f release() */ 1511*7f2fe78bSCy Schubert #define cc_credentials_iterator_release(iterator) \ 1512*7f2fe78bSCy Schubert ((iterator) -> functions -> release (iterator)) 1513*7f2fe78bSCy Schubert /*! Helper macro for cc_credentials_iterator_f next() */ 1514*7f2fe78bSCy Schubert #define cc_credentials_iterator_next(iterator, credentials) \ 1515*7f2fe78bSCy Schubert ((iterator) -> functions -> next (iterator, credentials)) 1516*7f2fe78bSCy Schubert /*! Helper macro for cc_credentials_iterator_f clone() */ 1517*7f2fe78bSCy Schubert #define cc_credentials_iterator_clone(iterator, new_iterator) \ 1518*7f2fe78bSCy Schubert ((iterator) -> functions -> clone (iterator, new_iterator)) 1519*7f2fe78bSCy Schubert /*!@}*/ 1520*7f2fe78bSCy Schubert 1521*7f2fe78bSCy Schubert #if defined(__APPLE__) && (defined(__ppc__) || defined(__ppc64__) || defined(__i386__) || defined(__x86_64__)) 1522*7f2fe78bSCy Schubert #pragma pack(pop) 1523*7f2fe78bSCy Schubert #endif 1524*7f2fe78bSCy Schubert 1525*7f2fe78bSCy Schubert #ifdef __cplusplus 1526*7f2fe78bSCy Schubert } 1527*7f2fe78bSCy Schubert #endif /* __cplusplus */ 1528*7f2fe78bSCy Schubert 1529*7f2fe78bSCy Schubert #endif /* __CREDENTIALSCACHE__ */ 1530