Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d567caa61c | ||
|
41561a3a8a | ||
|
70fba42683 | ||
|
644b7078d7 |
35
.github/workflows/maven.yml
vendored
35
.github/workflows/maven.yml
vendored
@@ -1,35 +0,0 @@
|
||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
name: WiseMapping API
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "develop" ]
|
||||
pull_request:
|
||||
branches: [ "develop" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'zulu'
|
||||
cache: maven
|
||||
- name: Build with Maven
|
||||
run: mvn -B clean package --file wise-api/pom.xml
|
||||
- name: Build the Docker image
|
||||
run: docker build -t wisemapping/wisemapping-api:latest wise-api
|
||||
|
||||
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
|
||||
#- name: Update dependency graph
|
||||
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
|
15
LICENSE.md
15
LICENSE.md
@@ -1,15 +0,0 @@
|
||||
# WiseMapping Public License Version 1.0 (WPL)
|
||||
|
||||
WiseMapping open source edition is licensed under the WiseMapping Public License Version 1.0. It is basically Apache License Version 2.0 plus the "powered by wisemapping" text requirement on every single page (the "License") unless we authorize you to remove it.
|
||||
The WiseMapping Public License Version 1.0 ("WPL") consists of the [APACHE LICENSE, VERSION 2.0](http://www.apache.org/licenses/LICENSE-2.0), modified to be specific to WiseMapping, with the Additional Terms in Exhibit B.
|
||||
|
||||
Unless Required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
## EXHIBIT B - WiseMapping Public License.
|
||||
Additional Terms applicable to the WiseMapping Public License.
|
||||
I. Effect.
|
||||
These additional terms described in this wiseMapping Public License - Additional Terms shall apply to the Covered Code under this License.
|
||||
II. WiseMapping and "powered by WiseMapping" text.
|
||||
This License does not grant any rights to use the trademarks "WiseMapping" even if such marks are included in the Original Code or Modifications.
|
||||
However, in addition to the other notice obligations, unless wisemapping founders authorize you by email not to do it, (1) all copies of the Original Code in Executable and Source Code form must, as a form of attribution of the original author, include on each user interface screen (i) the "powered by WiseMapping" text; and (2) all derivative works and copies of derivative works of the Covered Code in Executable and Source Code form must include on each user interface screen (i) the "powered by WiseMapping" text. In addition, the "powered by WiseMapping" text, as appropriate, must be visible to all users, must appear in each user interface screen, and must be in the same position. When users click on the "powered by WiseMapping" text it must direct them to http://www.wisemapping.com. This obligation shall also apply to any copies or derivative works which are distributed under the alternative terms of Section 3.6 and this obligation must be included in any such license
|
91
README.md
91
README.md
@@ -1,89 +1,74 @@
|
||||
# WiseMapping Open Source
|
||||
# Overview
|
||||
|
||||
WiseMapping is an open-source web-based mind mapping tool that harnesses the potential of Mind Maps by blending together open standards technologies like SVG and React. It is built upon the foundation of the code supporting http://www.wisemapping.com, ensuring reliability and continuity in its development.
|
||||
Wise Mapping is the web mind mapping open source tool that leverages the power of Mind Maps mixing open standards technologies such as SVG and React.
|
||||
WiseMapping is based on the same code product supporting [http://www.wisemapping.com].
|
||||
|
||||
# Build and Start Application
|
||||
## Compiling and Running
|
||||
|
||||
The following section describes the steps to check out, compile, and start WiseMapping locally. If you are interested in deploying it, I recommend using the already published images https://hub.docker.com/r/wisemapping/wisemapping.
|
||||
### Prerequisites
|
||||
|
||||
## Prerequisites
|
||||
The following products must be installed:
|
||||
|
||||
* JDK 21 or higher
|
||||
* Maven v3.x or higher ([http://maven.apache.org/])
|
||||
* Yarn v1 or higher
|
||||
* Node v18 or higher
|
||||
* OpenJDK 11 or higher
|
||||
* Maven 3.x or higher ([http://maven.apache.org/])
|
||||
|
||||
## Option 1: Quick Start with Docker Compose
|
||||
### Compiling
|
||||
|
||||
The following command line will start WiseMapping locally using HSQLDB in memory for development purposes:
|
||||
WiseMapping uses Maven as packaging and project management. It's composed of 5 maven sub-modules:
|
||||
|
||||
```
|
||||
$ mvn -f wise-api/pom.xml package
|
||||
$ docker compose up --build
|
||||
```
|
||||
* wise-ui: React font-end fetcher
|
||||
* wise-webapp: J2EE web application
|
||||
|
||||
Application will start at http://localhost/c/login. You can login using *test@wisemapping.org* and password *test*
|
||||
The full compilation of the project can be performed executing within <project-dir>:
|
||||
|
||||
## Option 2: Start Frontend and Backend API
|
||||
`mvn clean install`
|
||||
|
||||
### Compile and Start API
|
||||
Once this command is executed, the file <project-dir>/wise-webapp/target/wisemapping*.war will be generated.
|
||||
|
||||
```
|
||||
$ mvn -f wise-api/pom.xml package
|
||||
$ cd wise-api
|
||||
$ mvn spring-boot:run
|
||||
```
|
||||
### Local Development
|
||||
The previously generated war can be deployed locally executing within the directory <project-dir>/wise-webapp the following command:
|
||||
|
||||
### Compile and Start Frontend
|
||||
`cd wise-webapp;mvn jetty:run-war`
|
||||
|
||||
You need to checkout https://github.com/wisemapping/wisemapping-frontend first. Then, follow the next steps:
|
||||
This will start the application on the URL: [http://localhost:8080/] using file based database.
|
||||
|
||||
```
|
||||
$ export NODE_OPTIONS=--openssl-legacy-provider
|
||||
$ export APP_CONFIG_TYPE="file:dev"
|
||||
User: test@wisemapping.org
|
||||
Password: test
|
||||
|
||||
$ cd wisemapping-frontend
|
||||
$ yarn install
|
||||
$ yarn build
|
||||
### Local Development + UI Integration
|
||||
|
||||
$ cd packages/webapp; yarn start
|
||||
```
|
||||
Application will start at http://localhost:3000/c/login. You can login using *test@wisemapping.org* and password *test*
|
||||
In order to reduce the life-cycle to develop UI backend testing, you can do the following hack:
|
||||
|
||||
# Supportability Matrix
|
||||
* Clone [wisemapping-open-source](https://bitbucket.org/wisemapping/wisemapping-open-source/) and [wisemapping-frontend](https://bitbucket.org/wisemapping/wisemapping-frontend/) at the same top level directory
|
||||
* Compile `wisemapping-frontend`. Details for compilation can be found in the `wisemapping-frontend` readme.
|
||||
* Compile `wisemapping-open-source`
|
||||
|
||||
## Databases
|
||||
A quick and dirty solution to share changes in the UI is to manually compile the dist. This will make the loader file available without the need to publish:
|
||||
|
||||
* MySQL v8 or higher
|
||||
* PostgreSQL v15 or higher
|
||||
* Hsqldb v2.7 or higher
|
||||
`cp -r wisemapping-frontend/packages/mindplot/dist/* wisemapping-open-source/wise-ui/target/wisemapping-mindplot/package/dist`
|
||||
|
||||
# Configuration
|
||||
|
||||
WiseMapping backend is based on SpringBoot v3 and it's highly customizable. Additional documentation can be found [here](https://docs.spring.io/spring-boot/3.3/reference/features/external-config.html)
|
||||
### Compiling and running with docker-compose
|
||||
|
||||
The perfered option is to extended by overwriting [application.yaml](https://github.com/wisemapping/wisemapping-open-source/blob/develop/wise-api/src/main/resources/application.yml)
|
||||
Check out the [docker section](./docker/README.
|
||||
|
||||
```
|
||||
$ java -jar target/wisemapping-api.jar --spring.config.additional-location=../../wise-conf/app.yml
|
||||
```
|
||||
## Members
|
||||
|
||||
For example, this [example](https://github.com/wisemapping/wisemapping-open-source/blob/develop/config/database/postgresql/app-postgresql.yaml) configure PostgreSQL as database.
|
||||
|
||||
# Members
|
||||
|
||||
## Founders
|
||||
### Founders
|
||||
|
||||
* Paulo Veiga <pveiga@wisemapping.com>
|
||||
* Pablo Luna <pablo@wisemapping.com>
|
||||
|
||||
## Past Individual Contributors
|
||||
### Individual Contributors
|
||||
|
||||
* Ignacio Manzano
|
||||
* Ezequiel Bergamaschi <ezequielbergamaschi@gmail.com>
|
||||
|
||||
### Past Individual Contributors
|
||||
|
||||
* Ignacio Manzano
|
||||
|
||||
## License
|
||||
|
||||
The source code is Licensed under the WiseMapping Open License, Version 1.0 (the “License”);
|
||||
You may obtain a copy of the License at: [https://github.com/wisemapping/wisemapping-open-source/blob/develop/LICENSE.md](https://github.com/wisemapping/wisemapping-open-source/blob/develop/LICENSE.md)
|
||||
You may obtain a copy of the License at: [https://wisemapping.atlassian.net/wiki/display/WS/License]
|
||||
|
||||
|
39
bitbucket-pipelines.yml
Normal file
39
bitbucket-pipelines.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
# Template maven-build
|
||||
|
||||
# This template allows you to test and build your Java project with Maven.
|
||||
# The workflow allows running tests, code checkstyle and security scans on the default branch.
|
||||
|
||||
# Prerequisites: pom.xml and appropriate project structure should exist in the repository.
|
||||
|
||||
image: maven:3.6.3
|
||||
|
||||
pipelines:
|
||||
branches:
|
||||
'{master,develop}':
|
||||
- step:
|
||||
name: Build and Test
|
||||
caches:
|
||||
- node
|
||||
- maven
|
||||
- docker
|
||||
script:
|
||||
# Compile sources ...
|
||||
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
|
||||
- . $HOME/.nvm/nvm.sh && nvm install node
|
||||
- mvn -B verify --file pom.xml
|
||||
# Publish to docker repo ...
|
||||
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
|
||||
- docker build -t wisemapping/wisemapping:latest -f distribution/Dockerfile wise-webapp/target/
|
||||
- docker push wisemapping/wisemapping:latest
|
||||
after-script:
|
||||
# Collect checkstyle results, if any, and convert to Bitbucket Code Insights.
|
||||
- pipe: atlassian/checkstyle-report:0.3.0
|
||||
services:
|
||||
- docker
|
||||
- step:
|
||||
name: Security Scan
|
||||
script:
|
||||
# Run a security scan for sensitive data.
|
||||
# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
|
||||
- pipe: atlassian/git-secrets-scan:0.5.1
|
||||
|
@@ -1,45 +0,0 @@
|
||||
# Database Configuration
|
||||
|
||||
## Overview
|
||||
|
||||
WiseMapping supports a wide variety of databases. However, we run intensively tests over HSQL and MySQL database.
|
||||
|
||||
* HyperSQL: Automatically configured when you compile WiseMapping and It's used primarily for testing. Additionally, the binary distribution already has an instance configured to provide a single click installation.
|
||||
* MySQL: This version is the most tested database we support. MySQL is the database use in http://www.wisemapping.com and it's the suggested version for production environments.
|
||||
* PostgreSQL: Scripts are distributed for the creation and configuration of the it. You will find them within "config/postgres" directory in the binary distribution. Additionally, JDBC driver need to be added to the container.
|
||||
* Others: In spite of the fact that we don't provide yet initialization scripts for others databases, WiseMapping can be deployed in any relational database. Please, contact us if you have any particular question on this area.
|
||||
|
||||
* In the following section, you are going to find a detailed explanation how to configure you WiseMapping using MySQL 5.5.
|
||||
|
||||
## MySQL Installation
|
||||
### Prerequisites
|
||||
* Download and install MySQL. You can download it for free from: http://dev.mysql.com/downloads/
|
||||
Running SQL Scripts
|
||||
Inside the WiseMapping binary distribution, you will find a directory "config/mysql". It contains all the SQL script required to configure a new WiseMapping database instance.
|
||||
|
||||
You will find 4 scripts:
|
||||
* create-database.sql: Create all wisemapping database and wisemapping user.
|
||||
* create-schemas.sql: Create all database tables and index.
|
||||
* apopulate-schemas.sql: Creates a mind map example and an a test user "test@wisemapping.org" with password "test".
|
||||
* drop-schemas.sql: Drop all wisemapping tables in case you want to have a fresh installation.
|
||||
|
||||
There are a lot of good tools you can use to run this scripts (eg: MySQLWorkbench). However, the simples way is to use the command line tool that is distributed as part of the MySQL installation.
|
||||
If you are one brave hearts that is not afraid of the command line tools, open a terminar and execute the following lines:
|
||||
~~~~
|
||||
cd <WISEMAPPING-DIR>/config/database/mysql
|
||||
# Default MySQL installation creates a "root" user with empty password. You can connect to the database with this user if you are # logged in same machine where the database is installed and must be executed logged as "root"
|
||||
#
|
||||
# If you have changed the default database "root" password , you need to specify an additional -p parameter and provide the
|
||||
# new password.
|
||||
mysql -uroot < create-database.sql
|
||||
|
||||
# Create tables and default tests user
|
||||
mysql -uwisemapping -Dwisemapping -ppassword < create-schemas.sql
|
||||
mysql -uwisemapping -Dwisemapping -ppassword < apopulate-schemas.sql
|
||||
~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
Great, you have configured you database !. Let's configure WiseMapping now.
|
||||
|
10
config/database/hsql/apopulate-schemas.sql
Normal file
10
config/database/hsql/apopulate-schemas.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
|
||||
|
||||
COMMIT;
|
||||
SHUTDOWN;
|
96
config/database/hsql/create-schemas.sql
Normal file
96
config/database/hsql/create-schemas.sql
Normal file
@@ -0,0 +1,96 @@
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
creation_date DATE
|
||||
);
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL IDENTITY,
|
||||
authentication_type CHAR(1) NOT NULL,
|
||||
authenticator_uri VARCHAR(255) NULL,
|
||||
firstname VARCHAR(255) NOT NULL,
|
||||
lastname VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
activation_code BIGINT NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) NOT NULL,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
xml LONGVARBINARY NOT NULL,
|
||||
public BOOLEAN NOT NULL,
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014),
|
||||
last_editor_id INTEGER NOT NULL
|
||||
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
|
||||
title VARCHAR(30),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
iconName VARCHAR(50) NOT NULL
|
||||
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
xml LONGVARBINARY NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
starred BOOLEAN NOT NULL,
|
||||
mindmap_properties VARCHAR(512)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
--FOREIGN KEY(user_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
user_id INTEGER NOT NULL,
|
||||
login_date DATE,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
COMMIT;
|
11
config/database/hsql/drop-schemas.sql
Normal file
11
config/database/hsql/drop-schemas.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
@@ -1,10 +0,0 @@
|
||||
RENAME TABLE USER TO ACCOUNT;
|
||||
RENAME TABLE LABEL TO MINDMAP_LABEL;
|
||||
|
||||
ALTER TABLE COLLABORATION
|
||||
RENAME COLUMN colaborator_id to collaborator_id;
|
||||
|
||||
ALTER TABLE ACCOUNT
|
||||
RENAME COLUMN colaborator_id to collaborator_id;
|
||||
|
||||
ALTER TABLE MINDMAP_LABEL DROP COLUMN iconName;
|
13
config/database/mysql/apopulate-schemas.sql
Normal file
13
config/database/mysql/apopulate-schemas.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Command: mysql -u root -p < apopulate_schemas.sql
|
||||
#
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
COMMIT;
|
@@ -1,14 +0,0 @@
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/wisemapping?useUnicode=yes&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
password: password
|
||||
username: wisemapping
|
||||
jpa:
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQLDialect
|
||||
sql:
|
||||
init:
|
||||
platform: mysql
|
@@ -1,12 +1,10 @@
|
||||
#
|
||||
# Command: mysql -u root -p < create-database.sql
|
||||
#
|
||||
DROP DATABASE IF EXISTS wisemapping;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS wisemapping
|
||||
CHARACTER SET = 'utf8'
|
||||
COLLATE = 'utf8_unicode_ci';
|
||||
|
||||
CREATE USER 'wisemapping'@'%' IDENTIFIED BY 'password';
|
||||
GRANT ALL PRIVILEGES ON wisemapping.* TO 'wisemapping'@'%' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;
|
||||
#
|
||||
# Command: mysql -u root -p < create_database.sql
|
||||
#
|
||||
DROP DATABASE IF EXISTS wisemapping;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS wisemapping
|
||||
CHARACTER SET = 'utf8'
|
||||
COLLATE = 'utf8_unicode_ci';
|
||||
GRANT ALL ON wisemapping.* TO 'wisemapping'@'localhost';
|
||||
SET PASSWORD FOR 'wisemapping'@'localhost' = PASSWORD('password');
|
@@ -1,117 +1,137 @@
|
||||
CREATE TABLE IF NOT EXISTS COLLABORATOR (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
email VARCHAR(255) CHARACTER SET UTF8MB4 NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ACCOUNT (
|
||||
collaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
authentication_type CHAR(1)
|
||||
CHARACTER SET UTF8MB4 NOT NULL,
|
||||
authenticator_uri VARCHAR(255)
|
||||
CHARACTER SET utf8,
|
||||
firstname VARCHAR(255) CHARACTER SET UTF8MB4 NOT NULL,
|
||||
lastname VARCHAR(255) CHARACTER SET UTF8MB4 NOT NULL,
|
||||
password VARCHAR(255) CHARACTER SET UTF8MB4 NOT NULL,
|
||||
activation_code BIGINT(20) NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) CHARACTER SET UTF8MB4 NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
google_sync BOOL,
|
||||
sync_code VARCHAR(255),
|
||||
google_token VARCHAR(255),
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
) CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS MINDMAP (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(255)
|
||||
CHARACTER SET UTF8MB4 NOT NULL,
|
||||
description VARCHAR(255)
|
||||
CHARACTER SET utf8,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT 0,
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
last_editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES ACCOUNT (collaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS MINDMAP_LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET UTF8MB4 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES ACCOUNT (collaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES MINDMAP_LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES MINDMAP_LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS MINDMAP_HISTORY
|
||||
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
starred BOOL NOT NULL DEFAULT 0,
|
||||
mindmap_properties VARCHAR(512)
|
||||
CHARACTER SET utf8
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS COLLABORATION (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
collaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
UNIQUE KEY UC_ROLE (mindmap_id,collaborator_id),
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES ACCOUNT (collaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET UTF8MB4;
|
||||
#
|
||||
# Command: mysql -u root -p < create_schemas.sql
|
||||
#
|
||||
|
||||
USE wisemapping;
|
||||
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
email VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
authentication_type CHAR(1)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
authenticator_uri VARCHAR(255)
|
||||
CHARACTER SET utf8,
|
||||
firstname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
lastname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
password VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
activation_code BIGINT(20) NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
description VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT 0,
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014)
|
||||
CHARACTER SET utf8,
|
||||
last_editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
iconName VARCHAR(50) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
starred BOOL NOT NULL DEFAULT 0,
|
||||
mindmap_properties VARCHAR(512)
|
||||
CHARACTER SET utf8
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
COMMIT;
|
11
config/database/mysql/drop-schemas.sql
Normal file
11
config/database/mysql/drop-schemas.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
57
config/database/mysql/v2.0-to-v3.0.sql
Normal file
57
config/database/mysql/v2.0-to-v3.0.sql
Normal file
@@ -0,0 +1,57 @@
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
starred BOOL NOT NULL DEFAULT 0,
|
||||
mindmap_properties VARCHAR(512)
|
||||
CHARACTER SET utf8
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
DROP TABLE `MINDMAP_NATIVE`;
|
||||
ALTER TABLE `MINDMAP_COLABORATOR` RENAME TO `COLLABORATION`;
|
||||
ALTER TABLE `COLABORATOR` RENAME TO `COLLABORATOR`;
|
||||
|
||||
ALTER TABLE `MINDMAP` DROP COLUMN `editor_properties`, DROP COLUMN `mindMapNative_id`;
|
||||
|
||||
ALTER TABLE `MINDMAP` CHANGE COLUMN `owner_id` `creator_id` INT(11) NOT NULL
|
||||
, DROP INDEX `owner_id`
|
||||
, ADD INDEX `owner_id` (`creator_id` ASC);
|
||||
|
||||
ALTER TABLE `COLLABORATION` ADD COLUMN `properties_id` INT(11) NULL DEFAULT NULL
|
||||
AFTER `role_id`;
|
||||
DROP TABLE USER_LOGIN;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
login_date DATE
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
#ALTER TABLE ACCESS_AUDITORY
|
||||
# ADD CONSTRAINT `user_id`
|
||||
# FOREIGN KEY ()
|
||||
# REFERENCES `USER` ()
|
||||
# ON DELETE CASCADE
|
||||
# ON UPDATE NO ACTION
|
||||
#, ADD INDEX `user_id` () ;
|
||||
|
||||
ALTER TABLE `MINDMAP_HISTORY` DROP COLUMN `creator_user`, ADD COLUMN `editor_id` INT(11) NULL DEFAULT NULL AFTER `creation_date`;
|
||||
|
||||
ALTER TABLE `USER` ADD COLUMN `locale` VARCHAR(5) NULL
|
||||
AFTER `allowSendEmail`;
|
||||
|
||||
ALTER TABLE `MINDMAP` DROP COLUMN `last_editor`, ADD COLUMN `last_editor_id` INT(11) NULL DEFAULT 2
|
||||
AFTER `tags`;
|
||||
|
||||
ALTER TABLE `USER` DROP COLUMN `username`, CHANGE COLUMN `activationCode` `activation_code` BIGINT(20) NOT NULL, CHANGE COLUMN `allowSendEmail` `allow_send_email` CHAR(1) NOT NULL DEFAULT '0';
|
||||
|
||||
INSERT INTO `MINDMAP` (`last_editor_id`) VALUES (1);
|
||||
|
||||
INSERT INTO `COLLABORATOR` (`id`, `email`, `creation_date`) VALUES (8081, 'migfake@wis.com', '2007-10-09');
|
||||
DELETE FROM `USER`
|
||||
WHERE activation_date IS null;
|
||||
DROP TABLE FEEDBACK;
|
||||
|
||||
|
||||
ALTER TABLE `MINDMAP` CHANGE COLUMN `XML` `XML` MEDIUMBLOB NULL DEFAULT NULL;
|
||||
ALTER TABLE `MINDMAP_HISTORY` CHANGE COLUMN `XML` `XML` MEDIUMBLOB NULL DEFAULT NULL;
|
5
config/database/mysql/v3.0-to-v3.0.1.sql
Normal file
5
config/database/mysql/v3.0-to-v3.0.1.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE `USER` ADD COLUMN `authentication_type` CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 'D'
|
||||
AFTER `colaborator_id`;
|
||||
|
||||
ALTER TABLE `USER` ADD COLUMN `authenticator_uri` VARCHAR(255) CHARACTER SET utf8
|
||||
AFTER `authentication_type`;
|
37
config/database/mysql/v3.0.2-to-v3.0.3.sql
Normal file
37
config/database/mysql/v3.0.2-to-v3.0.3.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
ALTER TABLE `USER` DROP COLUMN `id`;
|
||||
|
||||
ALTER TABLE `ACCESS_AUDITORY`
|
||||
ADD CONSTRAINT
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
ALTER TABLE `LABEL`
|
||||
ADD COLUMN iconName VARCHAR(50) NOT NULL;
|
||||
|
||||
UPDATE LABEL SET iconName = 'glyphicon glyphicon-tag';
|
3
config/database/postgres/create-database.sql
Normal file
3
config/database/postgres/create-database.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
CREATE DATABASE wisemapping;
|
||||
CREATE USER wisemapping WITH PASSWORD 'password';
|
||||
GRANT ALL PRIVILEGES ON DATABASE wisemapping TO wisemapping;
|
@@ -1,13 +1,13 @@
|
||||
create TABLE IF NOT EXISTS COLLABORATOR (
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS ACCOUNT (
|
||||
CREATE TABLE "user" (
|
||||
authentication_type TEXT NOT NULL,
|
||||
authenticator_uri VARCHAR(255),
|
||||
collaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
firstname VARCHAR(255) NOT NULL,
|
||||
lastname VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
@@ -15,71 +15,82 @@ create TABLE IF NOT EXISTS ACCOUNT (
|
||||
activation_date DATE,
|
||||
allow_send_email TEXT NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
google_sync BOOLEAN,
|
||||
sync_code VARCHAR(255),
|
||||
google_token VARCHAR(255),
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id) ON delete CASCADE ON update NO ACTION
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS MINDMAP_LABEL (
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES ACCOUNT (collaborator_id)
|
||||
color VARCHAR(7) NOT NULL
|
||||
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS MINDMAP (
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255),
|
||||
description VARCHAR(255) NOT NULL,
|
||||
xml BYTEA NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT FALSE,
|
||||
creation_date TIMESTAMP,
|
||||
edition_date TIMESTAMP,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014),
|
||||
last_editor_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(creator_id) REFERENCES "USER"(collaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
--FOREIGN KEY(creator_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES MINDMAP_LABEL (id) ON delete CASCADE ON update NO ACTION
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS MINDMAP_HISTORY
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id SERIAL NOT NULL PRIMARY KEY,
|
||||
xml BYTEA NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date TIMESTAMP,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON delete CASCADE ON update NO ACTION
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS COLLABORATION_PROPERTIES (
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
starred BOOL NOT NULL DEFAULT FALSE,
|
||||
mindmap_properties VARCHAR(512)
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS COLLABORATION (
|
||||
CREATE TABLE COLLABORATION (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
collaborator_id INTEGER NOT NULL,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (collaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON delete CASCADE ON update NO ACTION,
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id) ON delete CASCADE ON update NO ACTION
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
create TABLE IF NOT EXISTS ACCESS_AUDITORY (
|
||||
CREATE TABLE TAG (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(user_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES ACCOUNT (collaborator_id) ON delete CASCADE ON update NO ACTION
|
||||
);
|
||||
FOREIGN KEY (user_id) REFERENCES "user" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
COMMIT;
|
11
config/database/postgres/drop-schemas.sql
Normal file
11
config/database/postgres/drop-schemas.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
DROP TABLE TAG;
|
||||
DROP TABLE ACCESS_AUDITORY;
|
||||
DROP TABLE COLLABORATION;
|
||||
DROP TABLE COLLABORATION_PROPERTIES;
|
||||
DROP TABLE MINDMAP_HISTORY;
|
||||
DROP TABLE R_LABEL_MINDMAP;
|
||||
DROP TABLE LABEL;
|
||||
DROP TABLE MINDMAP;
|
||||
DROP TABLE "user";
|
||||
DROP TABLE COLLABORATOR;
|
||||
COMMIT;
|
@@ -1,14 +0,0 @@
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost/wisemapping
|
||||
driver-class-name: org.postgresql.Driver
|
||||
password: password
|
||||
username: wisemapping
|
||||
jpa:
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
sql:
|
||||
init:
|
||||
platform: postgresql
|
@@ -1,7 +0,0 @@
|
||||
|
||||
CREATE DATABASE wisemapping;
|
||||
CREATE USER wisemapping WITH PASSWORD 'password';
|
||||
GRANT ALL PRIVILEGES ON DATABASE wisemapping TO wisemapping;
|
||||
|
||||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO wisemapping;
|
||||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO wisemapping;
|
@@ -2,16 +2,15 @@
|
||||
# Based on ubuntu:latest, installs WiseMapping (http://ww.wisemapping.org)
|
||||
|
||||
# Based info setup ...
|
||||
#FROM --platform=$BUILDPLATFORM tomcat:9.0.71-jdk17
|
||||
FROM tomcat:10.1.11-jdk17
|
||||
FROM tomcat:9.0-jdk17-openjdk
|
||||
LABEL maintainer="Paulo Gustavo Veiga <pveiga@wisemapping.com>"
|
||||
|
||||
# Build variables ...
|
||||
ARG WEBAPP_TARGET_DIR="/usr/local/tomcat/webapps/ROOT"
|
||||
ARG DB_BASE_DIR="/var/lib/wisemapping"
|
||||
|
||||
# Default ENV configurations ...
|
||||
ENV JAVA_OPTS="-XX:+PrintFlagsFinal -XX:InitialRAMPercentage=30 -XX:MaxRAMPercentage=80 -Dfile.encoding=UTF-8"
|
||||
# Defautl ENV configurations ...
|
||||
ENV JAVA_OPTS="-XX:+PrintFlagsFinal -XX:InitialRAMPercentage=30 -XX:MaxRAMPercentage=80"
|
||||
ENV database.base.url=${DB_BASE_DIR}
|
||||
|
||||
# Copy wisemapping distribution ...
|
||||
@@ -21,16 +20,7 @@ RUN cd ${WEBAPP_TARGET_DIR} && jar -xvf /tmp/wisemapping.war
|
||||
RUN rm /tmp/wisemapping.war
|
||||
|
||||
# Change logger to
|
||||
RUN cp ${WEBAPP_TARGET_DIR}/WEB-INF/log4j2-stdout.xml ${WEBAPP_TARGET_DIR}/WEB-INF/classes/log4j2.xml
|
||||
|
||||
# Add support for proxy
|
||||
RUN sed -i 's|\
|
||||
</Host>|\
|
||||
<Valve className="org.apache.catalina.valves.RemoteIpValve" \
|
||||
remoteIpHeader="X-Forwarded-For" \
|
||||
protocolHeader="X-Forwarded-Proto"/>\
|
||||
</Host>|' \
|
||||
/usr/local/tomcat/conf/server.xml
|
||||
RUN cp ${WEBAPP_TARGET_DIR}/WEB-INF/classes/log4j-stdout.properties ${WEBAPP_TARGET_DIR}/WEB-INF/classes/log4j.properties
|
||||
|
||||
# Copy default HSQL DB for testing ...
|
||||
RUN mkdir -p ${DB_BASE_DIR}/db
|
||||
|
@@ -9,27 +9,15 @@ There are multiple ways to run WiseMapping depending on your database configurat
|
||||
|
||||
## Option 1: Running HSQL within the image storage
|
||||
|
||||
> $ docker run -it --rm -p 8080:8080 wisemapping/wisemapping:latest
|
||||
> $ docker run -it --rm -p 8080:8080 veigap/wisemapping:latest>
|
||||
|
||||
Then, open your browser at `http://localhost:8888`. A default user is available for testing `test@wisemapping.org` and password `test`.
|
||||
Then, open your browser at `http://localhost:8888`. A default user is available for testing `test@wisemapping.com` and password `test`.
|
||||
|
||||
***This option, all changes will be lost once the image is stopped. Use it for testing only***
|
||||
|
||||
## Option 2: Running HSQL with mounted directory
|
||||
|
||||
Only one time, copy the empty default out of the container:
|
||||
|
||||
> $ mkdir your- db-dir-store-path
|
||||
>
|
||||
> $ docker run --name wiseapp -d --mount type=bind,source=your-db-dir-store-path,target=/var/lib/wise-db wisemapping/wisemapping:latest
|
||||
>
|
||||
> $ docker cp wiseapp:/var/lib/wisemapping/db your-db-dir-store-path
|
||||
>
|
||||
> $ docker stop wiseapp;docker rm wiseapp
|
||||
|
||||
Then, execute the container mounting tbe directory:
|
||||
|
||||
> $ docker run --mount type=bind,source=your-db-dir-store-path/db,target=/var/lib/wisemapping/db -it --rm -p 8080:8080 wisemapping/wisemapping:latest
|
||||
> $ docker run -it --rm -p 8080:8080 veigap/wisemapping:latest
|
||||
|
||||
## Option 3: External MySQL/PostgreSQL
|
||||
|
||||
@@ -42,13 +30,13 @@ Depending on the database your want to configure, you can create initialization
|
||||
The next step is configure the WiseMapping for the database and credentials.
|
||||
Download `app.properties` configuration file and configure the required sections:
|
||||
|
||||
> $ curl https://bitbucket.org/wisemapping/wisemapping-open-source/src/master/wise-webapp/src/main/webapp/WEB-INF/app.properties
|
||||
> $ curl https://bitbucket.org/wisemapping/wisemapping-open-source/raw/644b7078d790220c7844b732a83d45495f11d64e/wise-webapp/src/main/webapp/WEB-INF/app.properties
|
||||
|
||||
### Starting the application
|
||||
|
||||
Run the application mounting your previously configured `app.properties`
|
||||
|
||||
> $ docker run --mount type=bind,source=your-file-path/app.properties,target=/usr/local/tomcat/webapps/ROOT/WEB-INF/app.properties -it --rm -p 8080:8080 wisemapping/wisemapping:latest
|
||||
> $ docker run --mount type=bind,source=your-file-path/app.properties,target=/usr/local/tomcat/webapps/ROOT/WEB-INF/app.properties -it --rm -p 8080:8080 veigap/wisemapping:latest
|
||||
|
||||
# Advanced configuration
|
||||
|
||||
|
@@ -4,7 +4,4 @@ set -o
|
||||
set -u
|
||||
|
||||
mvn -f ../pom.xml clean package
|
||||
docker build --platform linux/amd64 -t wisemapping/wisemapping:latest -f ./Dockerfile ../wise-webapp/target/
|
||||
#docker buildx create --use --platform=linux/arm64,linux/amd64 --name multi-platform-builder
|
||||
#docker buildx inspect --bootstrap
|
||||
#docker buildx build --platform=linux/amd64,linux/arm64 --push -t wisemapping/wisemapping:latest -f ./Dockerfile ../wise-webapp/target/
|
||||
docker build -t wisemapping/wisemapping:latest -f ./Dockerfile ../wise-webapp/target/
|
||||
|
10
distribution/mysql-init/0001create-database.sql
Normal file
10
distribution/mysql-init/0001create-database.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# Command: mysql -u root -p < create_database.sql
|
||||
#
|
||||
DROP DATABASE IF EXISTS wisemapping;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS wisemapping
|
||||
CHARACTER SET = 'utf8'
|
||||
COLLATE = 'utf8_unicode_ci';
|
||||
GRANT ALL ON wisemapping.* TO 'wisemapping'@'localhost';
|
||||
SET PASSWORD FOR 'wisemapping'@'localhost' = PASSWORD('password');
|
137
distribution/mysql-init/0002create-schemas.sql
Normal file
137
distribution/mysql-init/0002create-schemas.sql
Normal file
@@ -0,0 +1,137 @@
|
||||
#
|
||||
# Command: mysql -u root -p < create_schemas.sql
|
||||
#
|
||||
|
||||
USE wisemapping;
|
||||
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
email VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
authentication_type CHAR(1)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
authenticator_uri VARCHAR(255)
|
||||
CHARACTER SET utf8,
|
||||
firstname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
lastname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
password VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
activation_code BIGINT(20) NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
description VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT 0,
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014)
|
||||
CHARACTER SET utf8,
|
||||
last_editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
iconName VARCHAR(50) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
starred BOOL NOT NULL DEFAULT 0,
|
||||
mindmap_properties VARCHAR(512)
|
||||
CHARACTER SET utf8
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
COMMIT;
|
13
distribution/mysql-init/0003apopulate-schemas.sql
Normal file
13
distribution/mysql-init/0003apopulate-schemas.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Command: mysql -u root -p < apopulate_schemas.sql
|
||||
#
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
COMMIT;
|
@@ -1,4 +0,0 @@
|
||||
ALTER TABLE USER
|
||||
ADD COLUMN `google_sync` TINYINT(1) NULL,
|
||||
ADD COLUMN `sync_code` VARCHAR(255) NULL,
|
||||
ADD COLUMN `google_token` VARCHAR(255) NULL;
|
@@ -1,4 +0,0 @@
|
||||
ALTER TABLE "user"
|
||||
ADD COLUMN `google_sync` BOOLEAN NULL,
|
||||
ADD COLUMN `sync_code` VARCHAR(255) NULL,
|
||||
ADD COLUMN `google_token` VARCHAR(255) NULL;
|
@@ -1,22 +0,0 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
wise-api:
|
||||
container_name: wise-api
|
||||
hostname: wise-api
|
||||
image: wise-api:latest
|
||||
build:
|
||||
context: ./wise-api
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8080:8080"
|
||||
wise-ui:
|
||||
container_name: wise-ui
|
||||
image: wise-ui:latest
|
||||
build:
|
||||
context: ./wise-ui
|
||||
dockerfile: Dockerfile
|
||||
depends_on:
|
||||
- wise-api
|
||||
ports:
|
||||
- "80:80"
|
15
license.txt
Normal file
15
license.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
Copyright [2014] [wisemapping]
|
||||
|
||||
Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
"powered by wisemapping" text requirement on every single page;
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the license at
|
||||
|
||||
http://www.wisemapping.org/license
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
155
pom.xml
Normal file
155
pom.xml
Normal file
@@ -0,0 +1,155 @@
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<properties>
|
||||
<com.wisemapping.version>5.0.4</com.wisemapping.version>
|
||||
<superpom.dir>${project.basedir}/wise-webapps</superpom.dir>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@bitbucket.org:wisemapping/wisemapping-open-source.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<name>WiseMapping Project</name>
|
||||
<version>5.0.4</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>WiseMapping Public License Version 1.0</name>
|
||||
<url>http://www.wisemapping.org/wisemapping-public-license-version-1-0-wpl</url>
|
||||
<comments>A business-friendly OSS license</comments>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven2-repository.dev.java.net</id>
|
||||
<name>Java.net Maven 2 Repository</name>
|
||||
<url>http://download.java.net/maven/2/</url>
|
||||
<layout>default</layout>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<organization>
|
||||
<name>WiseMapping</name>
|
||||
<url>http://www.wisemapping.org/</url>
|
||||
</organization>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.12</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.16</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>native2ascii-maven-plugin</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.searls</groupId>
|
||||
<artifactId>jasmine-maven-plugin</artifactId>
|
||||
<version>1.3.1.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2.2</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>distribution/assembly/standalone-editor.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<site>
|
||||
<id>www.wisemapping.org</id>
|
||||
<url>scp://www.wisemapping.org/docs/project/</url>
|
||||
</site>
|
||||
</distributionManagement>
|
||||
|
||||
<!-- Module Dependencies -->
|
||||
<modules>
|
||||
<module>wise-ui</module>
|
||||
<module>wise-webapp</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
||||
|
@@ -1,7 +0,0 @@
|
||||
FROM amazoncorretto:21.0.2
|
||||
LABEL maintainer="Paulo Gustavo Veiga <pveiga@wisemapping.com>"
|
||||
|
||||
VOLUME /tmp
|
||||
COPY target/wisemapping-api.jar wisemapping-api.jar
|
||||
|
||||
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /wisemapping-api.jar ${0} ${@}"]
|
232
wise-api/pom.xml
232
wise-api/pom.xml
@@ -1,232 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wise-api</artifactId>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
|
||||
<name>WiseMapping API</name>
|
||||
<url>https://www.wisemapping.org</url>
|
||||
|
||||
<properties>
|
||||
<com.wisemapping.version>6.0.0-SNAPSHOT</com.wisemapping.version>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>6.1.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.9.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.9.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.intellij</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>12.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.7.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Hibernate Validator -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>8.0.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.mail</groupId>
|
||||
<artifactId>jakarta.mail-api</artifactId>
|
||||
<version>2.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.angus</groupId>
|
||||
<artifactId>jakarta.mail</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.20.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Connection Pool-->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>5.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Only for test purposes -->
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.15.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.transaction</groupId>
|
||||
<artifactId>jakarta.transaction-api</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.15.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>fluent-hc</artifactId>
|
||||
<version>4.5.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<version>6.2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JWT dependencies -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>0.11.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>0.11.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>0.11.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<finalName>wisemapping-api</finalName>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<!-- <configuration>-->
|
||||
<!-- <jvmArguments>-->
|
||||
<!-- -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005-->
|
||||
<!-- </jvmArguments>-->
|
||||
<!-- </configuration>-->
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
@@ -1,26 +0,0 @@
|
||||
package com.wisemapping;
|
||||
|
||||
import com.wisemapping.config.common.CommonConfig;
|
||||
import com.wisemapping.config.rest.RestAppConfig;
|
||||
import com.wisemapping.config.rest.WebConfig;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.web.firewall.StrictHttpFirewall;
|
||||
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder()
|
||||
.parent(CommonConfig.class).web(WebApplicationType.NONE)
|
||||
.child(RestAppConfig.class, WebConfig.class).web(WebApplicationType.SERVLET)
|
||||
.run(args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StrictHttpFirewall httpFirewall() {
|
||||
StrictHttpFirewall firewall = new StrictHttpFirewall();
|
||||
firewall.setAllowSemicolon(true);
|
||||
return firewall;
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package com.wisemapping.config.common;
|
||||
|
||||
import com.wisemapping.dao.LabelManagerImpl;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.security.AuthenticationProvider;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapServiceImpl;
|
||||
import com.wisemapping.util.VelocityEngineUtils;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ComponentScan(basePackageClasses = {AuthenticationProvider.class, MindmapServiceImpl.class, LabelManagerImpl.class, VelocityEngineUtils.class})
|
||||
@Import({JPAConfig.class, SecurityConfig.class})
|
||||
@EnableAutoConfiguration
|
||||
public class CommonConfig {
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
return new AcceptHeaderLocaleResolver() {
|
||||
@Override
|
||||
public Locale resolveLocale(@NotNull HttpServletRequest request) {
|
||||
final Account user = Utils.getUser();
|
||||
Locale result;
|
||||
if (user != null && user.getLocale() != null) {
|
||||
String locale = user.getLocale();
|
||||
final String locales[] = locale.split("_");
|
||||
|
||||
Locale.Builder builder = new Locale.Builder().setLanguage(locales[0]);
|
||||
if (locales.length > 1) {
|
||||
builder.setVariant(locales[1]);
|
||||
}
|
||||
result = builder.build();
|
||||
} else {
|
||||
result = super.resolveLocale(request);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +0,0 @@
|
||||
package com.wisemapping.config.common;
|
||||
|
||||
import com.wisemapping.dao.MindmapManagerImpl;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.MindmapServiceImpl;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(basePackageClasses={MindmapServiceImpl.class, MindmapManagerImpl.class})
|
||||
@EntityScan(basePackageClasses= Account.class)
|
||||
public class JPAConfig {
|
||||
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
package com.wisemapping.config.common;
|
||||
|
||||
import com.wisemapping.security.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
|
||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableMethodSecurity(
|
||||
securedEnabled = true,
|
||||
jsr250Enabled = true)
|
||||
public class SecurityConfig {
|
||||
|
||||
@Autowired
|
||||
private ReadSecurityAdvise readAdvice;
|
||||
|
||||
@Autowired
|
||||
private UpdateSecurityAdvise updateAdvice;
|
||||
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
@Bean
|
||||
protected MethodSecurityExpressionHandler createExpressionHandler() {
|
||||
DefaultMethodSecurityExpressionHandler expressionHandler =
|
||||
new DefaultMethodSecurityExpressionHandler();
|
||||
|
||||
final MapAccessPermissionEvaluation permissionEvaluator = new MapAccessPermissionEvaluation(readAdvice, updateAdvice);
|
||||
expressionHandler.setPermissionEvaluator(permissionEvaluator);
|
||||
return expressionHandler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return DefaultPasswordEncoderFactories.createDelegatingPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider googleAuthenticationProvider() {
|
||||
return new GoogleAuthenticationProvider(userDetailsService);
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider dbAuthenticationProvider() {
|
||||
final com.wisemapping.security.AuthenticationProvider provider =
|
||||
new com.wisemapping.security.AuthenticationProvider();
|
||||
provider.setEncoder(passwordEncoder());
|
||||
provider.setUserDetailsService(userDetailsService);
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(@NotNull HttpSecurity http)
|
||||
throws Exception {
|
||||
final AuthenticationManagerBuilder builder = http.getSharedObject(AuthenticationManagerBuilder.class);
|
||||
builder.userDetailsService(userDetailsService)
|
||||
.passwordEncoder(passwordEncoder());
|
||||
|
||||
builder.authenticationProvider(dbAuthenticationProvider());
|
||||
builder.authenticationProvider(googleAuthenticationProvider());
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
package com.wisemapping.config.rest;
|
||||
|
||||
import com.wisemapping.filter.JwtAuthenticationFilter;
|
||||
import com.wisemapping.rest.MindmapController;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
|
||||
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
||||
|
||||
import static org.springframework.security.config.Customizer.withDefaults;
|
||||
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {MindmapController.class, JwtAuthenticationFilter.class})
|
||||
@EnableWebSecurity
|
||||
public class RestAppConfig {
|
||||
|
||||
@Value("${app.api.http-basic-enabled:false}")
|
||||
private boolean enableHttpBasic;
|
||||
|
||||
@Autowired
|
||||
private JwtAuthenticationFilter jwtAuthenticationFilter;
|
||||
|
||||
@Bean
|
||||
MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
||||
return new MvcRequestMatcher.Builder(introspector);
|
||||
}
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain apiSecurityFilterChain(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
||||
http
|
||||
.securityMatcher("/**")
|
||||
.addFilterAfter(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers(mvc.pattern("/error")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/authenticate")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/users/")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/app/config")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/maps/*/metadata")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/maps/*/document/xml-pub")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/users/resetPassword")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/oauth2/googlecallback")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/oauth2/confirmaccountsync")).permitAll()
|
||||
.requestMatchers(mvc.pattern("/api/restful/admin/**")).hasAnyRole("ADMIN")
|
||||
.requestMatchers(mvc.pattern("/**")).hasAnyRole("USER", "ADMIN")
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.logout(logout -> logout.permitAll()
|
||||
.logoutSuccessHandler((request, response, authentication) -> {
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
}))
|
||||
.csrf(AbstractHttpConfigurer::disable)
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
|
||||
|
||||
// Http basic is mainly used by automation tests.
|
||||
if (enableHttpBasic) {
|
||||
http.httpBasic(withDefaults());
|
||||
}
|
||||
|
||||
return http.build();
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
package com.wisemapping.config.rest;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Value("${app.security.corsAllowedOrigins:}")
|
||||
private String corsAllowedOrigins;
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(@NotNull CorsRegistry registry) {
|
||||
if (!corsAllowedOrigins.isEmpty()) {
|
||||
registry.addMapping("/api/**")
|
||||
.exposedHeaders("*")
|
||||
.allowedHeaders("*")
|
||||
.allowedMethods("*")
|
||||
.allowedOrigins(corsAllowedOrigins)
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LabelManager {
|
||||
|
||||
void addLabel(@NotNull final MindmapLabel label);
|
||||
|
||||
void saveLabel(@NotNull final MindmapLabel label);
|
||||
|
||||
@NotNull
|
||||
List<MindmapLabel> getAllLabels(@NotNull final Account user);
|
||||
|
||||
@Nullable
|
||||
MindmapLabel getLabelById(int id, @NotNull final Account user);
|
||||
|
||||
@Nullable
|
||||
MindmapLabel getLabelByTitle(@NotNull final String title, @NotNull final Account user);
|
||||
|
||||
void removeLabel(@NotNull final MindmapLabel label);
|
||||
}
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository("labelManager")
|
||||
public class LabelManagerImpl
|
||||
implements LabelManager {
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
public void addLabel(@NotNull final MindmapLabel label) {
|
||||
saveLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveLabel(@NotNull final MindmapLabel label) {
|
||||
entityManager.persist(label);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<MindmapLabel> getAllLabels(@NotNull final Account user) {
|
||||
final TypedQuery<MindmapLabel> query = entityManager.createQuery("from com.wisemapping.model.MindmapLabel wisemapping where creator=:creatorId", MindmapLabel.class);
|
||||
query.setParameter("creatorId", user);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MindmapLabel getLabelById(int id, @NotNull final Account user) {
|
||||
final TypedQuery<MindmapLabel> query = entityManager.createQuery("from com.wisemapping.model.MindmapLabel wisemapping where id=:id and creator=:creator", MindmapLabel.class);
|
||||
query.setParameter("id", id);
|
||||
query.setParameter("creator", user);
|
||||
|
||||
final List<MindmapLabel> resultList = query.getResultList();
|
||||
return getFirst(resultList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MindmapLabel getLabelByTitle(@NotNull String title, @NotNull final Account user) {
|
||||
final TypedQuery<MindmapLabel> query = entityManager.createQuery("from com.wisemapping.model.MindmapLabel wisemapping where title=:title and creator=:creator", MindmapLabel.class);
|
||||
query.setParameter("title", title);
|
||||
query.setParameter("creator", user);
|
||||
return query.getResultList().stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabel(@NotNull MindmapLabel label) {
|
||||
entityManager.remove(label);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MindmapLabel getFirst(final List<MindmapLabel> labels) {
|
||||
MindmapLabel result = null;
|
||||
if (labels != null && !labels.isEmpty()) {
|
||||
result = labels.get(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.*;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaDelete;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
@Repository("mindmapManager")
|
||||
public class MindmapManagerImpl
|
||||
implements MindmapManager {
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
public Collaborator findCollaborator(@NotNull final String email) {
|
||||
final Collaborator collaborator;
|
||||
final TypedQuery<Collaborator> query = entityManager.createQuery("from com.wisemapping.model.Collaborator collaborator where email=:email", Collaborator.class);
|
||||
query.setParameter("email", email);
|
||||
|
||||
final List<Collaborator> collaborators = query.getResultList();
|
||||
if (collaborators != null && !collaborators.isEmpty()) {
|
||||
assert collaborators.size() == 1 : "More than one user with the same email!";
|
||||
collaborator = collaborators.get(0);
|
||||
} else {
|
||||
collaborator = null;
|
||||
}
|
||||
return collaborator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MindMapHistory> getHistoryFrom(int mindmapId) {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
|
||||
final CriteriaQuery<MindMapHistory> cr = cb.createQuery(MindMapHistory.class);
|
||||
final Root<MindMapHistory> root = cr.from(MindMapHistory.class);
|
||||
|
||||
final CriteriaQuery<MindMapHistory> select = cr.select(root)
|
||||
.where(cb.equal(root.get("mindmapId"), mindmapId))
|
||||
.orderBy(cb.desc(root.get("creationTime")));
|
||||
|
||||
return entityManager.
|
||||
createQuery(select)
|
||||
.setMaxResults(30)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MindMapHistory getHistory(int historyId) {
|
||||
return entityManager.find(MindMapHistory.class, historyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCollaboration(@NotNull Collaboration collaboration) {
|
||||
entityManager.persist(collaboration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mindmap> findMindmapByUser(@NotNull Account user) {
|
||||
|
||||
final TypedQuery<Mindmap> query = entityManager
|
||||
.createQuery("from com.wisemapping.model.Mindmap m where m.id in (select c.mindMap.id from com.wisemapping.model.Collaboration as c where c.collaborator.id=:collabId )", Mindmap.class);
|
||||
query.setParameter("collabId", user.getId());
|
||||
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collaboration> findCollaboration(final int collaboratorId) {
|
||||
final TypedQuery<Collaboration> query = entityManager.createQuery("from com.wisemapping.model.Collaboration c where c.collaborator.id=:collaboratorId", Collaboration.class);
|
||||
query.setParameter("collaboratorId", collaboratorId);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollaborator(@NotNull Collaborator collaborator) {
|
||||
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
|
||||
entityManager.persist(collaborator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCollaboration(Collaboration collaboration) {
|
||||
entityManager.remove(collaboration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCollaborator(@NotNull Collaborator collaborator) {
|
||||
entityManager.remove(collaborator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Mindmap getMindmapById(int id) {
|
||||
return entityManager.find(Mindmap.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mindmap getMindmapByTitle(final String title, final Account user) {
|
||||
|
||||
final TypedQuery<Mindmap> query = entityManager.createQuery("from com.wisemapping.model.Mindmap wisemapping where title=:title and creator=:creator", Mindmap.class);
|
||||
query.setParameter("title", title);
|
||||
query.setParameter("creator", user);
|
||||
|
||||
List<Mindmap> mindMaps = query.getResultList();
|
||||
|
||||
Mindmap result = null;
|
||||
if (mindMaps != null && !mindMaps.isEmpty()) {
|
||||
result = mindMaps.get(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMindmap(Account user, Mindmap mindMap) {
|
||||
saveMindmap(mindMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveMindmap(Mindmap mindMap) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
entityManager.persist(mindMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
entityManager.merge(mindMap);
|
||||
if (saveHistory) {
|
||||
saveHistory(mindMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMindmap(@NotNull final Mindmap mindmap) {
|
||||
// Delete history first ...
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
|
||||
final CriteriaDelete<MindMapHistory> cr = cb.createCriteriaDelete(MindMapHistory.class);
|
||||
final Root<MindMapHistory> root = cr.from(MindMapHistory.class);
|
||||
|
||||
final CriteriaDelete<MindMapHistory> deleteStatement = cr.where(cb.equal(root.get("mindmapId"), mindmap.getId()));
|
||||
entityManager.createQuery(deleteStatement).executeUpdate();
|
||||
|
||||
// Remove collaborations ...
|
||||
mindmap.removedCollaboration(mindmap.getCollaborations());
|
||||
|
||||
// Delete mindmap ....
|
||||
entityManager.remove(mindmap);
|
||||
}
|
||||
|
||||
private void saveHistory(@NotNull final Mindmap mindMap) {
|
||||
final MindMapHistory history = new MindMapHistory();
|
||||
|
||||
history.setZippedXml(mindMap.getZippedXml());
|
||||
history.setCreationTime(Calendar.getInstance());
|
||||
history.setEditor(mindMap.getLastEditor());
|
||||
history.setMindmapId(mindMap.getId());
|
||||
entityManager.merge(history);
|
||||
}
|
||||
}
|
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.security.DefaultPasswordEncoderFactories;
|
||||
import com.wisemapping.security.LegacyPasswordEncoder;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
@Repository
|
||||
public class UserManagerImpl
|
||||
implements UserManager {
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
public UserManagerImpl() {
|
||||
}
|
||||
|
||||
public void setEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public List<Account> getAllUsers() {
|
||||
return entityManager.createQuery("from com.wisemapping.model.Account user", Account.class).getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Account getUserBy(@NotNull final String email) {
|
||||
Account user = null;
|
||||
|
||||
TypedQuery<Account> query = entityManager.createQuery("from com.wisemapping.model.Account colaborator where email=:email", Account.class);
|
||||
query.setParameter("email", email);
|
||||
|
||||
final List<Account> users = query.getResultList();
|
||||
if (users != null && !users.isEmpty()) {
|
||||
assert users.size() == 1 : "More than one user with the same email!";
|
||||
user = users.get(0);
|
||||
}
|
||||
return user;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaborator getCollaboratorBy(final String email) {
|
||||
final Collaborator result;
|
||||
|
||||
final TypedQuery<Collaborator> query = entityManager.createQuery("from com.wisemapping.model.Collaborator colaborator where " +
|
||||
"email=:email", Collaborator.class);
|
||||
query.setParameter("email", email);
|
||||
|
||||
final List<Collaborator> cols = query.getResultList();
|
||||
if (cols != null && !cols.isEmpty()) {
|
||||
assert cols.size() == 1 : "More than one colaborator with the same email!";
|
||||
result = cols.get(0);
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Account getUserBy(int id) {
|
||||
return entityManager.find(Account.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUser(Account user) {
|
||||
assert user != null : "Trying to store a null user";
|
||||
if (!AuthenticationType.GOOGLE_OAUTH2.equals(user.getAuthenticationType())) {
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
} else {
|
||||
user.setPassword("");
|
||||
}
|
||||
entityManager.persist(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account createUser(@NotNull Account user, @NotNull Collaborator collaborator) {
|
||||
assert user != null : "Trying to store a null user";
|
||||
|
||||
// Migrate from previous temporal collab to new user ...
|
||||
collaborator.setEmail(collaborator.getEmail() + "_toRemove");
|
||||
entityManager.merge(collaborator);
|
||||
entityManager.flush();
|
||||
|
||||
// Save all new...
|
||||
this.createUser(user);
|
||||
|
||||
// Update mindmap ...
|
||||
final Set<Collaboration> collaborations = new CopyOnWriteArraySet<>(collaborator.getCollaborations());
|
||||
for (Collaboration collabs : collaborations) {
|
||||
collabs.setCollaborator(user);
|
||||
}
|
||||
|
||||
// Delete old user ...
|
||||
entityManager.remove(collaborator);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUser(@NotNull final Account user) {
|
||||
entityManager.remove(user);
|
||||
}
|
||||
|
||||
public void auditLogin(@NotNull AccessAuditory accessAuditory) {
|
||||
assert accessAuditory != null : "accessAuditory is null";
|
||||
entityManager.persist(accessAuditory);
|
||||
}
|
||||
|
||||
public void updateUser(@NotNull Account user) {
|
||||
assert user != null : "user is null";
|
||||
|
||||
// Does the password need to be encrypted ?
|
||||
final String password = user.getPassword();
|
||||
if (password != null && (!password.startsWith(LegacyPasswordEncoder.ENC_PREFIX) && !password.startsWith("{" + DefaultPasswordEncoderFactories.ENCODING_ID))) {
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
}
|
||||
|
||||
entityManager.merge(user);
|
||||
}
|
||||
|
||||
public Account getUserByActivationCode(long code) {
|
||||
final Account user;
|
||||
|
||||
final TypedQuery<Account> query = entityManager.createQuery("from com.wisemapping.model.User user where " +
|
||||
"activationCode=:activationCode", Account.class);
|
||||
query.setParameter("activationCode", code);
|
||||
|
||||
final List<Account> users = query.getResultList();
|
||||
if (users != null && !users.isEmpty()) {
|
||||
|
||||
assert users.size() == 1 : "More than one user with the same username!";
|
||||
user = users.get(0);
|
||||
} else {
|
||||
user = null;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AccessDeniedSecurityException
|
||||
extends ClientException {
|
||||
public static final String MSG_KEY = "ACCESS_HAS_BEEN_REVOKED";
|
||||
|
||||
public AccessDeniedSecurityException(@NotNull String msg) {
|
||||
super(msg, Severity.FATAL);
|
||||
}
|
||||
|
||||
public AccessDeniedSecurityException(@NotNull long mapId, Collaborator user) {
|
||||
super("You do not have enough right access to see this map. This map has been changed to private or deleted.", Severity.FATAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class InvalidEmailException
|
||||
extends ClientException {
|
||||
private static final String EMAIL_IS_INVALID = "INVALID_EMAIL_ADDRESS";
|
||||
|
||||
public InvalidEmailException(@NotNull String emails) {
|
||||
super("Invalid email exception:" + emails, Severity.WARNING);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return EMAIL_IS_INVALID;
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class InvalidMindmapException
|
||||
extends ClientException {
|
||||
private static final String EMPTY_MINDMAP = "MINDMAP_EMPTY_ERROR";
|
||||
private static final String INVALID_MINDMAP_FORMAT = "INVALID_MINDMAP_FORMAT";
|
||||
private static final String TOO_BIG_MINDMAP = "TOO_BIG_MINDMAP";
|
||||
|
||||
private final String bundleKey;
|
||||
|
||||
private InvalidMindmapException(@NotNull String bundleKey, @Nullable String xmlDoc) {
|
||||
super("Invalid mindmap format:" + xmlDoc, Severity.SEVERE);
|
||||
this.bundleKey = bundleKey;
|
||||
}
|
||||
|
||||
static public InvalidMindmapException emptyMindmap() {
|
||||
return new InvalidMindmapException(EMPTY_MINDMAP, "<empty string>");
|
||||
}
|
||||
|
||||
static public InvalidMindmapException invalidFormat(@Nullable String xmlDoc) {
|
||||
return new InvalidMindmapException(INVALID_MINDMAP_FORMAT, xmlDoc);
|
||||
}
|
||||
|
||||
static public InvalidMindmapException tooBigMindnap(int numberOfTopics) {
|
||||
return new InvalidMindmapException(TOO_BIG_MINDMAP, "<too-big " + numberOfTopics + ">");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return bundleKey;
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LabelCouldNotFoundException extends ClientException {
|
||||
|
||||
private static final String MSG_KEY = "LABEL_CAN_NOT_BE_FOUND";
|
||||
|
||||
public LabelCouldNotFoundException(@NotNull String msg)
|
||||
{
|
||||
super(msg,Severity.FATAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.LockManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class LockException
|
||||
extends ClientException {
|
||||
private static final String MSG_KEY = "MINDMAP_IS_LOCKED";
|
||||
|
||||
public LockException(@NotNull String message) {
|
||||
super(message, Severity.INFO);
|
||||
}
|
||||
|
||||
public static LockException createLockLost(@NotNull Mindmap mindmap, @NotNull Account user, @NotNull LockManager manager) {
|
||||
return new LockException("Lock can not be granted to " + user.getEmail() + ". The lock is assigned to " + manager.getLockInfo(mindmap));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MapNotPublicSecurityException
|
||||
extends ClientException {
|
||||
public static final String MSG_KEY = "ACCESS_HAS_BEEN_REVOKED";
|
||||
|
||||
public MapNotPublicSecurityException(@NotNull String msg) {
|
||||
super(msg, Severity.FATAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
|
||||
import com.wisemapping.service.google.http.HttpInvokerException;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class OAuthAuthenticationException extends WiseMappingException {
|
||||
|
||||
public OAuthAuthenticationException(@NotNull HttpInvokerException exception) {
|
||||
super(exception.getMessage());
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class PasswordTooLongException
|
||||
extends ClientException {
|
||||
private static final String PASSWORD_TOO_LONG = "PASSWORD_TOO_LONG";
|
||||
|
||||
public PasswordTooLongException() {
|
||||
super("Password length must be less than 40 characters", Severity.WARNING);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return PASSWORD_TOO_LONG;
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class TooManyInactiveAccountsExceptions
|
||||
extends ClientException {
|
||||
private static final String TOO_MANY_INACTIVE_ACCOUNTS = "TOO_MANY_INACTIVE_ACCOUNTS";
|
||||
|
||||
public TooManyInactiveAccountsExceptions(@NotNull long accounts) {
|
||||
super("Too many inactive accounts:" + accounts, Severity.WARNING);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return TOO_MANY_INACTIVE_ACCOUNTS;
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.validation.Errors;
|
||||
|
||||
public class ValidationException extends WiseMappingException {
|
||||
private final Errors errors;
|
||||
|
||||
public ValidationException(@NotNull Errors errors) {
|
||||
super("Validation Exceptions:" + errors);
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
public Errors getErrors() {
|
||||
return errors;
|
||||
}
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
package com.wisemapping.filter;
|
||||
|
||||
import com.wisemapping.security.JwtTokenUtil;
|
||||
import com.wisemapping.security.UserDetails;
|
||||
import com.wisemapping.security.UserDetailsService;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.wisemapping.security.JwtTokenUtil.BEARER_TOKEN_PREFIX;
|
||||
|
||||
@Component
|
||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(@NotNull final HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
final Optional<String> token = getJwtTokenFromRequest(request);
|
||||
|
||||
if (token.isPresent() && SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||
// Extract email from token ...
|
||||
final Optional<String> email = extractEmailFromToken(token.get());
|
||||
|
||||
if (email.isPresent() && jwtTokenUtil.validateJwtToken(token.get())) {
|
||||
// Is it an existing user ?
|
||||
try {
|
||||
final UserDetails userDetails = userDetailsService.loadUserByUsername(email.get());
|
||||
final UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(
|
||||
userDetails, null, userDetails.getAuthorities());
|
||||
authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
||||
} catch (UsernameNotFoundException e) {
|
||||
logger.trace("User " + email.get() + " could not be found");
|
||||
}
|
||||
}
|
||||
}
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
|
||||
private Optional<String> extractEmailFromToken(final @NotNull String token) {
|
||||
Optional<String> result = Optional.empty();
|
||||
try {
|
||||
result = Optional.ofNullable(jwtTokenUtil.extractFromJwtToken(token));
|
||||
} catch (Exception e) {
|
||||
// Handle token extraction/validation errors
|
||||
logger.debug("Error extracting email from token: " + e.getMessage());
|
||||
}
|
||||
logger.trace("JWT token email:" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Optional<String> getJwtTokenFromRequest(@NotNull HttpServletRequest request) {
|
||||
Optional<String> result = Optional.empty();
|
||||
|
||||
final String authorizationHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
if (authorizationHeader != null) {
|
||||
if (authorizationHeader.startsWith(BEARER_TOKEN_PREFIX)) {
|
||||
logger.trace("JWT Bearer token found.");
|
||||
final String token = authorizationHeader.substring(BEARER_TOKEN_PREFIX.length());
|
||||
result = Optional.of(token);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.listener;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.LockException;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LockManager;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpSessionEvent;
|
||||
import jakarta.servlet.http.HttpSessionListener;
|
||||
|
||||
public class UnlockOnExpireListener implements HttpSessionListener {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public void sessionCreated(@NotNull HttpSessionEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionDestroyed(@NotNull HttpSessionEvent event) {
|
||||
|
||||
final ServletContext servletContext = event.getSession().getServletContext();
|
||||
final WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
|
||||
final MindmapService mindmapService = (MindmapService) wc.getBean("mindmapService");
|
||||
|
||||
final LockManager lockManager = mindmapService.getLockManager();
|
||||
final Account user = Utils.getUser(false);
|
||||
if (user != null) {
|
||||
synchronized (mindmapService.getLockManager()) {
|
||||
try {
|
||||
lockManager.unlockAll(user);
|
||||
} catch (LockException | AccessDeniedSecurityException e) {
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "COLLABORATION_PROPERTIES")
|
||||
public class CollaborationProperties implements Serializable {
|
||||
public static final String DEFAULT_JSON_PROPERTIES = "{\"zoom\":0.8}";
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
private boolean starred;
|
||||
@Column(name = "mindmap_properties")
|
||||
private String mindmapProperties;
|
||||
|
||||
public CollaborationProperties() {
|
||||
|
||||
}
|
||||
|
||||
public boolean getStarred() {
|
||||
return starred;
|
||||
}
|
||||
|
||||
public void setStarred(boolean starred) {
|
||||
this.starred = starred;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMindmapProperties() {
|
||||
return mindmapProperties == null ? DEFAULT_JSON_PROPERTIES : mindmapProperties;
|
||||
}
|
||||
|
||||
public void setMindmapProperties(@NotNull String mindmapProperties) {
|
||||
this.mindmapProperties = mindmapProperties;
|
||||
}
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "MINDMAP_LABEL")
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class MindmapLabel implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
@NotNull
|
||||
private String title;
|
||||
@NotNull
|
||||
private String color;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "creator_id", nullable = true, unique = true)
|
||||
@NotNull
|
||||
private Account creator;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "parent_label_id", nullable = true)
|
||||
@Nullable
|
||||
private MindmapLabel parent;
|
||||
|
||||
public void setParent(@Nullable MindmapLabel parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MindmapLabel getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setCreator(@NotNull Account creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Account getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MindmapLabel)) return false;
|
||||
|
||||
final MindmapLabel label = (MindmapLabel) o;
|
||||
return id == label.id && creator.getId() == label.creator.getId()
|
||||
&& Objects.equals(parent, label.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
long result = title.hashCode();
|
||||
result = 31 * result + (creator != null ? creator.hashCode() : 0);
|
||||
result = 31 * result + (parent != null ? parent.hashCode() : 0);
|
||||
return (int) result;
|
||||
}
|
||||
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.InvalidMindmapException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
abstract public class MindmapUtils {
|
||||
|
||||
private static final int MAX_SUPPORTED_NODES = 4000;
|
||||
|
||||
public static void verifyMindmap(@Nullable String xmlDoc) throws InvalidMindmapException {
|
||||
if (xmlDoc == null || xmlDoc.trim().isEmpty()) {
|
||||
// Perform basic structure validation. Must have a map node and
|
||||
throw InvalidMindmapException.emptyMindmap();
|
||||
}
|
||||
|
||||
// Perform basic structure validation without parsing the XML.
|
||||
if (!xmlDoc.trim().endsWith("</map>") || !xmlDoc.trim().startsWith("<map")) {
|
||||
throw InvalidMindmapException.invalidFormat(xmlDoc);
|
||||
}
|
||||
|
||||
int numberOfTopics = xmlDoc.split("<topic").length;
|
||||
// Any valid map must contain at least a central topic ...
|
||||
if (numberOfTopics == 0) {
|
||||
throw InvalidMindmapException.invalidFormat(xmlDoc);
|
||||
}
|
||||
|
||||
// Validate that the number of nodes is not bigger 5000 nodes.
|
||||
if (numberOfTopics > MAX_SUPPORTED_NODES) {
|
||||
throw InvalidMindmapException.tooBigMindnap(numberOfTopics);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.PasswordTooLongException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/restful/account")
|
||||
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
||||
public class AccountController extends BaseController {
|
||||
@Qualifier("userService")
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Qualifier("mindmapService")
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@Qualifier("labelService")
|
||||
@Autowired
|
||||
private LabelService labelService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/password", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changePassword(@RequestBody String password) throws PasswordTooLongException {
|
||||
if (password == null) {
|
||||
throw new IllegalArgumentException("Password can not be null");
|
||||
}
|
||||
|
||||
if (password.length() > Account.MAX_PASSWORD_LENGTH_SIZE) {
|
||||
throw new PasswordTooLongException();
|
||||
}
|
||||
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setPassword(password);
|
||||
userService.changePassword(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "", produces = {"application/json"})
|
||||
public RestUser fetchAccount() {
|
||||
final Account user = Utils.getUser(true);
|
||||
return new RestUser(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/firstname", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changeFirstname(@RequestBody String firstname) {
|
||||
if (firstname == null) {
|
||||
throw new IllegalArgumentException("Firstname can not be null");
|
||||
}
|
||||
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setFirstname(firstname);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/lastname", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changeLastName(@RequestBody String lastname) {
|
||||
if (lastname == null) {
|
||||
throw new IllegalArgumentException("lastname can not be null");
|
||||
|
||||
}
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setLastname(lastname);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/locale", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changeLanguage(@RequestBody String language) {
|
||||
if (language == null) {
|
||||
throw new IllegalArgumentException("language can not be null");
|
||||
|
||||
}
|
||||
|
||||
final Account user = Utils.getUser(true);
|
||||
user.setLocale(language);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "")
|
||||
public void deleteUser() throws WiseMappingException {
|
||||
// Delete collaborations ...
|
||||
final Account user = Utils.getUser(true);
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
final Mindmap mindmap = collaboration.getMindMap();
|
||||
mindmapService.removeMindmap(mindmap, user);
|
||||
}
|
||||
|
||||
// Delete labels ....
|
||||
final List<MindmapLabel> labels = labelService.getAll(user);
|
||||
labels.forEach(l -> {
|
||||
try {
|
||||
labelService.removeLabel(l, user);
|
||||
} catch (WiseMappingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
|
||||
// Finally, delete user ...
|
||||
userService.removeUser(user);
|
||||
}
|
||||
}
|
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/restful/admin")
|
||||
@PreAuthorize("isAuthenticated() and hasRole('ROLE_ADMIN')")
|
||||
public class AdminController extends BaseController {
|
||||
@Qualifier("userService")
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Qualifier("mindmapService")
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/users/{id}", produces = {"application/json"})
|
||||
@ResponseBody
|
||||
public RestUser getUserById(@PathVariable int id) {
|
||||
final Account userBy = userService.getUserBy(id);
|
||||
if (userBy == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
}
|
||||
return new RestUser(userBy);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/users/email/{email:.+}", produces = {"application/json"})
|
||||
@ResponseBody
|
||||
public RestUser getUserByEmail(@PathVariable String email) {
|
||||
final Account user = userService.getUserBy(email);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + email + "' could not be found");
|
||||
}
|
||||
return new RestUser(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/users", consumes = {"application/json"}, produces = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.CREATED)
|
||||
public void createUser(@RequestBody RestUser user, final HttpServletResponse response) throws WiseMappingException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
}
|
||||
|
||||
// User already exists ?
|
||||
final String email = user.getEmail();
|
||||
if (userService.getUserBy(email) != null) {
|
||||
throw new IllegalArgumentException("User already exists with this email.");
|
||||
}
|
||||
|
||||
// Run some other validations ...
|
||||
final Account delegated = user.getDelegated();
|
||||
final String lastname = delegated.getLastname();
|
||||
if (lastname == null || lastname.isEmpty()) {
|
||||
throw new IllegalArgumentException("lastname can not be null");
|
||||
}
|
||||
|
||||
final String firstName = delegated.getFirstname();
|
||||
if (firstName == null || firstName.isEmpty()) {
|
||||
throw new IllegalArgumentException("firstname can not be null");
|
||||
}
|
||||
|
||||
|
||||
final String password = delegated.getPassword();
|
||||
if (password == null || password.isEmpty()) {
|
||||
throw new IllegalArgumentException("password can not be null");
|
||||
}
|
||||
|
||||
// Finally create the user ...
|
||||
delegated.setAuthenticationType(AuthenticationType.DATABASE);
|
||||
userService.createUser(delegated, false, true);
|
||||
response.setHeader("Location", "/api/restful/admin/users/" + user.getId());
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/users/{id}/password", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changePassword(@RequestBody String password, @PathVariable int id) {
|
||||
if (password == null) {
|
||||
throw new IllegalArgumentException("Password can not be null");
|
||||
}
|
||||
|
||||
final Account user = userService.getUserBy(id);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
||||
}
|
||||
user.setPassword(password);
|
||||
userService.changePassword(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/users/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteUserByEmail(@PathVariable int id) throws WiseMappingException {
|
||||
final Account user = userService.getUserBy(id);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
||||
}
|
||||
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
final Mindmap mindmap = collaboration.getMindMap();
|
||||
mindmapService.removeMindmap(mindmap, user);
|
||||
}
|
||||
userService.removeUser(user);
|
||||
}
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.rest.model.RestAppConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/restful/app")
|
||||
public class AppController extends BaseController {
|
||||
|
||||
@Value("${app.security.oauth2.google.url:}")
|
||||
private String googleOauth2Url;
|
||||
|
||||
@Value("${app.registration.enabled:true}")
|
||||
private Boolean isRegistrationEnabled;
|
||||
|
||||
@Value("${app.registration.captcha.enabled:false}")
|
||||
private Boolean isCaptchaEnabled;
|
||||
|
||||
@Value("${app.registration.captcha.siteKey:}")
|
||||
private String captchaSiteKey;
|
||||
|
||||
@Value("${app.site.api-base-url:}")
|
||||
private String apiBaseUrl;
|
||||
|
||||
@Value("${app.site.ui-base-url:}")
|
||||
private String uiBaseUrl;
|
||||
|
||||
@Value("${app.analytics.account:}")
|
||||
private String analyticsAccount;
|
||||
|
||||
@Value("${app.jwt.expirationMin:10080}")
|
||||
private int jwtExpirationMin;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/config")
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public RestAppConfig appConfig() {
|
||||
return new RestAppConfig.RestAppConfigBuilder()
|
||||
.setApiUrl(apiBaseUrl)
|
||||
.setUiUrl(uiBaseUrl)
|
||||
.setCaptchaSiteKey(captchaSiteKey)
|
||||
.setGoogleOauth2Url(googleOauth2Url)
|
||||
.setAnalyticsAccount(analyticsAccount)
|
||||
.setRegistrationEnabled(isRegistrationEnabled)
|
||||
.setJwtExpirationMin(jwtExpirationMin)
|
||||
.build();
|
||||
}
|
||||
|
||||
public String getGoogleOauth2Url() {
|
||||
return googleOauth2Url;
|
||||
}
|
||||
|
||||
public void setGoogleOauth2Url(String googleOauth2Url) {
|
||||
this.googleOauth2Url = googleOauth2Url;
|
||||
}
|
||||
|
||||
public Boolean getRegistrationEnabled() {
|
||||
return isRegistrationEnabled;
|
||||
}
|
||||
|
||||
public void setRegistrationEnabled(Boolean registrationEnabled) {
|
||||
isRegistrationEnabled = registrationEnabled;
|
||||
}
|
||||
|
||||
public Boolean getCaptchaEnabled() {
|
||||
return isCaptchaEnabled;
|
||||
}
|
||||
|
||||
public void setCaptchaEnabled(Boolean captchaEnabled) {
|
||||
isCaptchaEnabled = captchaEnabled;
|
||||
}
|
||||
|
||||
public String getCaptchaSiteKey() {
|
||||
return captchaSiteKey;
|
||||
}
|
||||
|
||||
public void setCaptchaSiteKey(String captchaSiteKey) {
|
||||
this.captchaSiteKey = captchaSiteKey;
|
||||
}
|
||||
|
||||
public String getApiBaseUrl() {
|
||||
return apiBaseUrl;
|
||||
}
|
||||
|
||||
public void setApiBaseUrl(String apiBaseUrl) {
|
||||
this.apiBaseUrl = apiBaseUrl;
|
||||
}
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.rest.model.RestJwtUser;
|
||||
import com.wisemapping.security.JwtTokenUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/restful")
|
||||
public class JwtAuthController {
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
@RequestMapping(value = "/authenticate", method = RequestMethod.POST)
|
||||
public ResponseEntity<String> createAuthenticationToken(@RequestBody RestJwtUser user, @NotNull HttpServletResponse response) throws WiseMappingException {
|
||||
// Is a valid user ?
|
||||
authenticate(user.getEmail(), user.getPassword());
|
||||
final String result = jwtTokenUtil.doLogin(response, user.getEmail());
|
||||
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
private void authenticate(@NotNull String username, @NotNull String password) throws WiseMappingException {
|
||||
try {
|
||||
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
||||
} catch (DisabledException | BadCredentialsException e) {
|
||||
throw new WiseMappingException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.rest.model.RestOath2CallbackResponse;
|
||||
import com.wisemapping.security.JwtTokenUtil;
|
||||
import com.wisemapping.service.UserService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/restful/oauth2/")
|
||||
@CrossOrigin
|
||||
public class OAuth2Controller extends BaseController {
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
|
||||
@Qualifier("userService")
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Qualifier("authenticationManager")
|
||||
@Autowired
|
||||
private AuthenticationManager authManager;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "googlecallback", produces = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public RestOath2CallbackResponse processGoogleCallback(@NotNull @RequestParam String code, @NotNull HttpServletResponse response, @NotNull HttpServletRequest request) throws WiseMappingException {
|
||||
logger.debug("ProcessGoogleCallback:" + code);
|
||||
if (code == null) {
|
||||
throw new WiseMappingException("Illegal argument exception: " + code);
|
||||
}
|
||||
|
||||
final Account user = userService.createAndAuthUserFromGoogle(code);
|
||||
String jwtToken = null;
|
||||
if (user.getGoogleSync()) {
|
||||
jwtToken = jwtTokenUtil.doLogin(response, user.getEmail());
|
||||
}
|
||||
|
||||
// Response ...
|
||||
return new RestOath2CallbackResponse(user, jwtToken);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "confirmaccountsync", produces = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public RestOath2CallbackResponse confirmAccountSync(@NotNull @RequestParam String email, @NotNull @RequestParam String code, @NotNull HttpServletResponse response) throws WiseMappingException {
|
||||
logger.debug("ConfirmAccountSync:" + email + " - " + code);
|
||||
if (code == null) {
|
||||
throw new WiseMappingException("Illegal argument exception: " + email + " - " + code);
|
||||
}
|
||||
|
||||
// Update login
|
||||
final Account user = userService.confirmGoogleAccountSync(email, code);
|
||||
|
||||
// Add header ...
|
||||
final String jwtToken = jwtTokenUtil.doLogin(response, email);
|
||||
|
||||
// Response ...
|
||||
return new RestOath2CallbackResponse(user, jwtToken);
|
||||
}
|
||||
}
|
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RestAppConfig {
|
||||
private String apiBaseUrl;
|
||||
private String uiBaseUrl;
|
||||
private String googleOauth2Url;
|
||||
private boolean registrationEnabled;
|
||||
private boolean recaptcha2Enabled;
|
||||
private String recaptcha2SiteKey;
|
||||
private String analyticsAccount;
|
||||
|
||||
private int jwtExpirationMin = 10080;
|
||||
|
||||
RestAppConfig() {
|
||||
|
||||
}
|
||||
|
||||
public String getApiBaseUrl() {
|
||||
return apiBaseUrl;
|
||||
}
|
||||
|
||||
public void setApiBaseUrl(String apiBaseUrl) {
|
||||
this.apiBaseUrl = apiBaseUrl;
|
||||
}
|
||||
|
||||
public String getGoogleOauth2Url() {
|
||||
return googleOauth2Url;
|
||||
}
|
||||
|
||||
public void setGoogleOauth2Url(String googleOauth2Url) {
|
||||
this.googleOauth2Url = googleOauth2Url;
|
||||
}
|
||||
|
||||
public boolean isRegistrationEnabled() {
|
||||
return registrationEnabled;
|
||||
}
|
||||
|
||||
public void setRegistrationEnabled(boolean registrationEnabled) {
|
||||
this.registrationEnabled = registrationEnabled;
|
||||
}
|
||||
|
||||
public boolean isRecaptcha2Enabled() {
|
||||
return recaptcha2Enabled;
|
||||
}
|
||||
|
||||
public void setRecaptcha2Enabled(boolean recaptcha2Enabled) {
|
||||
this.recaptcha2Enabled = recaptcha2Enabled;
|
||||
}
|
||||
|
||||
public String getRecaptcha2SiteKey() {
|
||||
return recaptcha2SiteKey;
|
||||
}
|
||||
|
||||
public void setRecaptcha2SiteKey(String recaptcha2SiteKey) {
|
||||
this.recaptcha2SiteKey = recaptcha2SiteKey;
|
||||
}
|
||||
|
||||
public String getAnalyticsAccount() {
|
||||
return analyticsAccount;
|
||||
}
|
||||
|
||||
public void setAnalyticsAccount(String analyticsAccount) {
|
||||
this.analyticsAccount = analyticsAccount;
|
||||
}
|
||||
|
||||
public int getJwtExpirationMin() {
|
||||
return jwtExpirationMin;
|
||||
}
|
||||
|
||||
public void setJwtExpirationMin(int jwtExpirationMin) {
|
||||
this.jwtExpirationMin = jwtExpirationMin;
|
||||
}
|
||||
|
||||
public String getUiBaseUrl() {
|
||||
return uiBaseUrl;
|
||||
}
|
||||
|
||||
public void setUiBaseUrl(String uiBaseUrl) {
|
||||
this.uiBaseUrl = uiBaseUrl;
|
||||
}
|
||||
|
||||
public static class RestAppConfigBuilder {
|
||||
private String apiBaseUrl;
|
||||
private String uiBaseUrl;
|
||||
private String googleOauth2Url;
|
||||
private boolean registrationEnabled;
|
||||
private boolean isCatchaEnabled = false;
|
||||
private String captchaSiteKey;
|
||||
private String analyticsAccount;
|
||||
|
||||
private int jwtExpirationMin;
|
||||
|
||||
public RestAppConfigBuilder setCaptchaSiteKey(@NotNull String captchaSiteKey) {
|
||||
this.captchaSiteKey = captchaSiteKey;
|
||||
this.isCatchaEnabled = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestAppConfigBuilder setApiUrl(@NotNull String url) {
|
||||
this.apiBaseUrl = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestAppConfigBuilder setUiUrl(@NotNull String url) {
|
||||
this.uiBaseUrl = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestAppConfigBuilder setJwtExpirationMin(@NotNull int value) {
|
||||
this.jwtExpirationMin = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestAppConfigBuilder setGoogleOauth2Url(@NotNull String googleOauth2Url) {
|
||||
this.googleOauth2Url = googleOauth2Url;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void setGoogleAnalyticsAccount(@NotNull String analyticsAccount) {
|
||||
this.analyticsAccount = analyticsAccount;
|
||||
}
|
||||
|
||||
public RestAppConfigBuilder setRegistrationEnabled(@NotNull boolean registrationEnabled) {
|
||||
this.registrationEnabled = registrationEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestAppConfigBuilder setAnalyticsAccount(@NotNull String analyticsAccount) {
|
||||
this.analyticsAccount = analyticsAccount;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RestAppConfig build() {
|
||||
final RestAppConfig result = new RestAppConfig();
|
||||
result.googleOauth2Url = googleOauth2Url;
|
||||
result.recaptcha2SiteKey = captchaSiteKey;
|
||||
result.recaptcha2Enabled = isCatchaEnabled;
|
||||
result.uiBaseUrl = uiBaseUrl;
|
||||
result.apiBaseUrl = apiBaseUrl;
|
||||
result.registrationEnabled = registrationEnabled;
|
||||
result.analyticsAccount = analyticsAccount;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RestJwtUser {
|
||||
|
||||
private String email;
|
||||
private String password;
|
||||
|
||||
public RestJwtUser(@NotNull String email, @NotNull String password) {
|
||||
this.setEmail(email);
|
||||
this.setPassword(password);
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.LockInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RestLockInfo {
|
||||
|
||||
private String email;
|
||||
|
||||
// This is required only for compliance with the JAXB serializer.
|
||||
public RestLockInfo() {
|
||||
|
||||
}
|
||||
|
||||
public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull Account user) {
|
||||
this.email = user.getEmail();
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
||||
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY
|
||||
)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RestMindmapMetadata {
|
||||
private String jsonProps;
|
||||
private boolean locked;
|
||||
private String title;
|
||||
private String isLockedBy;
|
||||
|
||||
private String creatorFullName;
|
||||
|
||||
public RestMindmapMetadata(@NotNull String title, @NotNull String jsonProps, @NotNull String creatorFullName, boolean locked, @Nullable String isLockedBy) {
|
||||
this.jsonProps = jsonProps;
|
||||
this.title = title;
|
||||
this.locked = locked;
|
||||
this.isLockedBy = isLockedBy;
|
||||
this.creatorFullName = creatorFullName;
|
||||
}
|
||||
|
||||
public String getJsonProps() {
|
||||
return jsonProps;
|
||||
}
|
||||
|
||||
public void setJsonProps(String jsonProps) {
|
||||
this.jsonProps = jsonProps;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getIsLockedBy() {
|
||||
return isLockedBy;
|
||||
}
|
||||
|
||||
public void setIsLockedBy(String isLockedBy) {
|
||||
this.isLockedBy = isLockedBy;
|
||||
}
|
||||
|
||||
public String getCreatorFullName() {
|
||||
return creatorFullName;
|
||||
}
|
||||
|
||||
public void setCreatorFullName(String creatorFullName) {
|
||||
this.creatorFullName = creatorFullName;
|
||||
}
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY
|
||||
)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RestOath2CallbackResponse {
|
||||
|
||||
private String email;
|
||||
private Boolean googleSync;
|
||||
private String syncCode;
|
||||
private String jwtToken;
|
||||
|
||||
public RestOath2CallbackResponse(@NotNull Account user, @Nullable String jwtToken) {
|
||||
this.setEmail(user.getEmail());
|
||||
this.setGoogleSync(user.getGoogleSync());
|
||||
this.setSyncCode(user.getSyncCode());
|
||||
this.setJwtToken(jwtToken);
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Boolean getGoogleSync() {
|
||||
return googleSync;
|
||||
}
|
||||
|
||||
public void setGoogleSync(Boolean googleSync) {
|
||||
this.googleSync = googleSync;
|
||||
}
|
||||
|
||||
public String getSyncCode() {
|
||||
return syncCode;
|
||||
}
|
||||
|
||||
public void setSyncCode(String syncCode) {
|
||||
this.syncCode = syncCode;
|
||||
}
|
||||
|
||||
public String getJwtToken() {
|
||||
return jwtToken;
|
||||
}
|
||||
|
||||
public void setJwtToken(String jwtToken) {
|
||||
this.jwtToken = jwtToken;
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
public enum RestResetPasswordAction {
|
||||
|
||||
EMAIL_SENT, OAUTH2_USER
|
||||
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
public class RestResetPasswordResponse {
|
||||
|
||||
RestResetPasswordAction action;
|
||||
|
||||
public RestResetPasswordAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(RestResetPasswordAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.security;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DefaultPasswordEncoderFactories {
|
||||
|
||||
public static final String ENCODING_ID = "bcrypt";
|
||||
|
||||
public static PasswordEncoder createDelegatingPasswordEncoder() {
|
||||
|
||||
final Map<String, PasswordEncoder> encoders = new HashMap<>();
|
||||
encoders.put(ENCODING_ID, new BCryptPasswordEncoder(12));
|
||||
|
||||
DelegatingPasswordEncoder result = new DelegatingPasswordEncoder(ENCODING_ID, encoders);
|
||||
result.setDefaultPasswordEncoderForMatches(new LegacyPasswordEncoder());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
package com.wisemapping.security;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||
|
||||
import com.wisemapping.model.Account;
|
||||
|
||||
public class GoogleAuthenticationProvider implements org.springframework.security.authentication.AuthenticationProvider {
|
||||
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
public GoogleAuthenticationProvider(@NotNull UserDetailsService userDetailsService) {
|
||||
this.userDetailsService = userDetailsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate the given PreAuthenticatedAuthenticationToken.
|
||||
* <p>
|
||||
* If the principal contained in the authentication object is null, the request will
|
||||
* be ignored to allow other providers to authenticate it.
|
||||
*/
|
||||
@Override
|
||||
public Authentication authenticate(Authentication inputToken) throws AuthenticationException {
|
||||
if (!supports(inputToken.getClass())) {
|
||||
return null;
|
||||
}
|
||||
if (inputToken.getPrincipal() == null) {
|
||||
throw new BadCredentialsException("No pre-authenticated principal found in request.");
|
||||
}
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(inputToken.getName());
|
||||
final Account user = userDetails.getUser();
|
||||
|
||||
if (!user.isActive()) {
|
||||
throw new BadCredentialsException("User has been disabled for login " + inputToken.getName());
|
||||
}
|
||||
|
||||
PreAuthenticatedAuthenticationToken resultToken = new PreAuthenticatedAuthenticationToken(userDetails,
|
||||
inputToken.getCredentials(), userDetails.getAuthorities());
|
||||
resultToken.setDetails(userDetails);
|
||||
|
||||
userDetailsService.getUserService().auditLogin(user);
|
||||
|
||||
return resultToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that this provider only supports PreAuthenticatedAuthenticationToken
|
||||
* (sub)classes.
|
||||
*/
|
||||
@Override
|
||||
public final boolean supports(Class<?> authentication) {
|
||||
return PreAuthenticatedAuthenticationToken.class.isAssignableFrom(authentication);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
package com.wisemapping.security;
|
||||
|
||||
import io.jsonwebtoken.*;
|
||||
import io.jsonwebtoken.io.Decoders;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.Key;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class JwtTokenUtil implements Serializable {
|
||||
final private Logger logger = LogManager.getLogger();
|
||||
public final static String BEARER_TOKEN_PREFIX = "Bearer ";
|
||||
|
||||
|
||||
@Value("${app.jwt.secret}")
|
||||
private String jwtSecret;
|
||||
|
||||
@Value("${app.jwt.expirationMin}")
|
||||
private int jwtExpirationMin;
|
||||
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
|
||||
public String generateJwtToken(@NotNull final UserDetails user) {
|
||||
return Jwts.builder()
|
||||
.setSubject((user.getUsername()))
|
||||
.setIssuedAt(new Date())
|
||||
.setExpiration(new Date((new Date()).getTime() + jwtExpirationMin * 1000L * 60))
|
||||
.signWith(key(), SignatureAlgorithm.HS256)
|
||||
.compact();
|
||||
}
|
||||
|
||||
private Key key() {
|
||||
return Keys.hmacShaKeyFor(Decoders.BASE64.decode(jwtSecret));
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public String extractFromJwtToken(String token) {
|
||||
return Jwts.parserBuilder().setSigningKey(key()).build()
|
||||
.parseClaimsJws(token).getBody().getSubject();
|
||||
}
|
||||
|
||||
public boolean validateJwtToken(@NotNull String authToken) {
|
||||
boolean result = false;
|
||||
try {
|
||||
Jwts.parserBuilder().setSigningKey(key()).build().parse(authToken);
|
||||
result = true;
|
||||
} catch (MalformedJwtException e) {
|
||||
logger.error("Invalid JWT token: {}", e.getMessage());
|
||||
} catch (ExpiredJwtException e) {
|
||||
logger.error("JWT token is expired: {}", e.getMessage());
|
||||
} catch (UnsupportedJwtException e) {
|
||||
logger.error("JWT token is unsupported: {}", e.getMessage());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("JWT claims string is empty: {}", e.getMessage());
|
||||
}
|
||||
|
||||
logger.trace("Is JWT token valid:" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String doLogin(@NotNull HttpServletResponse response, @NotNull String email) {
|
||||
logger.debug("Performing login:" + email);
|
||||
final UserDetails userDetails = userDetailsService.loadUserByUsername(email);
|
||||
|
||||
// Add JWT in the HTTP header ...
|
||||
final String token = generateJwtToken(userDetails);
|
||||
response.addHeader(HttpHeaders.AUTHORIZATION, BEARER_TOKEN_PREFIX + token);
|
||||
|
||||
return token;
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
package com.wisemapping.security;
|
||||
|
||||
public enum MapAccessPermission {
|
||||
READ,
|
||||
WRITE
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
package com.wisemapping.security;
|
||||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.Account;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.security.access.PermissionEvaluator;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public class MapAccessPermissionEvaluation implements PermissionEvaluator {
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
|
||||
private MapPermissionsSecurityAdvice readAdvice;
|
||||
|
||||
private MapPermissionsSecurityAdvice updateAdvice;
|
||||
|
||||
public MapAccessPermissionEvaluation(final @NotNull MapPermissionsSecurityAdvice readAdvice, final @NotNull MapPermissionsSecurityAdvice updateAdvice) {
|
||||
this.readAdvice = readAdvice;
|
||||
this.updateAdvice = updateAdvice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(
|
||||
@NotNull Authentication auth, @NotNull Object targetDomainObject, @NotNull Object permission) {
|
||||
|
||||
logger.log(Level.DEBUG, "auth: " + auth + ",targetDomainObject:" + targetDomainObject + ",permission:" + permission);
|
||||
if ((auth == null) || (targetDomainObject == null) || !(permission instanceof String)) {
|
||||
logger.debug("Permissions could not be validated, illegal parameters.");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean result;
|
||||
final Account user = Utils.getUser();
|
||||
final MapAccessPermission perm = MapAccessPermission.valueOf((permission.toString().toUpperCase()));
|
||||
if (targetDomainObject instanceof Integer) {
|
||||
// Checking permissions by mapId ...
|
||||
final int mapId = (Integer) targetDomainObject;
|
||||
result = hasPrivilege(mapId, perm);
|
||||
} else if (targetDomainObject instanceof Mindmap) {
|
||||
final Mindmap map = (Mindmap) targetDomainObject;
|
||||
result = hasPrivilege(map, perm);
|
||||
} else if (targetDomainObject instanceof Collaborator collab) {
|
||||
// Read only operations checks ...
|
||||
result = user.identityEquality(collab) || readAdvice.getMindmapService().isAdmin(user);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported check control of permissions");
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
logger.debug("User '" + (user != null ? user.getEmail() : "none") + "' not allowed to invoke");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(
|
||||
@NotNull Authentication auth, Serializable targetId, @NotNull String targetType, @NotNull Object
|
||||
permission) {
|
||||
logger.log(Level.FATAL, "Unsupported privilege: auth: " + auth + ",targetId:" + targetType + ",targetType:" + targetType + ", permission:" + permission);
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasPrivilege(@NotNull int mapId, @NotNull MapAccessPermission permission) {
|
||||
boolean result;
|
||||
final Account user = Utils.getUser();
|
||||
if (MapAccessPermission.READ == permission) {
|
||||
result = readAdvice.isAllowed(user, mapId);
|
||||
} else {
|
||||
result = updateAdvice.isAllowed(user, mapId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean hasPrivilege(@NotNull Mindmap map, @NotNull MapAccessPermission permission) {
|
||||
boolean result;
|
||||
final Account user = Utils.getUser();
|
||||
if (MapAccessPermission.READ == permission) {
|
||||
result = readAdvice.isAllowed(user, map);
|
||||
} else {
|
||||
result = updateAdvice.isAllowed(user, map);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.security;
|
||||
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class UpdateSecurityAdvise
|
||||
extends MapPermissionsSecurityAdvice {
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable Account user, @NotNull Mindmap map) {
|
||||
boolean result;
|
||||
if (map.getCreator() == null) {
|
||||
// This means that the map is new and is an add operation.
|
||||
result = true;
|
||||
} else {
|
||||
result = getMindmapService().hasPermissions(user, map, CollaborationRole.EDITOR);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAllowed(@Nullable Account user, int mapId) {
|
||||
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR);
|
||||
}
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.security;
|
||||
|
||||
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class UserDetailsService
|
||||
implements org.springframework.security.core.userdetails.UserDetailsService {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Value("${app.admin.user}")
|
||||
private String adminUser;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(@NotNull String email) throws UsernameNotFoundException, DataAccessException {
|
||||
final Account user = userService.getUserBy(email);
|
||||
|
||||
if (user != null) {
|
||||
return new UserDetails(user, isAdmin(email));
|
||||
} else {
|
||||
throw new UsernameNotFoundException(email);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAdmin(@Nullable String email) {
|
||||
return email != null && adminUser != null && email.trim().endsWith(adminUser);
|
||||
}
|
||||
|
||||
public UserService getUserService() {
|
||||
return userService;
|
||||
}
|
||||
|
||||
public void setUserService(UserService userManager) {
|
||||
this.userService = userManager;
|
||||
}
|
||||
|
||||
public String getAdminUser() {
|
||||
return adminUser;
|
||||
}
|
||||
|
||||
public void setAdminUser(String adminUser) {
|
||||
this.adminUser = adminUser;
|
||||
}
|
||||
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LabelService {
|
||||
|
||||
void addLabel(@NotNull final MindmapLabel label, @NotNull final Account user) throws WiseMappingException;
|
||||
|
||||
@NotNull List<MindmapLabel> getAll(@NotNull final Account user);
|
||||
|
||||
@Nullable
|
||||
MindmapLabel findLabelById(int id, @NotNull final Account user);
|
||||
|
||||
MindmapLabel getLabelByTitle(@NotNull String title, @NotNull final Account user);
|
||||
|
||||
void removeLabel(@NotNull final MindmapLabel label, @NotNull final Account user) throws WiseMappingException;
|
||||
}
|
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.dao.LabelManager;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.MindmapLabel;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("labelService")
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public class LabelServiceImpl implements LabelService {
|
||||
|
||||
@Autowired
|
||||
private LabelManager labelManager;
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'WRITE')")
|
||||
public void addLabel(@NotNull final MindmapLabel label, @NotNull final Account user) {
|
||||
|
||||
label.setCreator(user);
|
||||
labelManager.addLabel(label);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public List<MindmapLabel> getAll(@NotNull final Account user) {
|
||||
return labelManager.getAllLabels(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public MindmapLabel findLabelById(int id, @NotNull final Account user) {
|
||||
return labelManager.getLabelById(id, user);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'READ')")
|
||||
public MindmapLabel getLabelByTitle(@NotNull String title, @NotNull final Account user) {
|
||||
return labelManager.getLabelByTitle(title, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAnyRole('USER', 'ADMIN') && hasPermission(#user, 'WRITE')")
|
||||
public void removeLabel(@NotNull MindmapLabel label, @NotNull Account user) throws WiseMappingException {
|
||||
if (label.getCreator().equals(user)) {
|
||||
labelManager.removeLabel(label);
|
||||
} else {
|
||||
throw new WiseMappingException("User: "+ user.getFullName() + "has no ownership on label " + label.getTitle());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.LockException;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface LockManager {
|
||||
boolean isLocked(@NotNull Mindmap mindmap);
|
||||
|
||||
LockInfo getLockInfo(@NotNull Mindmap mindmap);
|
||||
|
||||
void unlock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException, AccessDeniedSecurityException;
|
||||
|
||||
void unlockAll(@NotNull Account user) throws LockException, AccessDeniedSecurityException;
|
||||
|
||||
boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull Account user);
|
||||
|
||||
long generateSession();
|
||||
|
||||
@NotNull
|
||||
LockInfo lock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException;
|
||||
}
|
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.LockException;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.Account;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
class LockManagerImpl implements LockManager {
|
||||
private static final int ONE_MINUTE_MILLISECONDS = 1000 * 60;
|
||||
private final Map<Integer, LockInfo> lockInfoByMapId;
|
||||
private final static Timer expirationTimer = new Timer();
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public boolean isLocked(@NotNull Mindmap mindmap) {
|
||||
return this.getLockInfo(mindmap) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LockInfo getLockInfo(@NotNull Mindmap mindmap) {
|
||||
return lockInfoByMapId.get(mindmap.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlockAll(@NotNull final Account user) throws LockException, AccessDeniedSecurityException {
|
||||
final Set<Integer> mapIds = lockInfoByMapId.keySet();
|
||||
for (final Integer mapId : mapIds) {
|
||||
final LockInfo lockInfo = lockInfoByMapId.get(mapId);
|
||||
if (lockInfo.getUser().identityEquality(user)) {
|
||||
unlock(mapId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException, AccessDeniedSecurityException {
|
||||
verifyHasLock(mindmap, user);
|
||||
this.unlock(mindmap.getId());
|
||||
}
|
||||
|
||||
private void unlock(int mapId) {
|
||||
logger.debug("Unlock map id:" + mapId);
|
||||
lockInfoByMapId.remove(mapId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull Account collaborator) {
|
||||
boolean result = false;
|
||||
final LockInfo lockInfo = this.getLockInfo(mindmap);
|
||||
if (lockInfo != null && lockInfo.getUser().identityEquality(collaborator)) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long generateSession() {
|
||||
return System.nanoTime();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public LockInfo lock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException {
|
||||
if (isLocked(mindmap) && !isLockedBy(mindmap, user)) {
|
||||
throw LockException.createLockLost(mindmap, user, this);
|
||||
}
|
||||
|
||||
// Do I need to create a new lock ?
|
||||
LockInfo result = lockInfoByMapId.get(mindmap.getId());
|
||||
if (result == null) {
|
||||
logger.debug("Creating new lock for map id:" + mindmap.getId());
|
||||
result = new LockInfo(user, mindmap);
|
||||
lockInfoByMapId.put(mindmap.getId(), result);
|
||||
}
|
||||
|
||||
// Update timestamp ...
|
||||
logger.debug("Updating timeout:" + result);
|
||||
result.updateTimeout();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void verifyHasLock(@NotNull Mindmap mindmap, @NotNull Account user) throws LockException, AccessDeniedSecurityException {
|
||||
// Only editor can have lock ...
|
||||
if (!mindmap.hasPermissions(user, CollaborationRole.EDITOR)) {
|
||||
throw new AccessDeniedSecurityException(mindmap.getId(), user);
|
||||
}
|
||||
|
||||
// Is the lock assigned to the user ...
|
||||
if (isLocked(mindmap) && !isLockedBy(mindmap, user)) {
|
||||
throw LockException.createLockLost(mindmap, user, this);
|
||||
}
|
||||
}
|
||||
|
||||
public LockManagerImpl() {
|
||||
lockInfoByMapId = new ConcurrentHashMap<>();
|
||||
expirationTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
synchronized (this) {
|
||||
logger.debug("Lock expiration scheduler started. Current locks:" + lockInfoByMapId.keySet());
|
||||
// Search for expired sessions and remove them ....
|
||||
lockInfoByMapId.
|
||||
keySet().
|
||||
stream().
|
||||
filter(mapId -> lockInfoByMapId.get(mapId).isExpired()).
|
||||
forEach(mapId -> unlock(mapId));
|
||||
}
|
||||
|
||||
}
|
||||
}, ONE_MINUTE_MILLISECONDS, ONE_MINUTE_MILLISECONDS);
|
||||
}
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.model.Account;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
final public class NotificationService {
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
@Autowired
|
||||
private ResourceBundleMessageSource messageSource;
|
||||
|
||||
@Autowired
|
||||
private MailerService mailerService;
|
||||
|
||||
@Value("${app.site.ui-base-url:http://localhost:8080/}")
|
||||
private String baseUrl;
|
||||
|
||||
public void newCollaboration(@NotNull Collaboration collaboration, @NotNull Mindmap mindmap, @NotNull Account user, @Nullable String message) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
try {
|
||||
// Sent collaboration email ...
|
||||
final String formMail = mailerService.getServerSenderEmail();
|
||||
|
||||
// Is the user already registered user ?.
|
||||
final String collabEmail = collaboration.getCollaborator().getEmail();
|
||||
|
||||
// Build the subject ...
|
||||
final String subject = messageSource.getMessage("SHARE_MAP.EMAIL_SUBJECT", new Object[]{user.getFullName()}, locale);
|
||||
|
||||
// Fill template properties ...
|
||||
final Map<String, Object> model = new HashMap<>();
|
||||
model.put("mindmap", mindmap);
|
||||
model.put("ownerName", user.getFirstname());
|
||||
model.put("mapEditUrl", getBaseUrl() + "/c/maps/" + mindmap.getId() + "/edit");
|
||||
model.put("baseUrl", getBaseUrl());
|
||||
model.put("senderMail", user.getEmail());
|
||||
model.put("message", message);
|
||||
model.put("doNotReplay", messageSource.getMessage("EMAIL.DO_NOT_REPLAY", new Object[]{mailerService.getSupportEmail()}, locale));
|
||||
|
||||
// To resolve resources on templates ...
|
||||
model.put("noArg", new Object[]{});
|
||||
model.put("messages", messageSource);
|
||||
model.put("locale", locale);
|
||||
|
||||
mailerService.sendEmail(formMail, collabEmail, subject, model, "newCollaboration.vm");
|
||||
} catch (Exception e) {
|
||||
logger.info(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void resetPassword(@NotNull Account user, @NotNull String temporalPassword) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
final String mailSubject = messageSource.getMessage("CHANGE_PASSWORD.EMAIL_SUBJECT", null, locale);
|
||||
final String messageTitle = messageSource.getMessage("CHANGE_PASSWORD.EMAIL_TITLE", null, locale);
|
||||
final String messageBody = messageSource.getMessage("CHANGE_PASSWORD.EMAIL_BODY", new Object[]{temporalPassword, getBaseUrl()}, locale);
|
||||
|
||||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||
}
|
||||
|
||||
|
||||
public void passwordChanged(@NotNull Account user) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
final String mailSubject = messageSource.getMessage("PASSWORD_CHANGED.EMAIL_SUBJECT", null, locale);
|
||||
final String messageTitle = messageSource.getMessage("PASSWORD_CHANGED.EMAIL_TITLE", null, locale);
|
||||
final String messageBody = messageSource.getMessage("PASSWORD_CHANGED.EMAIL_BODY", null, locale);
|
||||
|
||||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||
}
|
||||
|
||||
public void newAccountCreated(@NotNull Account user) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
final String mailSubject = messageSource.getMessage("REGISTRATION.EMAIL_SUBJECT", null, locale);
|
||||
final String messageTitle = messageSource.getMessage("REGISTRATION.EMAIL_TITLE", null, locale);
|
||||
final String messageBody = messageSource.getMessage("REGISTRATION.EMAIL_BODY", null, locale);
|
||||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||
}
|
||||
|
||||
private void sendTemplateMail(@NotNull Account user, @NotNull String mailSubject, @NotNull String messageTitle, @NotNull String messageBody) {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
try {
|
||||
final Map<String, Object> model = new HashMap<>();
|
||||
model.put("firstName", user.getFirstname());
|
||||
model.put("messageTitle", messageTitle);
|
||||
model.put("messageBody", messageBody);
|
||||
model.put("baseUrl", getBaseUrl());
|
||||
model.put("support-email", mailerService.getSupportEmail());
|
||||
model.put("doNotReplay", messageSource.getMessage("EMAIL.DO_NOT_REPLAY", new Object[]{mailerService.getSupportEmail()}, locale));
|
||||
|
||||
// To resolve resources on templates ...
|
||||
model.put("noArg", new Object[]{});
|
||||
model.put("messages", messageSource);
|
||||
model.put("locale", locale);
|
||||
|
||||
logger.debug("Email properties->" + model);
|
||||
mailerService.sendEmail(mailerService.getServerSenderEmail(), user.getEmail(), mailSubject, model, "baseLayout.vm");
|
||||
} catch (Exception e) {
|
||||
logger.info(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void activateAccount(@NotNull Account user) {
|
||||
final Map<String, Object> model = new HashMap<>();
|
||||
model.put("user", user);
|
||||
mailerService.sendEmail(mailerService.getServerSenderEmail(), user.getEmail(), "[WiseMapping] Active account", model, "activationAccountMail.vm");
|
||||
}
|
||||
|
||||
public void sendRegistrationEmail(@NotNull Account user) {
|
||||
// throw new UnsupportedOperationException("Not implemented yet");
|
||||
// try {
|
||||
// final Map<String, String> model = new HashMap<String, String>();
|
||||
// model.put("email", user.getEmail());
|
||||
//// final String activationUrl = "http://wisemapping.com/c/activation?code=" + user.getActivationCode();
|
||||
//// model.put("emailcheck", activationUrl);
|
||||
//// mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), "Welcome to Wisemapping!", model,
|
||||
//// "confirmationMail.vm");
|
||||
// } catch (Exception e) {
|
||||
// handleException(e);
|
||||
// }
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public void setMessageSource(ResourceBundleMessageSource messageSource) {
|
||||
this.messageSource = messageSource;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.service;
|
||||
|
||||
import org.springframework.validation.BindException;
|
||||
|
||||
public class RegistrationException extends BindException {
|
||||
public RegistrationException(Object target, String objectName) {
|
||||
super(target, objectName);
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
package com.wisemapping.service.google;
|
||||
|
||||
public class GoogleAccountBasicData {
|
||||
|
||||
private String email;
|
||||
private String accountId;
|
||||
private String name;
|
||||
private String lastName;
|
||||
private String accessToken;
|
||||
private String refreshToken;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public String getRefreshToken() {
|
||||
return refreshToken;
|
||||
}
|
||||
|
||||
public void setRefreshToken(String refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GoogleAccountBasicData [email=" + email + ", accountId=" + accountId + ", name=" + name + ", lastName="
|
||||
+ lastName + ", accessToken=" + accessToken + ", refreshToken=" + refreshToken + "]";
|
||||
}
|
||||
|
||||
}
|
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.service.google;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.wisemapping.service.google.http.HttpInvoker;
|
||||
import com.wisemapping.service.google.http.HttpInvokerContentType;
|
||||
import com.wisemapping.service.google.http.HttpInvokerException;
|
||||
|
||||
@Service
|
||||
public class GoogleService {
|
||||
@Autowired
|
||||
private HttpInvoker httpInvoker;
|
||||
@Value("${app.security.oauth2.google.confirmUrl:}")
|
||||
private String optinConfirmUrl;
|
||||
@Value("${app.security.oauth2.google.userinfoUrl:}")
|
||||
private String accountBasicDataUrl;
|
||||
@Value("${app.security.oauth2.google.clientId:}")
|
||||
private String clientId;
|
||||
@Value("${app.security.oauth2.google.clientSecret:}")
|
||||
private String clientSecret;
|
||||
@Value("${app.security.oauth2.google.callbackUrl:}")
|
||||
private String callbackUrl;
|
||||
|
||||
public void setHttpInvoker(HttpInvoker httpInvoker) {
|
||||
this.httpInvoker = httpInvoker;
|
||||
}
|
||||
|
||||
public void setOptinConfirmUrl(String optinConfirmUrl) {
|
||||
this.optinConfirmUrl = optinConfirmUrl;
|
||||
}
|
||||
|
||||
public void setAccountBasicDataUrl(String accountBasicDataUrl) {
|
||||
this.accountBasicDataUrl = accountBasicDataUrl;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public void setCallbackUrl(String callbackUrl) {
|
||||
this.callbackUrl = callbackUrl;
|
||||
}
|
||||
|
||||
private String getNodeAsString(JsonNode node, String fieldName) {
|
||||
return getNodeAsString(node, fieldName, null);
|
||||
}
|
||||
|
||||
private String getNodeAsString(JsonNode node, String fieldName, String defaultValue) {
|
||||
JsonNode subNode = node.get(fieldName);
|
||||
return subNode != null ? subNode.asText() : defaultValue;
|
||||
}
|
||||
|
||||
private Map<String, String> getHeaders(String token) {
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("Content-type", "application/json");
|
||||
headers.put("Authorization", "Bearer " + token);
|
||||
return headers;
|
||||
}
|
||||
|
||||
private GoogleAccountBasicData getAccountBasicData(String token) throws HttpInvokerException {
|
||||
JsonNode response = httpInvoker.invoke(accountBasicDataUrl, null, HttpMethod.GET, this.getHeaders(token), null,
|
||||
null);
|
||||
GoogleAccountBasicData data = new GoogleAccountBasicData();
|
||||
data.setEmail(getNodeAsString(response, "email"));
|
||||
data.setAccountId(getNodeAsString(response, "id"));
|
||||
data.setName(getNodeAsString(response, "given_name", data.getEmail()));
|
||||
data.setLastName(getNodeAsString(response, "family_name"));
|
||||
return data;
|
||||
}
|
||||
|
||||
private Map<String, String> getOptinConfirmBody(String code) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("client_id", clientId);
|
||||
result.put("client_secret", clientSecret);
|
||||
result.put("code", code);
|
||||
result.put("redirect_uri", callbackUrl);
|
||||
result.put("grant_type", "authorization_code");
|
||||
return result;
|
||||
}
|
||||
|
||||
public GoogleAccountBasicData processCallback(final String code)
|
||||
throws HttpInvokerException {
|
||||
|
||||
final Map<String, String> body = this.getOptinConfirmBody(code);
|
||||
final JsonNode optionConfirmResponse = httpInvoker.invoke(
|
||||
optinConfirmUrl,
|
||||
HttpInvokerContentType.FORM_ENCODED,
|
||||
HttpMethod.POST,
|
||||
null,
|
||||
null,
|
||||
body);
|
||||
|
||||
final String accessToken = getNodeAsString(optionConfirmResponse, "access_token");
|
||||
final String refreshToken = getNodeAsString(optionConfirmResponse, "refresh_token");
|
||||
|
||||
final GoogleAccountBasicData data = this.getAccountBasicData(accessToken);
|
||||
data.setAccessToken(accessToken);
|
||||
data.setRefreshToken(refreshToken);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.service.google.http;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Service
|
||||
public class HttpInvoker {
|
||||
|
||||
protected static Logger logger = LogManager.getLogger(HttpInvoker.class);
|
||||
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
public HttpInvoker() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JsonNode invoke(
|
||||
@NotNull String url,
|
||||
HttpInvokerContentType requestContentType,
|
||||
HttpMethod method,
|
||||
Map<String, String> headers,
|
||||
String jsonPayload,
|
||||
Map<String, String> formData)
|
||||
throws HttpInvokerException {
|
||||
String responseBody = null;
|
||||
try {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("finalUrl: " + url);
|
||||
logger.debug("method: " + method);
|
||||
logger.debug("payload: " + jsonPayload);
|
||||
logger.debug("header: " + headers);
|
||||
}
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpRequestBase httpRequest;
|
||||
|
||||
// build request
|
||||
if (method.equals(HttpMethod.POST))
|
||||
httpRequest = new HttpPost(url);
|
||||
else if (method.equals(HttpMethod.PUT))
|
||||
httpRequest = new HttpPut(url);
|
||||
else if (method.equals(HttpMethod.GET))
|
||||
httpRequest = new HttpGet(url);
|
||||
else if (method.equals(HttpMethod.DELETE))
|
||||
httpRequest = new HttpDelete(url);
|
||||
else
|
||||
throw new HttpInvokerException("Method " + method + " not supported by http connector");
|
||||
|
||||
if (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT)) {
|
||||
HttpEntity entity = null;
|
||||
if (requestContentType.equals(HttpInvokerContentType.JSON)) {
|
||||
if (jsonPayload == null)
|
||||
throw new HttpInvokerException("Json content is required");
|
||||
entity = new StringEntity(jsonPayload, StandardCharsets.UTF_8);
|
||||
((HttpEntityEnclosingRequestBase) httpRequest).setEntity(entity);
|
||||
}
|
||||
if (requestContentType.equals(HttpInvokerContentType.FORM_ENCODED)) {
|
||||
List<NameValuePair> nameValuePairs = new ArrayList<>();
|
||||
Set<String> keys = formData.keySet();
|
||||
for (String key : keys) {
|
||||
nameValuePairs.add(new BasicNameValuePair(key, formData.get(key).toString()));
|
||||
}
|
||||
entity = new UrlEncodedFormEntity(nameValuePairs);
|
||||
((HttpEntityEnclosingRequestBase) httpRequest).setEntity(entity);
|
||||
}
|
||||
if (entity == null)
|
||||
throw new HttpInvokerException("Cant build entity to send");
|
||||
}
|
||||
|
||||
if (headers != null) {
|
||||
Set<String> keys = headers.keySet();
|
||||
for (String key : keys) {
|
||||
httpRequest.setHeader(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
if (requestContentType != null)
|
||||
httpRequest.setHeader("Content-Type", requestContentType.getHttpContentType());
|
||||
|
||||
// invoke
|
||||
CloseableHttpResponse response = httpClient.execute(httpRequest);
|
||||
// response process
|
||||
JsonNode root = null;
|
||||
responseBody = response.getEntity() != null && response.getEntity().getContent() != null
|
||||
? IOUtils.toString(response.getEntity().getContent(), (String) null)
|
||||
: null;
|
||||
if (responseBody != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("response plain: " + responseBody);
|
||||
}
|
||||
try {
|
||||
root = mapper.readTree(responseBody);
|
||||
} catch (Exception e) {
|
||||
int returnCode = response.getStatusLine().getStatusCode();
|
||||
throw new HttpInvokerException("cant transform response to JSON. RQ: " + jsonPayload + ", RS: "
|
||||
+ responseBody + ", status: " + returnCode, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (response.getStatusLine().getStatusCode() >= 400) {
|
||||
logger.error("error response: " + responseBody);
|
||||
throw new HttpInvokerException("error invoking " + url + ", response: " + responseBody + ", status: "
|
||||
+ response.getStatusLine().getStatusCode(), HttpStatus.SC_BAD_REQUEST);
|
||||
}
|
||||
|
||||
httpRequest.releaseConnection();
|
||||
response.close();
|
||||
httpClient.close();
|
||||
|
||||
return root;
|
||||
} catch (HttpInvokerException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("cant invoke service " + url);
|
||||
logger.error("response: " + responseBody, e);
|
||||
throw new HttpInvokerException("cant invoke service " + url, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package com.wisemapping.service.google.http;
|
||||
|
||||
public enum HttpInvokerContentType {
|
||||
|
||||
JSON("application/json"),
|
||||
FORM_ENCODED("application/x-www-form-urlencoded");
|
||||
|
||||
private String httpContentType;
|
||||
|
||||
HttpInvokerContentType(String type) {
|
||||
this.httpContentType = type;
|
||||
}
|
||||
|
||||
public String getHttpContentType() {
|
||||
return httpContentType;
|
||||
}
|
||||
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.service.google.http;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
public class HttpInvokerException extends Exception {
|
||||
private final int statusCode;
|
||||
|
||||
public HttpInvokerException(String message) {
|
||||
this(message, HttpStatus.SC_INTERNAL_SERVER_ERROR, null);
|
||||
}
|
||||
|
||||
public HttpInvokerException(String message, int statusCode) {
|
||||
this(message, statusCode, null);
|
||||
}
|
||||
public HttpInvokerException(String message, Throwable cause) {
|
||||
this(message, HttpStatus.SC_INTERNAL_SERVER_ERROR, cause);
|
||||
}
|
||||
|
||||
public HttpInvokerException(String message, int statusCode, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.util;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
final public class TimeUtils
|
||||
{
|
||||
private static final SimpleDateFormat sdf;
|
||||
static {
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public static String toISO8601(@Nullable Date date) {
|
||||
String result = "";
|
||||
if (date != null) {
|
||||
result = sdf.format(date) + "Z";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -1 +0,0 @@
|
||||
# Solves error Can't find bundle for base name jakarta.xml.bind.Messages, locale en_US
|
@@ -1,116 +0,0 @@
|
||||
#
|
||||
# This file contains all the defaults that it will be used when the application is started.
|
||||
# There are two main sections: SpringBoot Config and Application Config
|
||||
#
|
||||
|
||||
#
|
||||
# SpringBoot Config: WiseMapping Backend is based on SpringBoot. Additional configurations documentation could be found https://docs.spring.io/spring-boot/3.3/reference/features/external-config.html.
|
||||
#
|
||||
spring:
|
||||
# SMTP server configuration used for password recovery and notifications.
|
||||
mail:
|
||||
host: smtp.example.com
|
||||
port: 25
|
||||
username: setusername
|
||||
password: setpassword
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
connectiontimeout: 5000
|
||||
timeout: 3000
|
||||
writetimeout: 5000
|
||||
# Database configuration options. Examples can be found: https://github.com/wisemapping/wisemapping-open-source/tree/develop/config/database
|
||||
datasource:
|
||||
url: jdbc:hsqldb:mem:wisemapping
|
||||
driver-class-name: org.hsqldb.jdbc.JDBCDriver
|
||||
password: ''
|
||||
username: sa
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: none
|
||||
open-in-view: true
|
||||
properties:
|
||||
hibernate:
|
||||
current_session_context_class: thread
|
||||
default_batch_fetch_size: 200
|
||||
dialect: org.hibernate.dialect.HSQLDialect
|
||||
format_sql: true
|
||||
sql:
|
||||
init:
|
||||
mode: always
|
||||
platform: hsqldb
|
||||
# General Config: Do no touch.
|
||||
main:
|
||||
allow-circular-references: true
|
||||
output:
|
||||
ansi:
|
||||
enabled: always
|
||||
application:
|
||||
name: wisemapping-api
|
||||
title: wisemapping-api
|
||||
|
||||
|
||||
#
|
||||
# Log Level
|
||||
#
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
apache:
|
||||
tomcat: INFO
|
||||
root: INFO
|
||||
|
||||
#
|
||||
# Application Config related options:
|
||||
#
|
||||
app:
|
||||
# This information is mainly used by the frontend to connect to the backend. It must match the deployment topology used.
|
||||
site:
|
||||
ui-base-url: http://localhost
|
||||
api-base-url: http://localhost
|
||||
# Enable API basic authentication.
|
||||
api:
|
||||
http-basic-enabled: false
|
||||
# JSON Web Token configuration options. Secret must be configured.
|
||||
jwt:
|
||||
secret: dlqxKAg685SaKhsQXIMeM=JWCw3bkl3Ei3Tb7LMlnd19oMd66burPNlJ0Po1qguyjgpakQTk2CN3
|
||||
expirationMin: 10080 # One week
|
||||
# Admin account with super admin permissions on the API.
|
||||
admin:
|
||||
user: admin@wisemapping.org
|
||||
# STMP email configurations
|
||||
mail:
|
||||
sender-email: root@localhost
|
||||
support-email: root@localhost
|
||||
enabled: false
|
||||
accounts:
|
||||
max-inactive: 20
|
||||
# Google OAuth Authentication
|
||||
security:
|
||||
# corsAllowedOrigins: https://dev.wisemapping.com
|
||||
oauth2:
|
||||
google:
|
||||
clientSecret: <google-oath>
|
||||
confirmUrl: https://oauth2.googleapis.com/token
|
||||
userinfoUrl: https://www:googleapis.com/oauth2/v3/userinfo
|
||||
callbackUrl: https://app.wisemapping.com/c/registration-google
|
||||
clientId: 625682766634-cocbbbbb403iuvps1evecdk6d7phvbkf.apps.googleusercontent.com
|
||||
url: https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=${app.security.oauth2.google.callbackUrl}&prompt=consent&response_type=code&client_id=${app.security.oauth2.google.clientId}&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&access_type=offline&state=wisemapping&include_granted_scopes=true
|
||||
# accounts:
|
||||
# exclusion:
|
||||
# domain:
|
||||
# Account registration options dialog
|
||||
registration:
|
||||
enabled: true
|
||||
captcha:
|
||||
enabled: false
|
||||
siteKey: some-key
|
||||
secretKey: some-secret
|
||||
|
||||
|
||||
# Behind reverse proxy configuration
|
||||
server:
|
||||
tomcat:
|
||||
remote-ip-header: x-forwarded-for
|
||||
protocol-header: x-forwarded-proto
|
||||
|
@@ -1,6 +0,0 @@
|
||||
| | |' |\ /| ' /\ |~~\~|~
|
||||
| | ||(~/~/| \/ |/~~||~~\|~~\||/~\ /~~| /__\ |__/ |
|
||||
\/ \/ |_)\/_| |\__||__/|__/|| |\__| / \| _|_
|
||||
| | \__|
|
||||
${application.title} ${application.version}
|
||||
Powered by Spring Boot ${spring-boot.version}
|
@@ -1 +0,0 @@
|
||||
SET DATABASE SQL SYNTAX MYS TRUE;
|
@@ -1 +0,0 @@
|
||||
INSERT IGNORE INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
|
@@ -1,15 +0,0 @@
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO ACCOUNT (collaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE, 1,'D')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO ACCOUNT (collaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE, 1,'D')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
@@ -1,29 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<h3>Welcome to WiseMapping!</h3>
|
||||
|
||||
<p>
|
||||
To active your account and verify your e-mail address, please click on the following link.
|
||||
</p>
|
||||
<a href="${emailcheck}">${emailcheck}</a>
|
||||
</p>
|
||||
<p>
|
||||
If you have received this mail by error, you do not need to take any action to cancel the account. The account will
|
||||
not be activated, and you will not receive any further emails.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If clicking the link above does not work, copy and paste the URL in a new browser window instead.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For questions or concerns regarding your account, send us an email to support@wisemapping.com.
|
||||
</p>
|
||||
|
||||
<p style="color: #898989;">
|
||||
<a href="https://www.wisemapping.com/">The WiseMapping Team</a><br/>
|
||||
</p>
|
||||
<div>
|
||||
</body>
|
||||
</html>
|
@@ -1,73 +0,0 @@
|
||||
# Default German Support.
|
||||
DESCRIPTION=Beschreibung
|
||||
SITE.TITLE=WiseMapping
|
||||
FIELD_REQUIRED=Ein benötigtes Feld kann nicht leer gelassen werden
|
||||
EMAIL_ALREADY_EXIST=Die E-Mail-Adresse existiert bereits.
|
||||
NO_VALID_EMAIL_ADDRESS=Ungültige E-Mail-Adresse
|
||||
CREATOR=Urheber
|
||||
WELCOME=Willkommen
|
||||
SHARE=Veröffentlichen
|
||||
UNEXPECTED_ERROR=Ein unerwarteter Fehler ist aufgetreten.
|
||||
MAP_TITLE_ALREADY_EXISTS=Du hast bereits eine Mindmap mit demselben Namen
|
||||
LABEL_TITLE_ALREADY_EXISTS=Du hast bereits ein Label mit demselben Namen
|
||||
TUTORIAL.MULTIPLE_TEXT_STYLES=Mehrfache Textstile
|
||||
TUTORIAL.DIFFERENT_SHAPES=Verschiedene Formen
|
||||
TUTORIAL.FANCY_ICONS=Ausgefallene Symbole
|
||||
TUTORIAL.MOVE_WITH_ARROWS=Mit Pfeiltasten zwischen Themen wechseln
|
||||
TUTORIAL.START_TYPING_TO_EDIT_TEXT=Einfach mit dem tippen beginnen, um Text zu bearbeiten
|
||||
TUTORIAL.CTRL_TO_ADD_CHILD=Dröcke Strg/Meta+Enter um ein Unterthema einzufögen
|
||||
TUTORIAL.ENTER_TO_ADD_SIBLING=Drücke Return um ein Schwesterthema einzufögen
|
||||
TUTORIAL.MORE_KEY_TIPS=Mehr? Drücke auf obige Tastenkürzel
|
||||
TUTORIAL.DOUBLE_CLICK_TO_ADD=Doppelklick auf die Arbeitsfläche, um Themen zu erzeugen
|
||||
TUTORIAL.DRAG_AND_DROP_TO_POSITION=Thema per ziehen und fallen lassen positionieren
|
||||
TUTORIAL.DOUBLE_CLICK_TO_EDIT_TEXT=Doppelklick auf ein Thema, um den Text zu bearbeiten
|
||||
TUTORIAL.ADD_NOTES=Füge Notizen hinzu
|
||||
TUTORIAL.USER_THE_TOOLBAR=Benutze die Werkzeugleiste
|
||||
TUTORIAL.PUBLISH_YOUR_MAPS=Veröffentliche deine Mindmap
|
||||
TUTORIAL.EMBED_IN_BLOGS=In Blog einbinden
|
||||
TUTORIAL.INVITE_FRIEND=Freunde zur Zusammenarbeit einladen
|
||||
TUTORIAL.SHARING=Mitbenutzung
|
||||
TUTORIAL.EDITION_USING_MOUSE=Bearbeiten mit der Maus
|
||||
TUTORIAL.EDITION_USING_KEYBOARD=Bearbeiten mit der Tastatur
|
||||
TUTORIAL.ADD_LINKS_WEBPAGES=Verknüpfungen zu Internetseiten hinzufögen
|
||||
TUTORIAL.TOPIC_PROPERTIES=Themen Eigenschaften
|
||||
TUTORIAL.HOW_TO_START=Wie fange ich an?
|
||||
TUTORIAL.FONT_COLOR=Farbe
|
||||
TUTORIAL.FONT_STYLE=Stil
|
||||
TUTORIAL.FONT_TYPE=Typ
|
||||
TUTORIAL.SAMPLE_NOTE=Das ist eine einfache Notiz \!.
|
||||
CAPTCHA_LOADING_ERROR=ReCaptcha konnte nicht geladen werden. Du musst Zugriff auf den Google ReCaptcha Dienst haben.
|
||||
ACCESS_HAS_BEEN_REVOKED=Deine Zugriffsrechte auf diese Mindmap sind zuröckgesetzt worden. Bitte kontaktiere den Besitzer dieser Mindmap.
|
||||
MAP_CAN_NOT_BE_FOUND=Die Mindmap kann nicht gefunden werden. Sie muss gelöscht worden sein.
|
||||
LABEL_CAN_NOT_BE_FOUND=Das Label kann nicht gefunden werden. Es muss gelöscht worden sein.
|
||||
MINDMAP_TIMESTAMP_OUTDATED=Es ist nicht möglich, deine Änderungen zu speichern, da deine Mindmap von {0} geändert wurde. Aktualisiere die Seite und versuche es erneut.
|
||||
MINDMAP_LOCKED=Mindmap wird bearbeitet von {0} <{1}>. Die Mindmap wird im schreibgeschützten Modus geöffnet.
|
||||
MINDMAP_IS_LOCKED=Mindmap ist für die Bearbeitung gesperrt.
|
||||
# Confirmed
|
||||
RESET_PASSWORD_INVALID_EMAIL=Die angegebene E-Mail-Adresse ist kein gültiges Benutzerkonto. Bitte versuche es erneut mit einer gültigen E-Mail-Adresse.
|
||||
TRY_WELCOME=Dieser Ausgabebereich zeigt einige der Mindmap-Editor-Funktionen \!.
|
||||
UNEXPECTED_ERROR_DETAILS=Unerwarteter Fehler bei der Verarbeitung der Anforderung.
|
||||
NO_ENOUGH_PERMISSIONS=Diese Mindmap ist nicht mehr verfögbar.
|
||||
NO_ENOUGH_PERMISSIONS_DETAILS=Du hast nicht die erforderlichen Rechte, um dir diese Mindmap anzusehen. Diese Mindmap ist entweder privat oder wurde gelöscht.
|
||||
REGISTRATION.EMAIL_SUBJECT=Willkommen bei WiseMapping!
|
||||
REGISTRATION.EMAIL_TITLE=Dein Konto wurde erfolgreich erstellt
|
||||
REGISTRATION.EMAIL_BODY=<p>Vielen Dank för dein Interesse an WiseMapping. Klicke <a href='https://app.wisemapping.com/c/login'>hier</a>, um mit dem Erstellen und Teilen neuer Mindmaps zu beginnen. Wenn du eine Rückmeldung oder Ideen hast, sende uns eine E-Mail an <a href=\"mailto:feedback@wisemapping.com\">feedback@wisemapping.com</a>. Wir würden uns freuen, von dir zu hören.</p >
|
||||
CHANGE_PASSWORD.EMAIL_SUBJECT=Dein Passwort wurde zurückgesetzt
|
||||
CHANGE_PASSWORD.EMAIL_TITLE=Ein temporäres Passwort wurde generiert
|
||||
CHANGE_PASSWORD.EMAIL_BODY=<p>Jemand, höchstwahrscheinlich du selbst, hat ein neues Passwort für dein WiseMapping-Konto angefordert. </p><p><strong>Hier ist dein neues Passwort: {0} </strong></p><p>Du kannst dich anmelden, indem du <a href="{1}/c/login">hier klickst</a>. Wir empfehlen dir dringend, das Passwort so schnell wie möglich zu ändern.</p>
|
||||
PASSWORD_CHANGED.EMAIL_SUBJECT=Dein Passwort wurde geändert
|
||||
PASSWORD_CHANGED.EMAIL_TITLE=Dein Passwort wurde erfolgreich geändert
|
||||
PASSWORD_CHANGED.EMAIL_BODY=<p>Dies ist nur eine Benachrichtigung, dass dein Passwort geändert wurde. Es sind keine weiteren Maßnahmen erforderlich.</p>
|
||||
CAPTCHA_TIMEOUT_OUT_DUPLICATE=Bitte aktualisiere die Seite und versuche es erneut.
|
||||
CAPTCHA_INVALID_INPUT_RESPONSE=Antwort ungültig, aktualisiere die Seite und versuche es erneut.
|
||||
MINDMAP_EMPTY_ERROR=Mindmap darf nicht leer sein.
|
||||
INVALID_MINDMAP_FORMAT=Ungültiges Mindmap-Format.
|
||||
TOO_BIG_MINDMAP=Du hast die Grenze von 5000 Themen in einer Mindmap erreicht.
|
||||
SHARE_MAP.EMAIL_SUBJECT={0} hat eine Mindmap mit dir geteilt
|
||||
EMAIL.DO_NOT_REPLAY=Wichtig: Antworte nicht auf diese E-Mail. Wenn du weitere Hilfe benötigst oder Bedenken bezüglich deines Kontos hast, kontaktiere uns <a href="mailto:{0}">hier</a>.
|
||||
EMAIL.GREETINGS=Hallo
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Die Rolle des Besitzers kann nicht geändert werden. Bitte entferne den Besitzer aus der Änderungsliste.
|
||||
ZOOM_TO_FIT=Einpassen
|
||||
ZOOM_OUT=Verkleinern
|
||||
ZOOM_IN=Vergrößern
|
||||
PASSWORD_TOO_LONG=Passwort muss kürzer als 40 Zeichen sein.
|
@@ -1,72 +0,0 @@
|
||||
# Default English Support.
|
||||
DESCRIPTION=Description
|
||||
SITE.TITLE=WiseMapping
|
||||
FIELD_REQUIRED=Required field cannot be left blank
|
||||
EMAIL_ALREADY_EXIST=There is an account already with this email.
|
||||
NO_VALID_EMAIL_ADDRESS=Invalid email address
|
||||
INVALID_EMAIL_ADDRESS=Invalid email address. Please, verify that your entered valid email address.
|
||||
CREATOR=Creator
|
||||
WELCOME=Welcome
|
||||
SHARE=Share
|
||||
MAP_TITLE_ALREADY_EXISTS=You have already a map with the same name
|
||||
LABEL_TITLE_ALREADY_EXISTS=You have already a label with the same name
|
||||
TUTORIAL.MULTIPLE_TEXT_STYLES=Multiple Text Styles
|
||||
TUTORIAL.DIFFERENT_SHAPES=Different Shapes
|
||||
TUTORIAL.FANCY_ICONS=Fancy Icons
|
||||
TUTORIAL.MOVE_WITH_ARROWS=Move Between Topics With The Arrows
|
||||
TUTORIAL.START_TYPING_TO_EDIT_TEXT=Start Typing to Edit Text
|
||||
TUTORIAL.CTRL_TO_ADD_CHILD=Press Ctrl/Meta+Enter to Add Child Topic
|
||||
TUTORIAL.ENTER_TO_ADD_SIBLING=Press Enter to Add a Sibling Topic
|
||||
TUTORIAL.MORE_KEY_TIPS=More ?. Click on shortcuts above
|
||||
TUTORIAL.DOUBLE_CLICK_TO_ADD=Double Click on the Canvas to Create Topics
|
||||
TUTORIAL.DRAG_AND_DROP_TO_POSITION=Drag and Drop Topics Position
|
||||
TUTORIAL.DOUBLE_CLICK_TO_EDIT_TEXT=Double Click on a Topic to Edit the Text
|
||||
TUTORIAL.ADD_NOTES=Add Notes
|
||||
TUTORIAL.USER_THE_TOOLBAR=Use the Toolbar
|
||||
TUTORIAL.PUBLISH_YOUR_MAPS=Publish your Mind map
|
||||
TUTORIAL.EMBED_IN_BLOGS=Embed in Blogs
|
||||
TUTORIAL.INVITE_FRIEND=Invite Friends to Collaborate
|
||||
TUTORIAL.SHARING=Sharing
|
||||
TUTORIAL.EDITION_USING_MOUSE=Edition Using Mouse
|
||||
TUTORIAL.EDITION_USING_KEYBOARD=Edition Using Keyboard
|
||||
TUTORIAL.ADD_LINKS_WEBPAGES=Add Links to Web Pages
|
||||
TUTORIAL.TOPIC_PROPERTIES=Topics Properties
|
||||
TUTORIAL.HOW_TO_START=How to Start ?
|
||||
TUTORIAL.FONT_COLOR=Color
|
||||
TUTORIAL.FONT_STYLE=Styles
|
||||
TUTORIAL.FONT_TYPE=Type
|
||||
TUTORIAL.SAMPLE_NOTE=This is a simple note \!.
|
||||
CAPTCHA_LOADING_ERROR=ReCaptcha could not be loaded. You must have access to Google ReCaptcha service.
|
||||
ACCESS_HAS_BEEN_REVOKED=Your access permissions to this map has been revoked. Contact map owner.
|
||||
MAP_CAN_NOT_BE_FOUND=The map can not be found. It must have been deleted.
|
||||
LABEL_CAN_NOT_BE_FOUND=The label can not be found. It must have been deleted.
|
||||
MINDMAP_TIMESTAMP_OUTDATED=It's not possible to save your changes because your mind map has been modified by ''{0}''. Refresh the page and try again.
|
||||
MINDMAP_LOCKED=Map is being edited by {0} <{1}>. Map is opened in read only mode.
|
||||
MINDMAP_IS_LOCKED=Min map is locked for edition.
|
||||
# Confirmed
|
||||
RESET_PASSWORD_INVALID_EMAIL=The email provided is not a valid user account. Please, try again with a valid email.
|
||||
TRY_WELCOME=This edition space showcases some of the mind map editor capabilities \!.
|
||||
NO_ENOUGH_PERMISSIONS=This mind map cannot be opened.
|
||||
CAPTCHA_TIMEOUT_OUT_DUPLICATE=Please, refresh the page and try again.
|
||||
CAPTCHA_INVALID_INPUT_RESPONSE=Invalid input response, refresh the page and try again.
|
||||
MINDMAP_EMPTY_ERROR=Mind map can not be empty.
|
||||
INVALID_MINDMAP_FORMAT=Invalid mind map format.
|
||||
TOO_BIG_MINDMAP=You have reached the limit of 5000 topics in a mind map.
|
||||
REGISTRATION.EMAIL_SUBJECT=Welcome to WiseMapping !
|
||||
REGISTRATION.EMAIL_TITLE=Your account has been created successfully
|
||||
REGISTRATION.EMAIL_BODY=<p> Thank you for your interest in WiseMapping. Click <a href='https://app.wisemapping.com/c/login'>here</a> to start creating and sharing new mind maps. If have any feedback or idea, send us an email to <a href=\"mailto:feedback@wisemapping.com\">feedback@wisemapping.com</a> .We'd love to hear from you.</p>
|
||||
CHANGE_PASSWORD.EMAIL_SUBJECT=Your password has been reset
|
||||
CHANGE_PASSWORD.EMAIL_TITLE=A temporal password has been generated
|
||||
CHANGE_PASSWORD.EMAIL_BODY=<p>Someone, most likely you, requested a new password for your WiseMapping account. </p><p><strong>Here is your new password: {0} </strong></p><p>You can login clicking <a href="{1}/c/login">here</a>. We strongly encourage you to change the password as soon as possible.</p>
|
||||
PASSWORD_CHANGED.EMAIL_SUBJECT=Your password has been changed
|
||||
PASSWORD_CHANGED.EMAIL_TITLE=Your password has been changed successfully
|
||||
PASSWORD_CHANGED.EMAIL_BODY=<p>This is only an notification that your password has been changed. No further action is required.</p>
|
||||
SHARE_MAP.EMAIL_SUBJECT={0} has shared a mind map with you
|
||||
EMAIL.DO_NOT_REPLAY=Important: Do not reply this email. If you need further help or have any concerns regarding your account, contact us to <a href="mailto:{0}">here</a>.
|
||||
EMAIL.GREETINGS=Hi
|
||||
TOO_MANY_INACTIVE_ACCOUNTS=You have shared your mindmaps to more than 20 user that have not registered yet. Please, remove inactive accounts or ask them to register.
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Owner role can not be change. Please, remove owner from the change list.
|
||||
ZOOM_TO_FIT=Zoom to fit
|
||||
ZOOM_OUT=Zoom out
|
||||
ZOOM_IN=Zoom in
|
||||
PASSWORD_TOO_LONG=Password must be less than 40 characters.
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user