Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
JUserCont.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: JUserCont.h 5978 2026-09-11 16:13:48Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2007-2013
17 *
18 * This software is copyrighted by and is the sole property of Real
19 * Time Logic LLC. All rights, title, ownership, or other interests in
20 * the software remain the property of Real Time Logic LLC. This
21 * software may only be used in accordance with the terms and
22 * conditions stipulated in the corresponding license agreement under
23 * which the software has been supplied. Any unauthorized use,
24 * duplication, transmission, distribution, or disclosure of this
25 * software is expressly forbidden.
26 *
27 * This Copyright notice may not be removed or modified without prior
28 * written consent of Real Time Logic LLC.
29 *
30 * Real Time Logic LLC. reserves the right to modify this software
31 * without notice.
32 *
33 * http://www.realtimelogic.com
34 ****************************************************************************
35 *
36 */
37
40#ifndef __JUserCont_h
41#define __JUserCont_h
42
43#include <AuthenticatedUser.h>
44#include <SplayTree.h>
45#include <JVal.h>
46
47typedef struct
48{
49 SplayTreeNode super;
50 char* name; /* Pointer to memory below roles. */
51 char* pwd; /* Pointer to memory below name. */
52 BaTime maxInactiveInterval;
53 U16 noOfRoles;
54 U16 maxUsers;
55 BaBool recycle;
56 BaBool pwdIsHA1;
57 /* Roles array must be last. */
58 U16 roles[1]; /* List of roles. Roles are translated into unique numbers. */
59} JUser;
60
61
62typedef struct
63{
64 SplayTreeNode super;
65 U16 roleId;
66 char name[1];
67} JRole;
68
69
90typedef struct JUserCont
91#ifdef __cplusplus
92 : public UserIntf
93{
100 ~JUserCont();
107 void setUserDb(JVal* usersVal, JErr* err);
108#else
109{
110 UserIntf super; /* We inherit from UserIntf. */
111#endif
112
113 SplayTree userdb; /* JUser */
114 SplayTree roledb; /* JRole */
115 AllocatorIntf* alloc;
116 U32 noOfUsers;
117 U16 nextUniqueRoleId;
119
120#ifdef __cplusplus
121extern "C" {
122#endif
123#define JUserCont_findUser(o, uname) \
124 (JUser*)SplayTree_find(&(o)->userdb, uname)
125U16 JUserCont_role2Id(JUserCont* o, const char* roleName);
126U16* JUserCont_copyRoles(JUserCont* o,U16* roles,JVal* rolesVal,JErr* err);
139BA_API void JUserCont_setUserDb(JUserCont* o, JVal* usersVal, JErr* err);
140#ifdef __cplusplus
141}
143 JUserCont_constructor(this, alloc); }
145 JUserCont_destructor(this); }
146inline void JUserCont::setUserDb(JVal* usersVal, JErr* err) {
147 JUserCont_setUserDb(this, usersVal, err); }
148#endif
149
150#endif
BA_API void JUserCont_setUserDb(JUserCont *o, JVal *usersVal, JErr *err)
Replace the user database without rollback.
BA_API void JUserCont_destructor(JUserCont *o)
Release all users and role mappings.
BA_API void JUserCont_constructor(JUserCont *o, AllocatorIntf *alloc)
Initialize a user database.
uint16_t U16
Unsigned 16-bit integer.
Definition: GenPrimT.h:91
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:103
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:98
The JSON error container object.
Definition: JParser.h:173
User database implementing UserIntf, loaded from a parsed JSON object.
Definition: JUserCont.h:93
~JUserCont()
Release users and role mappings.
Definition: JUserCont.h:144
JUserCont(AllocatorIntf *alloc)
Initialize an empty database without copying the allocator.
Definition: JUserCont.h:142
void setUserDb(JVal *usersVal, JErr *err)
Replace users from the JSON schema described by JUserCont.
Definition: JUserCont.h:146
JVal represents a value in a JSON tree.
Definition: JVal.h:78
Intrusive tree node.
Definition: SplayTree.h:52
Self-adjusting tree of caller-owned nodes, with unique keys.
Definition: SplayTree.h:109
User database interface used by the authentication classes.
Definition: AuthenticatedUser.h:195