HOWTO - Sashipa development
You wish to define how the Sashipa application manage user accounts.
Sashipa configuration is managed by the server part of the application. Tree mode are available:
In a single table in a database.
In a XML file.
No configuration: connections to the software will be always anonymous.
A configuration storage is defined for each server. In a client (gui instance), the server used for retrieving user profile is specified like this:
<guiInstance gui='guiDemoContact' type='application'>
<guiResourceName>GuiDemoContact</guiResourceName>
<usedConfigStorage server='srvDemoContact' />
<usedServerForDatabase server='srvDemoContact' database='dbDemoContact' />
... guiLoaderBinaryUnit ...
</guiInstance>
|
Note that if the config server hasn't any configuration storage, the client application will try to automatically connect itself as anonymous.
At first, an element 'sashipaConfigStorage' has to be described in the 'database' element of the Sashipa source file:
<database name='dbDemoContact'>
... physicalName ...
... singularName ...
<sashipaConfigStorage name='cfgMain'>
<configSashipaTable>
<physicalName>SASHIPA_CFG</physicalName>
</configSashipaTable>
</sashipaConfigStorage>
... schemaTableSet ...
|
Note: this declaration doesn't make the table accessible as a schemaTable.
Now you just have to reference this element from the 'server' part. Here is an example:
<serverSet>
<server name='srvDemoContact' type='embeddedInGui'>
... element dbConnection ...
<configStorage>
<configDbStorage database='dbDemoContact' sashipaConfigStorage='cfgMain' />
</configStorage>
... element logStorage ...
</server>
</serverSet>
|
The structure of the Sashipa configuration table must be:
CREATE TABLE SASHIPA_CFG (
s_id integer NOT NULL PRIMARY KEY,
s_type char(4) NOT NULL,
s_key varchar(100) NOT NULL,
s_value clob, -- replace 'clob' by the unlimited text
-- column type of your dbms
UNIQUE (s_type, s_key)
);
|
The s_type column will contain the type of data stored. In the case of storing user accounts, it contains always 'USER'. The s_key column will contain a value that identify the data stored, by type. Important: this text value is always stored in a lower case. In the case of storing user account, the login is stored here. The s_value contains data to store. In the user account case, it contains all user account information in a XML format.
A user profile is stored in a XML format. Here is an example:
<userProfile>
<login>Test</login>
<password>test</password>
<completeName>M. Test</completeName>
<accessRightSet defaultType='using'>
<accessRight guiModule='modMain' type='readOnly' />
<accessRight guiModule='modOther' type='noAccess' />
<accessRight guiModule='modAgain' type='default' />
</accessRightSet>
<entry guiStarting='startingDefault' />
</userProfile>
|
The elements accessRight define access right of the user for each module. If a module is missing, the value of attribute accessRightSet.defaultType will be used. Value 'default' means that the default value defined in the Server element of the Sashipa code will be used. (if the value is not defined in the server element, 'using' will be used). The element entry is optional. It references one of elements guiStarting of the Sashipa source file.
Now you have to manually insert users (the administration software is not ready). Example:
/* insert two users. Please note that values in s_key must be in lower case. */ |
Note: Database2Sashipa needs a table name that includes the string 'SASHIPA_CFG' for automatically recognizing this table as a configuration table. (The case isn't sensitive)
Now, let see an example for storing configuration in an external XML file. Here is the content of element 'configStorage':
<serverSet>
<server name='srvDemoContact' type='embeddedInGui'>
... element dbConnection ...
<configStorage>
<configFileStorage><
uri>SASHIPA_CFG.xml</uri>
</configFileStorage>
</configStorage>
... element logStorage ...
</server>
</serverSet>
|
Now you can see an example of content of the XML file 'SASHIPA_CFG.xml':
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE configStorage [
<!ELEMENT configStorage (userProfileSet) >
<!ATTLIST configStorage version CDATA #REQUIRED >
<!ELEMENT userProfileSet (userProfile*) >
<!ELEMENT userProfile (login, password, completeName, accessRightSet, entry?) >
<!ELEMENT login (#PCDATA) >
<!ELEMENT password (#PCDATA) >
<!ELEMENT completeName (#PCDATA) >
<!ELEMENT accessRightSet (accessRight*) >
<!ATTLIST accessRightSet defaultType (default | readOnly | using | noAccess) 'default' >
<!ELEMENT accessRight EMPTY >
<!ATTLIST accessRight guiModule CDATA #REQUIRED >
<!ATTLIST accessRight type (default | readOnly | using | noAccess) #REQUIRED >
<!ELEMENT entry EMPTY >
<!ATTLIST entry guiStarting CDATA #REQUIRED >
]>
<configStorage version='1.0.1'>
<userProfileSet>
<userProfile>
<login>anonymous</login>
<password></password>
<completeName>Anonymous</completeName>
<accessRightSet defaultType='readOnly' />
</userProfile>
<userProfile>
<login>Test</login>
<password>test</password>
<completeName>Mr Test</completeName>
<accessRightSet />
</userProfile>
</userProfileSet>
</configStorage>
|
Just define the configStorage element empty in the Sashipa source file:
<serverSet>
<server name='srvDemoContact' type='embeddedInGui'>
... element dbConnection ...
<configStorage />
... element logStorage ...
</server>
</serverSet>
|
This server will accept all connections from clients.
Remark: Login management is case insensitive. Password are of course case sensitive.
© Copyright 2004 Sashipa-Melba Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License as much as this note clearly appears.