Making stable in-memory and in-file database with HSQL
parent
061c0f0814
commit
e305d3b16b
|
@ -15,6 +15,7 @@
|
|||
******************************************************************************/
|
||||
package org.mitre.swd.web;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -68,7 +69,7 @@ public class SimpleWebDiscoveryEndpoint {
|
|||
}
|
||||
|
||||
@RequestMapping("/.well-known/openid-configuration")
|
||||
public ModelAndView providerConfiguration(ModelAndView modelAndView) {
|
||||
public ModelAndView providerConfiguration(ModelAndView modelAndView, Principal p) {
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE access_token (
|
||||
CREATE TABLE IF NOT EXISTS access_token (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
token_value VARCHAR(4096),
|
||||
expiration TIMESTAMP,
|
||||
|
@ -9,7 +9,7 @@ CREATE TABLE access_token (
|
|||
id_token_string VARCHAR(4096)
|
||||
);
|
||||
|
||||
CREATE TABLE address (
|
||||
CREATE TABLE IF NOT EXISTS address (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
formatted VARCHAR(256),
|
||||
street_address VARCHAR(256),
|
||||
|
@ -19,7 +19,7 @@ CREATE TABLE address (
|
|||
country VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE approved_site (
|
||||
CREATE TABLE IF NOT EXISTS approved_site (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
user_id VARCHAR(4096),
|
||||
client_id VARCHAR(4096),
|
||||
|
@ -29,39 +29,39 @@ CREATE TABLE approved_site (
|
|||
whitelisted_site_id VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE approved_site_scope (
|
||||
CREATE TABLE IF NOT EXISTS approved_site_scope (
|
||||
owner_id BIGINT,
|
||||
scope VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE authentication_holder (
|
||||
CREATE TABLE IF NOT EXISTS authentication_holder (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
owner_id BIGINT,
|
||||
authentication LONGVARBINARY
|
||||
);
|
||||
|
||||
CREATE TABLE authority (
|
||||
CREATE TABLE IF NOT EXISTS authority (
|
||||
owner_id BIGINT,
|
||||
authority LONGVARBINARY
|
||||
);
|
||||
|
||||
CREATE TABLE authorization_code (
|
||||
CREATE TABLE IF NOT EXISTS authorization_code (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
code VARCHAR(256),
|
||||
authorization_request_holder LONGVARBINARY
|
||||
);
|
||||
|
||||
CREATE TABLE authorized_grant_type (
|
||||
CREATE TABLE IF NOT EXISTS authorized_grant_type (
|
||||
owner_id BIGINT,
|
||||
authorized_grant_type VARCHAR(2000)
|
||||
);
|
||||
|
||||
CREATE TABLE blacklisted_site (
|
||||
CREATE TABLE IF NOT EXISTS blacklisted_site (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
uri VARCHAR(2048)
|
||||
);
|
||||
|
||||
CREATE TABLE client_details (
|
||||
CREATE TABLE IF NOT EXISTS client_details (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
client_description VARCHAR(256),
|
||||
allow_refresh TINYINT,
|
||||
|
@ -105,31 +105,31 @@ CREATE TABLE client_details (
|
|||
default_acr VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE contact (
|
||||
CREATE TABLE IF NOT EXISTS contact (
|
||||
owner_id BIGINT,
|
||||
contact VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE event (
|
||||
CREATE TABLE IF NOT EXISTS event (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
type INT,
|
||||
timestamp DATE
|
||||
);
|
||||
|
||||
CREATE TABLE idtoken (
|
||||
CREATE TABLE IF NOT EXISTS idtoken (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE idtokenclaims (
|
||||
CREATE TABLE IF NOT EXISTS idtokenclaims (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE redirect_uri (
|
||||
CREATE TABLE IF NOT EXISTS redirect_uri (
|
||||
owner_id BIGINT,
|
||||
redirect_uri VARCHAR(2048)
|
||||
);
|
||||
|
||||
CREATE TABLE refresh_token (
|
||||
CREATE TABLE IF NOT EXISTS refresh_token (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
token_value VARCHAR(4096),
|
||||
expiration TIMESTAMP,
|
||||
|
@ -137,22 +137,22 @@ CREATE TABLE refresh_token (
|
|||
client_id VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE resource_id (
|
||||
CREATE TABLE IF NOT EXISTS resource_id (
|
||||
owner_id VARCHAR(256),
|
||||
resource_id VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE client_scope (
|
||||
CREATE TABLE IF NOT EXISTS client_scope (
|
||||
owner_id VARCHAR(4096),
|
||||
scope VARCHAR(2048)
|
||||
);
|
||||
|
||||
CREATE TABLE token_scope (
|
||||
CREATE TABLE IF NOT EXISTS token_scope (
|
||||
owner_id VARCHAR(4096),
|
||||
scope VARCHAR(2048)
|
||||
);
|
||||
|
||||
CREATE TABLE user_info (
|
||||
CREATE TABLE IF NOT EXISTS user_info (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
user_id VARCHAR(256),
|
||||
preferred_username VARCHAR(256),
|
||||
|
@ -174,13 +174,13 @@ CREATE TABLE user_info (
|
|||
updated_time VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE whitelisted_site (
|
||||
CREATE TABLE IF NOT EXISTS whitelisted_site (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
|
||||
creator_user_id VARCHAR(256),
|
||||
client_id VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE TABLE whitelisted_site_scope (
|
||||
CREATE TABLE IF NOT EXISTS whitelisted_site_scope (
|
||||
owner_id BIGINT,
|
||||
scope VARCHAR(256)
|
||||
);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
create table users(
|
||||
create table IF NOT EXISTS users(
|
||||
username varchar_ignorecase(50) not null primary key,
|
||||
password varchar_ignorecase(50) not null,
|
||||
enabled boolean not null);
|
||||
|
||||
create table authorities (
|
||||
create table IF NOT EXISTS authorities (
|
||||
username varchar_ignorecase(50) not null,
|
||||
authority varchar_ignorecase(50) not null,
|
||||
constraint fk_authorities_users foreign key(username) references users(username));
|
||||
create unique index ix_auth_username on authorities (username,authority);
|
||||
constraint fk_authorities_users foreign key(username) references users(username),
|
||||
constraint ix_authority unique (username,authority));
|
|
@ -1,29 +1,30 @@
|
|||
INSERT INTO users(username, password, enabled) values ('jricher','password',true);
|
||||
INSERT INTO authorities(username,authority) values ('jricher','ROLE_USER');
|
||||
INSERT INTO authorities(username,authority) values ('jricher','ROLE_ADMIN');
|
||||
INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('jricher','jricher','jricher', 'FALSE');
|
||||
MERGE INTO users
|
||||
USING (VALUES ('jricher','password',true)) AS vals(username, password, enabled)
|
||||
ON vals.username = users.username
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT (username, password, enabled) VALUES(vals.username, vals.password, vals.enabled);
|
||||
|
||||
MERGE INTO authorities
|
||||
USING (VALUES('jricher', 'ROLE_USER'), ('jricher', 'ROLE_ADMIN'), ('jricher', 'ROLE_AWESOME')) AS vals(username, authority)
|
||||
ON vals.username = authorities.username AND vals.authority = authorities.authority
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT (username,authority) values (vals.username, vals.authority);
|
||||
|
||||
MERGE INTO user_info
|
||||
USING (VALUES('user1-abc123', 'jricher', 'Justin Richer', false)) AS vals(user_id, preferred_username, name, email_verified)
|
||||
ON vals.preferred_username = user_info.preferred_username
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT (user_id, preferred_username, name, email_verified) VALUES (vals.user_id, vals.preferred_username, vals.name, vals.email_verified);
|
||||
|
||||
INSERT INTO users(username, password, enabled) values ('mfranklin','password',true);
|
||||
INSERT INTO authorities(username,authority) values ('mfranklin','ROLE_USER');
|
||||
INSERT INTO authorities(username,authority) values ('mfranklin','ROLE_ADMIN');
|
||||
INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('mfranklin','mfranklin','mfranklin', 'FALSE');
|
||||
|
||||
INSERT INTO users(username, password, enabled) values ('dcuomo','password',true);
|
||||
INSERT INTO authorities(username,authority) values ('dcuomo','ROLE_USER');
|
||||
INSERT INTO authorities(username,authority) values ('dcuomo','ROLE_ADMIN');
|
||||
INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('dcuomo','dcuomo','dcuomo', 'FALSE');
|
||||
|
||||
INSERT INTO users(username, password, enabled) values ('aanganes','password',true);
|
||||
INSERT INTO authorities(username,authority) values ('aanganes','ROLE_USER');
|
||||
INSERT INTO authorities(username,authority) values ('aanganes','ROLE_ADMIN');
|
||||
INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('aanganes','aanganes','aanganes', 'FALSE');
|
||||
|
||||
INSERT INTO users(username, password, enabled) values ('mjwalsh','password',true);
|
||||
INSERT INTO authorities(username,authority) values ('mjwalsh','ROLE_USER');
|
||||
INSERT INTO authorities(username,authority) values ('mjwalsh','ROLE_ADMIN');
|
||||
INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('mjwalsh','mjwalsh','mjwalsh', 'FALSE');
|
||||
|
||||
INSERT INTO users(username, password, enabled) values ('srmoore','password',true);
|
||||
INSERT INTO authorities(username,authority) values ('srmoore','ROLE_USER');
|
||||
INSERT INTO authorities(username,authority) values ('srmoore','ROLE_ADMIN');
|
||||
INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('srmoore','srmoore','srmoore', 'FALSE');
|
||||
--INSERT INTO users(username, password, enabled) values ('aanganes','password',true) where not exists (select * from user_info where username='aanganes');
|
||||
--INSERT INTO authorities(username,authority) values ('aanganes','ROLE_USER') where not exists (select * from user_info where username='aanganes');
|
||||
--INSERT INTO authorities(username,authority) values ('aanganes','ROLE_ADMIN') where not exists (select * from user_info where username='aanganes');
|
||||
--INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('aanganes','aanganes','aanganes', 'FALSE') where not exists (select * from user_info where username='aanganes');
|
||||
--
|
||||
--INSERT INTO users(username, password, enabled) values ('mfranklin','password',true) where not exists (select * from user_info where username='mfranklin');
|
||||
--INSERT INTO authorities(username,authority) values ('mfranklin','ROLE_USER') where not exists (select * from user_info where username='mfranklin');
|
||||
--INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('mfranklin','mfranklin','mfranklin', 'FALSE') where not exists (select * from user_info where username='mfranklin');
|
||||
--
|
||||
--INSERT INTO users(username, password, enabled) values ('srmoore','password',true) where not exists (select * from user_info where username='srmoore');
|
||||
--INSERT INTO authorities(username,authority) values ('srmoore','ROLE_USER') where not exists (select * from user_info where username='srmoore');
|
||||
--INSERT INTO user_info(user_id, preferred_username, name, email_verified) values ('srmoore','srmoore','srmoore', 'FALSE') where not exists (select * from user_info where username='srmoore');
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:oic;sql.syntax_mys=true" />
|
||||
<!-- <property name="url" value="jdbc:hsqldb:file:/opt/hsql/clipOIDC/oic;sql.syntax_mys=true" /> -->
|
||||
<!-- <property name="url" value="jdbc:hsqldb:mem:oic;sql.syntax_mys=true" /> -->
|
||||
<property name="url" value="jdbc:hsqldb:file:/tmp/oic;sql.syntax_mys=true" />
|
||||
<property name="username" value="oic" />
|
||||
<property name="password" value="oic" />
|
||||
</bean>
|
||||
|
|
Loading…
Reference in New Issue