Using Derby database for persistent OAuth service
Derby database can be used for persistent OAuth services. For convenience and reference purposes, this topic documents the steps you need to configure Derby database, either remote or local to the OAuth service, for OAuth persistent service.
Follow these steps:
- Create a database and tables.Edit and run the following SQL statement to create an OAuth database and table:
Run the createTables.sql file by starting ij with the following command:--- Change oauth2db to the name you want for the database --- Connect to Derby, choose one connection option by uncomment --- if connecting to Derby as network server --- CONNECT 'jdbc:derby://localhost:1527/oauth2db;create=true'; --- if connecting to embedded derby, you can change D:\oauth2db to location of database --- CONNECT 'jdbc:derby:D:\oauth2db;create=true'; --- if creating tables in existing Derby database, remove the create=true parameter. ----- CREATE TABLES ----- CREATE TABLE OAuthDBSchema.OAUTH20CACHE ( LOOKUPKEY VARCHAR(256) NOT NULL, UNIQUEID VARCHAR(128) NOT NULL, COMPONENTID VARCHAR(256) NOT NULL, TYPE VARCHAR(64) NOT NULL, SUBTYPE VARCHAR(64), CREATEDAT BIGINT, LIFETIME INT, EXPIRES BIGINT, TOKENSTRING VARCHAR(2048) NOT NULL, CLIENTID VARCHAR(64) NOT NULL, USERNAME VARCHAR(64) NOT NULL, SCOPE VARCHAR(512) NOT NULL, REDIRECTURI VARCHAR(2048), STATEID VARCHAR(64) NOT NULL ); CREATE TABLE OAuthDBSchema.OAUTH20CLIENTCONFIG ( COMPONENTID VARCHAR(256) NOT NULL, CLIENTID VARCHAR(256) NOT NULL, CLIENTSECRET VARCHAR(256), DISPLAYNAME VARCHAR(256) NOT NULL, REDIRECTURI VARCHAR(2048), ENABLED INT ); ----- ADD CONSTRAINTS ----- ALTER TABLE OAuthDBSchema.OAUTH20CACHE ADD CONSTRAINT PK_LOOKUPKEY PRIMARY KEY (LOOKUPKEY); ALTER TABLE OAuthDBSchema.OAUTH20CLIENTCONFIG ADD CONSTRAINT PK_COMPIDCLIENTID PRIMARY KEY (COMPONENTID,CLIENTID); ----- CREATE INDEXES ----- CREATE INDEX OAUTH20CACHE_EXPIRES ON OAUTHDBSCHEMA.OAUTH20CACHE (EXPIRES ASC); DISCONNECT CURRENT;
ij createTables.sql
- Configure the WebSphere® Application
Server.
In the administrative console, go to
.- Pick a scope. This topic uses server.
- Click . A wizard starts.
- Select the following parameters:
- Database Type: Derby
- Provider Type: Derby JDBC Provider
- Implementation Type: Connection pool data source
- Click .
- Click .
- Save the configuration.
- Go to .
- Pick a scope. This topic uses server.
- Click . A wizard starts.
- Select the following parameters:
- Data source name: OAuth JDBC Service
- JNDI name: jdbc/oauthProvider
- Click .
- Select the Derby JDBC Provider that you created.
- Click .
- Select the following parameters:
- Database name: <the path to the Derby embedded database, for example, D:\oauth2db>
- Container Managed Persistence: Checked
- Click Setup security alias page. . Leave the settings unchanged in the
- Click .
- Click .
- Save the configuration.