def add_group(arguments): node_map = proceed_with_node() if node_map is not None: if len(arguments) < 1: cli_error('You must pass at least 1 argument to this command: ' 'the name of the group.') else: groupname_str = arguments.popleft() # Parse group UUID (optional) try: group_uuid = UUID(arguments[0]) # Parsed successfully arguments.popleft() except (IndexError, ValueError): group_uuid = gen_uuid() user_group = UserGroup(uuid=UserGroupUUID.safe_cast_uuid( group_uuid), name=str(groupname_str), private=False, enc_key=gen_rand_key()) NodeApp.add_ugroup(user_group) print(u'Added group "{}" with UUID {}' .format(groupname_str, group_uuid))
def add_user_with_group(cls, username, group_uuid, digest, is_trusted, dw): """Add the user (and the appropriate group to the data stores). @param group_uuid: UUID of the user group. @type group_uuid: UserGroupUUID @param is_trusted: whether the user stands for the Trusted Hosts. @type is_trusted: bool @param dw: data wrapper @type dw: DataWrapper """ enc_key = gen_rand_key() group = UserGroup(uuid=group_uuid, name=username, private=True, enc_key=enc_key) TrustedQueries.TrustedUsers.add_user_with_group(username, group, digest, dw.rdbw) FDBQueries.Users.add_user(username=username, digest=digest, is_trusted=is_trusted, fdbw=dw.fdbw)
def add_user_with_group(cls, username, group_uuid, digest, is_trusted, dw): """Add the user (and the appropriate group to the data stores). @param group_uuid: UUID of the user group. @type group_uuid: UserGroupUUID @param is_trusted: whether the user stands for the Trusted Hosts. @type is_trusted: bool @param dw: data wrapper @type dw: DataWrapper """ enc_key = gen_rand_key() group = UserGroup(uuid=group_uuid, name=username, private=True, enc_key=enc_key) TrustedQueries.TrustedUsers.add_user_with_group( username, group, digest, dw.rdbw) FDBQueries.Users.add_user(username=username, digest=digest, is_trusted=is_trusted, fdbw=dw.fdbw)