das2C
das core C utilities (v3)
Data Structures | Typedefs | Functions
credentials.h File Reference

Handle storing credentials during a Das2 session and optionally save them to a file. More...

#include <stdio.h>
#include <das2/array.h>
Include dependency graph for credentials.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  das_credential
 A single credential. More...
 
struct  DasCredMngr
 Credentials manager Handles a list of login credentials and supplies these as needed for network operations. More...
 

Typedefs

typedef bool(* das_prompt) (const char *sServer, const char *sRealm, const char *sDataset, const char *sMessage, char *sUser, char *sPassword)
 Function signature for swapping out the user-prompt for credentials acquisition. More...
 

Functions

DAS_API char * das_b64_encode (const unsigned char *data, size_t input_length, size_t *output_length)
 Encode provided binary data as base64 characters in a new buffer. More...
 
DAS_API int CredMngr_addCred (DasCredMngr *pThis, const das_credential *pCred)
 Manually add a credential to a credentials manager instead of prompting the user. More...
 
DAS_API das_credentialCredMngr_getCred (DasCredMngr *pThis, const char *sServer, const char *sRealm, const char *sDataset, bool bValidOnly)
 Get direct memory access to a stored credential. More...
 
DAS_API int CredMngr_addUserPass (DasCredMngr *pThis, const char *sServer, const char *sRealm, const char *sDataset, const char *sUser, const char *sPass)
 Manually add a credential to a credentials manager instead of prompting the user. More...
 

Detailed Description

Handle storing credentials during a Das2 session and optionally save them to a file.

Function Documentation

◆ CredMngr_addCred()

DAS_API int CredMngr_addCred ( DasCredMngr pThis,
const das_credential pCred 
)

Manually add a credential to a credentials manager instead of prompting the user.

Typically when the credentials manager does not have a password it needs it calls the prompt function that was set using CredMngr_setPrompt() or the built in command line prompter if no prompt function has been set.

Parameters
pThisThe credentials manager structure that will hold the new credential in RAM
pCredThe credential to add. If an existing credential matches this one except for the hash value, the new hash will overwrite the old one.
Returns
The new number of cached credentials

◆ CredMngr_getCred()

DAS_API das_credential* CredMngr_getCred ( DasCredMngr pThis,
const char *  sServer,
const char *  sRealm,
const char *  sDataset,
bool  bValidOnly 
)

Get direct memory access to a stored credential.

Used by other functions to find a credential for a particular URL

Parameters
pThisA credentials manager
sServerThe service end point (A URL without fragments or query params)
sRealmThe security realm
sDatasetIf not NULL, the dataset parameter must equal this
bValidOnlyOnly return valid credentials. Credentials are assmed valid unless
Returns
A pointer to the in-memory credential, NULL if no credential matched the given conditions

◆ CredMngr_addUserPass()

DAS_API int CredMngr_addUserPass ( DasCredMngr pThis,
const char *  sServer,
const char *  sRealm,
const char *  sDataset,
const char *  sUser,
const char *  sPass 
)

Manually add a credential to a credentials manager instead of prompting the user.

This is a individual string version of CredMngr_addCred that calculates it's own base64 hash.

Parameters
pThisThe credentials manager structure that will hold the new credential in RAM
sServerThe resource URL including the path, but not including fragments or query parameters
sRealmThe security realm to which this credential shoud be supplied
sDatasetIf not NULL, the value of the 'dataset=' parameter that must be present for this credential to apply
sUserA user name
sPassA plain-text password
Returns
The new number of cached credentials, or -1 on an error