das2C
das core C utilities (v3)
Public Member Functions
DasCredMngr Struct Reference

Credentials manager Handles a list of login credentials and supplies these as needed for network operations. More...

#include <das2/credentials.h>

Collaboration diagram for DasCredMngr:
Collaboration graph
[legend]

Public Member Functions

DAS_API DasCredMngrnew_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...
 

Detailed Description

Credentials manager Handles a list of login credentials and supplies these as needed for network operations.

Member Function Documentation

◆ new_CredMngr()

DAS_API DasCredMngr * new_CredMngr ( const char *  sKeyStore)

Initialize a new credentials manager, optionally from a saved list.

Parameters
sKeyStoreIf 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").
Returns
A new credentials manager allocated on the heap

◆ del_CredMngr()

DAS_API void del_CredMngr ( DasCredMngr pThis)

Delete a credentials manager free'ing it's internal credential store.

Parameters
pThisA pointer to the credentials manager structure to free. The pointer is no-longer valid after this call and should be set to NULL.

◆ CredMngr_getHttpAuth()

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.

Parameters
pThisA pointer to a credentials manager structure
sServerThe name of the server for which these credentials apply
sRealmA string identifing the system the user will be authenticating too.
sDatasetThe name of the dataset for which these credentials apply
Returns
The auth token, NULL if no auth token could be supplied

◆ CredMngr_authFailed()

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

Parameters
pThisA pointer to a credentials manager structure
sServerThe name of the server for which these credentials apply
sRealmA string identifing the system the user will be authenticating too.
sDatasetThe name of the dataset for which these credentials apply
sMsgan optional message providing more details on why authentication failed

◆ CredMngr_setPrompt()

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.

Parameters
pThisa pointer to a credentials manager structure
new_promptThe new function, or NULL if no password prompt should ever be issued
Returns
The old password prompt function

◆ CredMngr_save()

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

Parameters
pThisa pointer to a CredMngr structure
sSymKeyA key to use for encrypting the credentials file (Not yet implemented, added for stable ABI, use NULL here)
sFilethe 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.
Returns
The number of credential rows saved, or -1 on an error.

◆ CredMngr_load()

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

Parameters
pThisa pointer to a CredMngr structure
sSymKeyA key to use for encrypting the credentials file (Not yet implemented, added for stable ABI, use NULL here)
sFilethe 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.
Returns
The number of NEW credential sets and conditions. Thus loading the exact same file twice should return 0 on the second load.

The documentation for this struct was generated from the following file: