![]() |
das2C
das core C utilities (v3)
|
Credentials manager Handles a list of login credentials and supplies these as needed for network operations. More...
#include <das2/credentials.h>
Public Member Functions | |
DAS_API DasCredMngr * | new_CredMngr (const char *sKeyStore) |
Initialize a new credentials manager, optionally from a saved list. More... | |
DAS_API void | del_CredMngr (DasCredMngr *pThis) |
Delete a credentials manager free'ing it's internal credential store. More... | |
DAS_API const char * | CredMngr_getHttpAuth (DasCredMngr *pThis, const char *sServer, const char *sRealm, const char *sDataset) |
Retrieve an HTTP basic authentication token for a given dataset on a given server. More... | |
DAS_API void | CredMngr_authFailed (DasCredMngr *pThis, const char *sServer, const char *sRealm, const char *sDataset, const char *sMsg) |
Let the credentials manager know that a particular authorization method failed. More... | |
DAS_API das_prompt | CredMngr_setPrompt (DasCredMngr *pThis, das_prompt new_prompt) |
Change the function used to prompt users for das2 server credentials. More... | |
DAS_API int | CredMngr_save (DasCredMngr *pThis, const char *sSymKey, const char *sFile) |
Save the current credentials to the given filename. More... | |
DAS_API int | CredMngr_load (DasCredMngr *pThis, const char *sSymKey, const char *sFile) |
Merge in credentials from the given filename. More... | |
Credentials manager Handles a list of login credentials and supplies these as needed for network operations.
DAS_API DasCredMngr * new_CredMngr | ( | const char * | sKeyStore | ) |
Initialize a new credentials manager, optionally from a saved list.
sKeyStore | If not NULL this saves the name of the intended credentials storage file. It DOES NOT LOAD ANYTHING! To load credentials use CredMngr_load(pThis, "myencryptkey"). |
DAS_API void del_CredMngr | ( | DasCredMngr * | pThis | ) |
Delete a credentials manager free'ing it's internal credential store.
pThis | A pointer to the credentials manager structure to free. The pointer is no-longer valid after this call and should be set to NULL. |
DAS_API const char * CredMngr_getHttpAuth | ( | DasCredMngr * | pThis, |
const char * | sServer, | ||
const char * | sRealm, | ||
const char * | sDataset | ||
) |
Retrieve an HTTP basic authentication token for a given dataset on a given server.
Side Effect: This may call the .prompt() method, which may initiate Terminal IO.
pThis | A pointer to a credentials manager structure |
sServer | The name of the server for which these credentials apply |
sRealm | A string identifing the system the user will be authenticating too. |
sDataset | The name of the dataset for which these credentials apply |
DAS_API void CredMngr_authFailed | ( | DasCredMngr * | pThis, |
const char * | sServer, | ||
const char * | sRealm, | ||
const char * | sDataset, | ||
const char * | sMsg | ||
) |
Let the credentials manager know that a particular authorization method failed.
The credentials manager can use this information to re-prompt the user if desired
pThis | A pointer to a credentials manager structure |
sServer | The name of the server for which these credentials apply |
sRealm | A string identifing the system the user will be authenticating too. |
sDataset | The name of the dataset for which these credentials apply |
sMsg | an optional message providing more details on why authentication failed |
DAS_API das_prompt CredMngr_setPrompt | ( | DasCredMngr * | pThis, |
das_prompt | new_prompt | ||
) |
Change the function used to prompt users for das2 server credentials.
The built-in password prompt function assumes a console application, it asks for a username then tries to set the controlling terminal to non-echoing I/O and asks for a password. It never returns false, so authentication is endless cycle. For long running programs a different function should be supplied here.
pThis | a pointer to a credentials manager structure |
new_prompt | The new function, or NULL if no password prompt should ever be issued |
DAS_API int CredMngr_save | ( | DasCredMngr * | pThis, |
const char * | sSymKey, | ||
const char * | sFile | ||
) |
Save the current credentials to the given filename.
NOTE: The credentials file is not encrypted. It could be since openssl is a required dependency of das2C, but the functionality to do so hasn't been implemented
pThis | a pointer to a CredMngr structure |
sSymKey | A key to use for encrypting the credentials file (Not yet implemented, added for stable ABI, use NULL here) |
sFile | the file to hold the loosly encypted credentials. If NULL then the keyfile indicated in the constructor, new_CredMngr() is used. If the file does not exist it is created. |
DAS_API int CredMngr_load | ( | DasCredMngr * | pThis, |
const char * | sSymKey, | ||
const char * | sFile | ||
) |
Merge in credentials from the given filename.
NOTE: The credentials file is not encrypted. It could be since openssl is a required dependency of das2C, but the functionality to do so hasn't been implemented
pThis | a pointer to a CredMngr structure |
sSymKey | A key to use for encrypting the credentials file (Not yet implemented, added for stable ABI, use NULL here) |
sFile | the file to hold the loosly encypted credentials. If the file does not exist, 0 is returned. Thus a missing credentials file is not considered an error. If sFile is NULL, then the keyfile given in the constructor, new_CredMngr() is used. |