|
CLASS moPasswd
NAME
Constructor -- initialize an moPasswd object
VERSION
Version: 1.2.0
SYNOPSIS
moPasswd(bool can_save = false);
PARAMETERS
can_save -- wether the current password list can be saved
DESCRIPTION
The constructor initializes an moPasswd object so you
can use it to read the read a password file.
The can_save parameter can be used to allow the Save()
instruction to work. Otherwise, the Save() instruction
will throw an error.
SEE ALSO
Load, Save, Find, Get
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moPasswd
NAME
Load -- load a password file
Save -- saves the current password info in a file
VERSION
Version: 1.2.0
SYNOPSIS
void Load(moTextStream& text_stream);
void Save(moTextStream& text_stream);
PARAMETERS
text_stream - a valid text stream to load/save from
DESCRIPTION
The Load() instruction reads the specified text stream,
line by line until it reaches the end of the file. The
entire file is always read. It is not expected to be
used on extremely large files. If you have a really
large number of users (or expect to have such a large
number), you may want to use either a database or one
file per letter or two letters of the beginning of the
login name of the users.
The previous list of passwords will be lost after the
Load() instruction was called even if the input file
can't be read.
Once a file was loaded, you can get the users using
one of the Find() or Get() functions.
The Save() instruction can be used to save the password
in a text stream. The text stream needs to have been
opened for writing. The Save() will not seek anywhere.
It is your responsability to seek at the beginning of
the file and resize it as required.
It is up to you to define the output stream with the
proper filter to save the text in UTF-8. Don't forget
that by default our text streams use UCS-32.
ERRORS
The constructor must have been called with 'true'
otherwise the Save() instruction will throw an error.
SEE ALSO
Find, Get, Constructor
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moPasswd
NAME
Find -- find an entry by name
Get -- get an entry by index
operator [] -- get a password by key or index
VERSION
Version: 1.2.0
SYNOPSIS
moUserSPtr Find(const moWCString& key, int column = 0, mode_t mode = MO_MODE_EQUAL);
moUserSPtr FindNextUser(void) const;
moUserSPtr operator [] (const moWCString& key);
moUserSPtr Get(int index);
moUserSPtr operator [] (int index);
PARAMETERS
key - a user name or some other entry string
column - the column to compare the key with
mode - the mode of comparison
index - the index to get
DESCRIPTION
The Find() function searches the list of entries and
returns the first one which matches the key. By default
it assumes that the key is compared as is and that the
first column has to be compared (i.e. column 0).
If you use a key which can match more than one entries,
then you can use the FindNextUser() function to search for
the following entries. You don't need to specify the
key, column and mode again. However, this feature is
not multi-thread safe in the even you want to modify
the password file. You will be responsible for proper
synchronization.
The mode is defined as follow:
MO_MODE_EQUAL compare the key and user
column entry letter for
letter
MO_MODE_CIEQUAL compare the key and user
column entry letter for
letter in case insensitive
manner
MO_MODE_REGEX assumes that the key is a
regular expression
MO_MODE_INTEGER assumes that the key and
column to be compared
are both integers
MO_MODE_IP assumes that the key and
column to be compared
are both IP addresses;
the key can include a
mask (x.x.x.x/m.m.m.m)
Empty entries, entries which are comments and entries
which have less columns than the column indicated for
search with Find() are all skipped.
The [] operator with a string searches like the default
Find() function. It assumes you want to search column
zero and that the key has to match exactly.
The Get() and [] operator with an integer both return
the entry at the specified index. The number of entries
can be queried with the Count() instruction. Trying to
get an entry which doesn't exist results in a throw.
Note that in this way you will get any moUser entry
including comments and empty lines.
We assume that you will use these instructions after
you loaded a password file. You can also create new
user entries and simply add them to the list before
to search for them later.
RETURN VALUE
All of these instructions return an moUser smart pointer
which can be null when the user isn't found.
ERRORS
The Get() instruction used with an index out of range
throws an error.
SEE ALSO
Load
BUGS
The Find() and FindNextUser() functions are not
thread safe. If you need to handle the same
password file in two different files, you
certainly want to synchronize them properly.
If you will only read the password file, then
you can simply use to moPasswd objects.
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moPasswd::moUser
NAME
Constructor -- initializes the moUser object
VERSION
Version: 1.2.0
SYNOPSIS
moPasswd::moUser(const moWCString& separators = ":");
PARAMETERS
separators - a list of separators
DESCRIPTION
Prepare an moUser object.
Please, see the moWords constructor for more information
about the separators.
SEE ALSO
SetWords()
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moPasswd::moUser
NAME
SetWords -- defines the different words from a single string
VERSION
Version: 1.2.0
SYNOPSIS
virtual unsigned long SetWords(const moWCString& words);
PARAMETERS
words - a list of words to cut into columns
DESCRIPTION
Accepts a string with the different entries you expect for
a user definition. The number of words and/or what they
contain is not constrained in any way. Words can also be
empty.
By default, the ':' is used as the separator. This can be
changed if you wish.
The strings are defined as in:
<word><sep><word><sep><word>...
By default, the words are clipped meaning that spaces at
the beginning and the end of the words are removed.
Words can also be quoted with single (') or double (")
quotes. In this case, they can include spaces and
separators.
EXAMPLES
The following are examples of what will be parsed:
# My password file
john:123:ZZPassword:?:"Smith, John"
foo:566:PassyWordy:123.11.23.123:"Wow"
In this case, the 1st line is taken as a comment
and the following are taken as users with 5 columns.
NOTES
You should not use the AddWords() with an moUser
object though it is permitted. Adding words doesn't
change the comment flag status. Thus you can append
a comment to another or add columns for a user
description.
SEE ALSO
SetWords() of the moWords class
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moPasswd::moUser
NAME
IsComment -- return true if this entry is a comment
VERSION
Version: 1.2.0
SYNOPSIS
bool IsComment(void) const;
DESCRIPTION
A line in the input password file may be a comment.
Comments are kept in moUser objects too so that way
we can save it back in the password file is required.
Yet, at times, a line is a comment. In this case, the
SetWords() function will set the comment flag to true.
Thought comments will also be cut in words, the words
shouldn't be used. Instead you should use the AllWords()
function to retrieve a comment.
EXAMPLES
The following are examples of what will be parsed:
# My password file
john:123:ZZPassword:?:"Smith, John"
foo:566:PassyWordy:123.11.23.123:"Wow"
In this case, the 1st line is taken as a comment
and the following are taken as users with 5 columns.
SEE ALSO
SetWords() of the moWords class
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
Links:
molib
the sandbox
|