Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
JUserCont Struct Reference

Detailed Description

User database implementing UserIntf, loaded from a parsed JSON object.

Object member names are usernames. Each user requires pwd and roles:

{"operator":{"pwd":"replace-this-password","roles":["viewer"],"maxUsers":5}}

pwd is a string, or an array whose first string is a 32-character HA1 value for the MD5 authentication variant. The remaining array elements are not used. roles is an array of role-name strings; an empty array or empty object means no roles. In JConstrCont, users without roles have super-user access.

Optional maxUsers (also accepted as maxusers) is an integer, default 5, clamped to 0..65535; zero omits the user. inactive is a nonnegative integer timeout in seconds, default zero; negative values become zero. recycle is a boolean, default FALSE. Missing or wrong-type optional values use defaults. Passwords longer than 98 bytes are stored but cannot be returned through the current AuthInfo password buffer, so authentication will fail for that user.

Updates replace the user list without rollback; role-name mappings persist until destruction. Serialize database updates with readers and authorizers.

#include <JUserCont.h>

Inheritance diagram for JUserCont:

Public Member Functions

 JUserCont (AllocatorIntf *alloc)
 Initialize an empty database without copying the allocator. More...
 
 ~JUserCont ()
 Release users and role mappings. More...
 
void setUserDb (JVal *usersVal, JErr *err)
 Replace users from the JSON schema described by JUserCont. More...
 
- Public Member Functions inherited from UserIntf
 UserIntf (UserIntf_GetPwd getPwd)
 The UserIntf constructor. More...
 

Constructor & Destructor Documentation

◆ JUserCont()

JUserCont::JUserCont ( AllocatorIntf alloc)

Initialize an empty database without copying the allocator.

Parameters
[in]allocBorrowed allocator, or NULL for the default allocator. The allocator must outlive the database.

◆ ~JUserCont()

JUserCont::~JUserCont ( )

Release users and role mappings.

Detach users of this UserIntf, including any JConstrCont, before destruction.

Member Function Documentation

◆ setUserDb()

void JUserCont::setUserDb ( JVal usersVal,
JErr err 
)

Replace users from the JSON schema described by JUserCont.

Parameters
[in]usersValRequired parsed JVal object. Strings are copied, so the tree can be released after the call. Usernames must be unique.
[in,out]errRequired initialized JErr receiving reported format or allocation errors. Old users are removed first; failure can leave a partially populated database. No value is returned.