Configure JDBCRealm with Transact
To configure users with a database using JDBCRealm:
- In the server.xml file, comment out MemoryRealm for the context path /dcma.
-
Add a JDBCRealm for the type of authentication.
- Using Windows authentication
-
<Realm className=”org.apache.catalina.realm.JDBCRealm” driverName=”net.sourceforge.jtds.jdbc.Driver” connectionURL=”jdbc:jtds:sqlserver://localhost:1433;databaseName=<<database_name>>;sendStringParametersAsUnicode=true;prepareSQL=3;domain=<<domain_name>>” connectionName=”” connectionPassword=”” userTable=”<<table name where users exist>>” userNameCol=”<<column name having users>>” userCredCol=”<<column name having password>>” userRoleTable=”<<table name having roles>>” roleNameCol=”<<column name having roles>>” />
- Using basic authentication
-
<Realm className=”org.apache.catalina.realm.JDBCRealm” driverName=”net.sourceforge.jtds.jdbc.Driver” connectionURL=”jdbc:jtds:sqlserver://localhost:1433;databaseName=Test;sendStringParametersAsUnicode=true;prepareSQL=3″ connectionName=”<<username>>” connectionPassword=”<<password>>” userTable=”<<table name where users exist>>” userNameCol=”<<column name having users>>” userCredCol=”<<column name having password>>” userRoleTable=”<<table name having roles>>” roleNameCol=”<<column name having roles>>” />
-
Create the tables in the database using the following DDL script:
create table users ( user_name varchar(15) not null primary key, user_pass varchar(15) not null ); create table roles ( role_name varchar(15) not null primary key ); create table user_roles ( user_name varchar(15) not null, role_name varchar(15) not null, primary key( user_name, role_name ) );
This script does the following:
-
Creates three tables: users, roles, and user_roles.
-
Adds user_name and user_pass columns to the users table.
-
Adds user_name and role_name columns to the user_roles table.
-
-
Restart the server.
The database authenticates the rest service user.