Scope: client and server, all versions.
This configures a Apache Derby store. Derby is a lightweight relational database written in Java. It is quite easy to set up and run and is full-featured, with support for standard SQL. It is much less work than one of the big databases (e.g. MySQL) to maintain.
As of version 5.5, OA4MP support Derby in various modes:
In this case, you do not need to have Derby installed at all. OA4MP will handle the details. All you need to do is set up access to it. If you do not supply credentials, default credentials will be used. Since there is no external access from outside the system, as long as you have the correct permissions set for the directory where the file store resides it should be secure.
Attribute | Required? | Default | Description |
createScript | N | -- | If you do not create this and want the system to do so, then specify the script here that contains all of the tables. If you do not specify it, the system will use whatever the current release version of this script is automatically (which is included in the OA4MP distro.) This must be the full path on your system. |
path | Y | -- | The physical path to the database file store. Note that this is the directory where the database resides. If you do not specify it explicitly as the database property. |
storeType | Y | file | This is required and is what tells OA4MP to use Derby as file store mode. If it is missing, the assumption is that it is a standard database. It may also have the value of memory for a memory store. |
<derby username="oa4mp" password="6eXSbO_W" bootPassword="o7MtXykd" storeType="file" path="/opt/oa4mp/test" schema="oauth2"> <!-- all the stores --> <derby/>
<derby storeType="file" path="/opt/oa4mp" > <!-- all the stores --> </derby>
This creates a file store which resides at "/opt/oa4mp/derby".
In this mode, the database is created and resides wholly in memory. It is not persistent between server restarts.
Attribute | Required? | Default | Description |
createScript | N | -- | If you do not create this and want the system to do so, then specify the script here that contains all of the tables. If you do not specify it, the system will use whatever the current release version of this script is automatically (which is included in the OA4MP distro.) This must be the full path on your system. |
storeType | Y | memory | This is required and is what tells OA4MP to use Derby in memory store mode. If it is missing, the assumption is that it is a standard database. |
<derby storeType="memory"> <!-- all the stores --> </derby>
<derby storeType="memory" database="oa4mp" createScript="/opt/oa4mp/etc/oa4mp-derby.sql" schema="oauth2"> <!-- all the stores --> </derby>
In this case, a database named oa4mp is created from a custom script. The schema is specified (which is used in the script.
Generally the schema, tablename and such use the default. Any option prefixed with a * in the table will have its default used. Note that there may be many stores for a configuration if each of them, e.g. requires different connection information.
Attribute | Required? | Default | Description |
username | Y | N/A | The name of the user to use |
password | Y | N/A | The password for the user |
bootPassword | Y | N/A | The password to unlock the database. |
driver | N | current | The JDBC driver |
database | Y | N/A | The path to the database. |
schema | N | The schema for the database | |
parameters | N | (none) | An optional extra set of parameters to pass to the JDBC driver. This is of the form key0=value0&key1=value1&key2=value2... Note that each key/value pair is separated with an ampersand. Note that OA4MP does all connections using UTF8 so that parameter is always added. |
The content of the store is specified in one of the content tags.
If you are installing Derby, you need to get the tools from their website (unless you have some form of package manager) and install that. There are install instructions for settig up your system.
This comment section tells how to set up an Apache Derby database to work with OA4MP.
Create the directory to where you want derby to create the database. This directory should be empty, since Derby will create everything on your behalf -- and might refuse to do anything if the directory has content. Make the following substitutions below:
Attribute | Description |
DB_NAME | the entire path to this database |
DB_PASSWORD | password to the database |
USER_NAME | name of the user (created below) |
USER_PASSWORD | password for user |
SCHEMA | schema for the database |
If you want your database to live in
/opt/oauth2/var/derby/oa4mp
you would create
/opt/oauth2/var/derby
with nothing in it and the DB_NAME is then
/opt/oauth2/var/derby/oa4mp
I.e., the last directory in this path is what Derby creates.
In Derby, the database lives in a directory. This means that unless certain precautions are taken, it is completely insecure. The setup below mitigates this.
Install derby, probably with a package manager like synaptic or yum.
Start derby with
ij
Then issue the following commands. This sets up the database and will create the user above (Note that the user name and password are set as Java properties, so do substitute). When he datqbase is shut down, these values are stored for subsequent usage and you then put them in the JDBC connection string. Even though the user does not exist yet, you must connect with the user name so that they are the owner of the database.
connect 'jdbc:derby:DB_NAME;create=true;dataEncryption=true;bootPassword=DB_PASSWORD;user=USER_NAME'; call syscs_util.syscs_set_database_property('derby.connection.requireAuthentication', 'true'); call syscs_util.syscs_set_database_property('derby.authentication.provider', 'BUILTIN'); call syscs_util.syscs_set_database_property('derby.user.USER_NAME', 'USER_PASSWORD'); call syscs_util.syscs_set_database_property('derby.database.propertiesOnly', 'true'); call syscs_util.syscs_set_database_property('derby.database.sqlAuthorization', 'true');
If you want be sure it works, create the schema as follows:
create schema oauth2; show schemas;
And a bunch of schemas will be displayed, including oauth2. This means everything worked. You don't need to issue the create schema command below.
At this point, exit Derby normally. Initial setup is done. You must connect again as the user that runs this because creating the tables below will automatically assign the current user as the table owner, so no other permissions (which can get complicated) are needed.
exit;
Now connect to it with the following from the command line after restarting ij:
connect 'jdbc:derby:DB_NAME;user=USER_NAME;password=USER_PASSWORD;bootPassword=DB_PASSWORD';
and either paste in the rest of this file OR just run the whole thing from inside ij
run '/full/path/to/oa4mp-derby.qdl';
At this point, your database is ready for use.
Let us say that you set up your Derby database with the following information
Attribute | Description |
DB_NAME | /opt/oa2/var/storage/my_db |
DB_PASSWORD | mairzy_doats |
USER_NAME | oa4mp |
USER_PASSWORD | dozey_doats |
SCHEMA | oauth2 |
Then the configuration of the derby element for all stores would be
<derby username="oa4mp" password="dozey_doats" bootPassword="mairzy_doats" database="opt/oa2/var/storage/my_db" schema="oauth2"> <transactions/> <clients/> <clientApprovals/> <permissions/> <adminClients/> <txStore/> <voStore/> </derby>