Database Structure

The database structure is extremely simple, we provide an example in PostgreSQL to describe it.

Schema Overview

The following image captures the overview of the tables in the schema:

Mobile Utility Server DB Schema

Database Tables

mus_mobile_app Mobile Applications

Contains information related to various mobile apps.

CREATE TABLE mus_mobile_app (
    id INTEGER PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    display_name VARCHAR(255) NOT NULL,
    sign_private_key VARCHAR(255) NOT NULL,
    sign_public_key VARCHAR(255) NOT NULL
);
Column Type Description
id INTEGER Primary key for the table, automatically incremented value.
name VARCHAR(255) Name of the application, a machine readable value, such as wlt-demo-app.
display_name VARCHAR(255) Display name of the application, a human readable value, such as Wultra Demo App.
sign_private_key VARCHAR(255) Base64-encoded private key associated with the application. It is used for signing the data on the server side.
sign_public_key VARCHAR(255) Base64-encoded public key associated with the application. It is used by the client applications when verifying data signed on the server side.

mus_mobile_domain Mobile App Domains

Contains information related to pinned domains.

CREATE TABLE mus_mobile_domain (
    id INTEGER PRIMARY KEY,
    app_id INTEGER NOT NULL,
    domain VARCHAR(255) NOT NULL
);
Column Type Description
id INTEGER Primary key for the table, automatically incremented value.
app_id INTEGER Reference to related mobile app entity.
domain VARCHAR(255) Host name of the domain, such as mobile.wultra.com.

mus_certificate SSL Certificate

Table with TLS/SSL certificate and fingerprints that should be pinned in the mobile app.

CREATE TABLE mus_certificate (
    id INTEGER PRIMARY KEY,
    pem TEXT NOT NULL,
    fingerprint VARCHAR(255) NOT NULL,
    expires INTEGER NOT NULL,
    mobile_domain_id INTEGER NOT NULL
);
Column Type Description
id INTEGER Primary key for the table, automatically incremented value.
pem TEXT Original certificate value in PEM format.
fingerprint VARCHAR(255) Value of the certificate fingerprint.
expires INTEGER Unix timestamp (seconds since Jan 1, 1970) of the certificate expiration.
mobile_domain_id INTEGER Reference to related application domain in the mus_mobile_domain table.

mus_user Administrative User

Table with users for basic HTTP authentication.

CREATE TABLE mus_user (
    id INTEGER PRIMARY KEY,
    username VARCHAR(255) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    enabled BOOLEAN NOT NULL
);
Column Type Description
id INTEGER Primary key for the table, automatically incremented value.
username VARCHAR(255) Username of the user.
password VARCHAR(255) Password of the user (bcrypt by default, or {SHA-256} prefix for SHA-256).
enabled BOOLEAN Indication if the user is enabled or not.

mus_user_authority Administrative User Authorities

Table with users authorities.

CREATE TABLE mus_user_authority (
    id INTEGER PRIMARY KEY,
    user_id INTEGER NOT NULL UNIQUE,
    authority VARCHAR(255) NOT NULL
);
Column Type Description
id INTEGER Primary key for the table, automatically incremented value.
user_id INTEGER Foreign key column referencing users in mus_user table.
authority VARCHAR(255) Name of authority for the user prefixed with ROLE_ (ROLE_ADMIN).

mus_mobile_app_version Mobile Application Version

Table to force or suggest update of mobile application version.

create table mus_mobile_app_version
(
    id                integer      not null primary key,
    app_id            integer      not null,
    platform          varchar(10)  not null,
    major_os_version  integer,
    suggested_version varchar(24),
    required_version  varchar(24),
    message_key       varchar(255)
);
Column Type Description
id INTEGER Primary key for the table, automatically incremented value.
app_id INTEGER Reference to related mobile app entity.
platform VARCHAR(10) ANDROID, IOS
major_os_version INTEGER For iOS e.g. 12.4.2 it is 12. For Android, it is API level e.g. 29. When null, the rule is applied for all versions.
suggested_version VARCHAR(24) If the application version is lower, update is suggested.
required_version VARCHAR(24) If the application version is lower, update is required.
message_key VARCHAR(255) Together with language identifies row in mus_localized_text

mus_localized_text Localized Text

Table with localized texts.

create table mus_localized_text
(
    message_key varchar(255) not null,
    language    varchar(2)   not null,
    text        text         not null,
    primary key (message_key, language)
);
Column Type Description
message_key VARCHAR(255) Primary composite key for the table.
language VARCHAR(2) Primary composite key for the table. ISO 639-1 two-letter language code.
text TEXT Localized text.

Sequences

mus_mobile_app_seq Mobile App Sequence

Sequence responsible for mobile app autoincrements.

CREATE SEQUENCE IF NOT EXISTS mus_mobile_app_seq INCREMENT BY 1 START WITH 1 CACHE 20;

mus_mobile_domain_seq Mobile App Domain Sequence

Sequence responsible for mobile domain autoincrements.

CREATE SEQUENCE IF NOT EXISTS mus_mobile_domain_seq INCREMENT BY 1 START WITH 1 CACHE 20;

mus_certificate_seq SSL Certificate Sequence

Sequence responsible for SSL certificates and fingerprints autoincrements.

CREATE SEQUENCE IF NOT EXISTS mus_certificates_seq INCREMENT BY 1 START WITH 1 CACHE 20;

mus_mobile_app_version_seq Mobile Application Version Sequence

Sequence responsible for mobile application version autoincrements.

CREATE SEQUENCE IF NOT EXISTS mus_mobile_app_version_seq INCREMENT BY 1 START WITH 1 CACHE 20;

Foreign Indexes

The tables are relatively small and as a result, do not require indexes. To marginally improve the lookup performance, you can create the following foreign indexes.

mus_mobile_fingerprint Foreign Index for SSL Fingerprint Lookup

Foreign index for mapping the fingerprint to domain.

ALTER TABLE mus_mobile_fingerprint
    ADD CONSTRAINT mobile_ssl_pinning_app_fk FOREIGN KEY (mobile_domain_id)
        REFERENCES mus_mobile_domain ON UPDATE CASCADE ON DELETE CASCADE;

mus_mobile_domain Foreign Index for Domain Lookup

Foreign index to map the domain to mobile app.

ALTER TABLE mus_mobile_domain
    ADD CONSTRAINT mus_mobile_domain_fk FOREIGN KEY (app_id)
        REFERENCES mus_mobile_app ON UPDATE CASCADE ON DELETE CASCADE;

mus_user_authority Foreign Index for User Authority Lookup

Foreign index to map the user authority to the user.

ALTER TABLE mus_user_authority
    ADD CONSTRAINT mus_user_fk FOREIGN KEY (app_id)
        REFERENCES mus_user ON UPDATE CASCADE ON DELETE CASCADE;
Last updated on Oct 02, 2023 (11:47) Edit on Github Send Feedback
Search

1.6.x

Mobile Utility Server