libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
credentials.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Chris Piker <chris-piker@uiowa.edu>
2  *
3  * This file is part of libdas2, the Core Das2 C Library.
4  *
5  * Libdas2 is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef _das_credmngr_h_
19 #define _das_credmngr_h_
20 
21 #include <stdio.h>
22 
23 #include <das2/array.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
49 typedef bool (*das_prompt)(
50  const char* sServer, const char* sRealm, const char* sDataset,
51  const char* sMessage, char* sUser, char* sPassword
52 );
53 
55 typedef struct das_credential_t{
56  bool bValid;
57  char sServer[128];
58  char sRealm[128];
59  char sDataset[128];
60  char sHash[256];
62 
63 
85 bool das_cred_init(
86  das_credential* pCred, const char* sServer, const char* sRealm,
87  const char* sDataset, const char* sHash
88 );
89 
94 typedef struct das_credmngr{
95  DasAry* pCreds;
96  das_prompt prompt;
97  const char* sKeyFile;
98  char sLastAuthMsg[1024];
99 } DasCredMngr;
100 
110 DasCredMngr* new_CredMngr(const char* sKeyStore);
111 
118 void del_CredMngr(DasCredMngr* pThis);
119 
134 int CredMngr_addCred(DasCredMngr* pThis, const das_credential* pCred);
135 
146 const char* CredMngr_getHttpAuth(
147  DasCredMngr* pThis, const char* sServer, const char* sRealm, const char* sDataset
148 );
149 
165  DasCredMngr* pThis, const char* sServer, const char* sRealm,
166  const char* sDataset, const char* sMsg
167 );
168 
169 
183 
190 bool CredMngr_save(const DasCredMngr* pThis, const char* sFile);
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* _das_credmngr_h_ */
197 
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.
Definition: credentials.h:49
DasCredMngr * new_CredMngr(const char *sKeyStore)
Initialize a new credentials manager, optionally from a saved list.
Credentials manager Handles a list of login credentials and supplies these as needed for network oper...
Definition: credentials.h:94
A single credential.
Definition: credentials.h:55
das_prompt CredMngr_setPrompt(DasCredMngr *pThis, das_prompt new_prompt)
Change the function used to prompt users for das2 server credentials.
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.
A dynamic buffer with multi-dimensional array style access.
void del_CredMngr(DasCredMngr *pThis)
Delete a credentials manager free&#39;ing it&#39;s internal credential store.
bool CredMngr_save(const DasCredMngr *pThis, const char *sFile)
Save the current credentials to the given filename.
int CredMngr_addCred(DasCredMngr *pThis, const das_credential *pCred)
Manually add a credential to a credentials manager instead of prompting the user. ...
bool das_cred_init(das_credential *pCred, const char *sServer, const char *sRealm, const char *sDataset, const char *sHash)
Initialize a credential to be cached in the credentials manager.
const char * CredMngr_getHttpAuth(DasCredMngr *pThis, const char *sServer, const char *sRealm, const char *sDataset)
Retrive an HTTP basic authentication token for a given dataset on a given server. ...
Dynamic recursive ragged arrays.
Definition: array.h:193