user_details.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
22 #ifndef USER_DETAILS_H
23 #define USER_DETAILS_H
24 
25 #include "jansson.h"
26 
27 #include "typedefs.h"
29 #include "linked_list.h"
30 
31 
37 typedef struct UserAuthentication
38 {
44 
47 
50 
54 
55 
61 typedef struct UserAuthenticationNode
62 {
65 
68 
70 
71 
76 typedef struct UserDetails
77 {
80 } UserDetails;
81 
82 
83 #ifdef __cplusplus
84 extern "C"
85 {
86 #endif
87 
88 
97 GRASSROOTS_UTIL_API UserDetails *AllocateUserDetails (const json_t *credentials_p);
98 
99 
106 GRASSROOTS_UTIL_API void FreeUserDetails (UserDetails *user_details_p);
107 
108 
117 GRASSROOTS_UTIL_API UserAuthentication *GetUserAuthenticationForSystem (const UserDetails *user_p, const char *system_s);
118 
119 
128 GRASSROOTS_UTIL_API UserAuthentication *GetUserAuthenticationForSystemFromJSON (const json_t *config_p, const char *system_s);
129 
130 
142 GRASSROOTS_UTIL_API bool AddUserAuthentication (UserDetails *user_details_p, const char *system_s, const char *username_s, const char *password_s, const char *token_s);
143 
144 
155 GRASSROOTS_UTIL_API UserAuthentication *AllocateUserAuthentication (const char *system_s, const char *username_s, const char *password_s, const char *token_s);
156 
157 
164 GRASSROOTS_UTIL_API void FreeUserAuthentication (UserAuthentication *auth_p);
165 
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 
172 #endif /* #ifndef USER_DETAILS_H */
bool AddUserAuthentication(UserDetails *user_details_p, const char *system_s, const char *username_s, const char *password_s, const char *token_s)
This will create and add the UserAuthentication details for a given system.
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
UserAuthentication * uan_auth_p
A pointer to the UserAuthentication details.
Definition: user_details.h:67
A datatype to store user credentials for a single system.
Definition: user_details.h:37
void FreeUserDetails(UserDetails *user_details_p)
Free a UserDetails.
UserAuthentication * GetUserAuthenticationForSystemFromJSON(const json_t *config_p, const char *system_s)
Get the UserAuthentication details for a given system from a given JSON fragment.
char * ua_oath_totp_token_s
An OAth token for time-based authentication.
Definition: user_details.h:52
A datatype to store UserAuthentications on a LinkedList.
Definition: user_details.h:61
char * ua_system_id_s
An identifier for the system that this UserAuthentication is for.
Definition: user_details.h:43
A doubly-linked list.
UserAuthentication * GetUserAuthenticationForSystem(const UserDetails *user_p, const char *system_s)
Get the UserAuthentication details for a given system.
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
UserAuthentication * AllocateUserAuthentication(const char *system_s, const char *username_s, const char *password_s, const char *token_s)
Allocate a UserAuthentication for a given system.
char * ua_password_s
The encrypted password.
Definition: user_details.h:49
UserDetails * AllocateUserDetails(const json_t *credentials_p)
Allocate a UserDetails with the given username.
void FreeUserAuthentication(UserAuthentication *auth_p)
Free a UserAuthentication.
A datatype to store user credentials.
Definition: user_details.h:76
char * ua_username_s
The username.
Definition: user_details.h:46
LinkedList * ud_auth_list_p
A LinkedList of UserAuthenticationNodes.
Definition: user_details.h:79
ListItem uan_base_node
The base ListItem to allow the storage of UserAuthenticationNodes on a LinkedList.
Definition: user_details.h:64