spring boot files
This commit is contained in:
commit
0c2ac849f2
|
@ -0,0 +1,4 @@
|
|||
FROM openjdk:8-jdk-alpine
|
||||
ADD target/springbootapp-0.0.1-SNAPSHOT.jar app.jar
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
|
|
@ -0,0 +1,224 @@
|
|||
# Developer Documentation - Spiri Simulator Backend
|
||||
|
||||
|
||||
**Steps to install and access Backend server APIs:**
|
||||
|
||||
- System - Ubuntu 18.04
|
||||
- Install maven and Java- 11 to your Ubuntu machine
|
||||
- sudo apt update
|
||||
- sudo apt install maven
|
||||
- sudo apt install default-jdk
|
||||
|
||||
|
||||
|
||||
**Install mysql- 5.7 (https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04)**
|
||||
- $ sudo apt update
|
||||
- $ sudo apt install mysql-server
|
||||
- $ Configuring mysql
|
||||
- $ sudo mysql_secure_installation
|
||||
- Note: Set password plugin- Initially set it to ‘yes’ and level ‘0’ for validation policy
|
||||
- Adjusting User Authentication and Privileges
|
||||
|
||||
|
||||
|
||||
**Add scripts to mysql server**
|
||||
- Run below command to add scripts from (cloned**) backend folder into in installed my sql server
|
||||
- mysql -u username -p database_name < file.sql
|
||||
**Scripts are in the db table :https://gitlab.pleiadesrobotics.com/web-services/backend/-/tree/feature_base_code/db
|
||||
- Install Eclipse
|
||||
Download Eclipse from https://www.eclipse.org/downloads/
|
||||
- Setup eclipse with tar xfz ~/Downloads/eclipse-inst-linux64.tar.gz ~/Downloads/eclipse-installer/eclipse-inst
|
||||
- Setup eclipse for lombok getter & setter
|
||||
- Copy lombok-1.18.6.jar from ../.m2/repository/org/projectlombok/lombok/1.18.6 to eclipse root folder(where eclipse.ini file is)
|
||||
- cd <'eclipse root directory'>
|
||||
- java -jar lombok-1.18.6.jar install ~/eclipse/jee-2020-03/eclipse/
|
||||
- java -jar lombok.jar install ~/eclipse/jee-2020-03/eclipse/
|
||||
|
||||
#### Or
|
||||
|
||||
- cd <'eclipse root directory'>
|
||||
- java -jar eclipse/lombok-1.18.6.jar
|
||||
- install ~/Downloads/eclipse-java-2020-03-R-linux-gtk-x86_64/eclipse/
|
||||
- Restart eclipse and build again the project
|
||||
|
||||
**Build & Run - Backend:**
|
||||
- git clone git@gitlab.pleiadesrobotics.com:web-services/backend.git
|
||||
- Update ~/backend/src/main/resources/application.yml with mysql password set
|
||||
- cd backend
|
||||
- mvn clean install
|
||||
- mvn spring-boot:run
|
||||
- Open localhost:8080/task/list/ to test everything runs OK. It will run the backend server at port 8080 default.
|
||||
|
||||
**Understanding Backend Codebase:**
|
||||
|
||||
***src/main/java***
|
||||
|
||||
###### com.example.springbootapp
|
||||
- This is the main class to run your complete application.
|
||||
|
||||
###### Com.example.springbootapp.config
|
||||
- Configuration files for adding the security
|
||||
|
||||
###### Com.example.springbootapp.controllers
|
||||
- Once you want a new microservice add this to the package and create new class with the tag “Get
|
||||
mapping” so basically on the hit to the URL the page is redirected as per the functionality written here.
|
||||
Usually after a hit it opens up the specific implementation written in the package relevant to the
|
||||
specific class in “com.example.springbootapp.services”.
|
||||
|
||||
###### com.example.springbootapp.model
|
||||
- POJO (Plain OLd Java Objects) for all the functionality are added here these are basic getter and setter methods that you require.
|
||||
|
||||
###### Com.example.springbootapp.repository
|
||||
- Here interfaces are defined which are extending JPA(database connection to your db) then these
|
||||
|
||||
###### com.example.springbootapp.schedulers
|
||||
- service to stop the container spawned using AWS when not being used.
|
||||
|
||||
|
||||
###### com.example.springbootapp.services
|
||||
- This usually has an interface and an implementation of that interface which is for having the best
|
||||
practise of loose coupling. So for example
|
||||
|
||||
CompetitionService.java is the interface and CompetitionServiceImpl.java is the class. So all the
|
||||
methods that are defined in the interface are implemented in this service implementation.
|
||||
/backend/src/main/java/com/example/springbootapp/services/CompetitionService.java
|
||||
/backend/src/main/java/com/example/springbootapp/services/CompetitionServiceImpl.java
|
||||
|
||||
|
||||
#### src/main/resources
|
||||
- Here the application yml files and the properties file is kept
|
||||
You can add the following things for example :
|
||||
Set the mysql db
|
||||
Set the okta Oauth 2 authentication etc
|
||||
Example :- https://gitlab.spirirobotics.com/web-services/backend/-/blob/feature_base_code/src/main/resources/application.yml
|
||||
|
||||
|
||||
#### src/test/java
|
||||
- Use Junit or Mockito to add your unit test cases
|
||||
Junit : https://junit.org/junit5/
|
||||
Mockito: https://site.mockito.org/
|
||||
|
||||
|
||||
**APIs details:**
|
||||
- To CRUD applications (Competitions)
|
||||
https://developer.okta.com/docs/reference/api/apps/
|
||||
|
||||
- To CRUD groups (Teams)
|
||||
https://developer.okta.com/docs/reference/api/groups/
|
||||
|
||||
- To CRUD users
|
||||
https://developer.okta.com/docs/reference/api/users/
|
||||
|
||||
- To get a user Id from our backend abstracted user API
|
||||
[/api/user](url)
|
||||
|
||||
This Api returns current okta session user object from where you can retrieve userId from "sub"
|
||||
|
||||
{"at_hash":"cBwzHrq22cIYxBd1g3851g","sub":"00u21ycq02wVcoFxT357","zoneinfo":"America/Los_Angeles","ver":1,"email_verified":true,"amr":["pwd"],"iss":"https://dev-125890.okta.com/oauth2/default","preferred_username":"raga.amber@gmail.com","locale":"en-US","given_name":"Raghav","aud":["0oa21yqmlw0cI8weJ357"],"updated_at":1576023483,"idp":"00o21ycpwwDPVJJEi357","auth_time":1576967436,"name":"Raghav Sharma","exp":"2019-12-21T23:56:24Z","family_name":"Sharma","iat":"2019-12-21T22:56:24Z","email":"raga.amber@gmail.com","jti":"ID.LCHoKAbPBXVCs0LjnXY2v54q9wnUMQZXBW5o0poI8GQ"}
|
||||
|
||||
- To log out current user (Post)
|
||||
[/api/logout](url) Pass idToken to be timed out, this api will call okta to make token invalid.
|
||||
|
||||
- To get competition progress (Get)
|
||||
[/competition/progress/{user_id}/{comp_id}](url)
|
||||
This will return you all tasks. Construct your task list using this response.
|
||||
|
||||
- To create a simulator (Get) (TODO: Change it to post call)
|
||||
[/simulator/start/{user_id}/{name}/{pwd}](url) where user_id is student okta id, name is given_name, pwd is any constant.
|
||||
This API returns 'publicIp' which is a Fargate container IP to access newly created simulator and shell.
|
||||
|
||||
- To update task (Get) (TODO: Change it to post call)
|
||||
[/competition/update/${userId}/${compId}/${taskId}](url)
|
||||
|
||||
- To create/update master data task (Put)
|
||||
[/task/update](url)
|
||||
|
||||
{
|
||||
"user_id":11,"comp_id":13,"task_id":1,"task_name":"Is simulator launched ?","task_progress":"0", "task_action":"Launch Simulator"
|
||||
}
|
||||
|
||||
- To log heart beat to active simulator against student id (Get) (TODO: Change it to post call)
|
||||
[/simulator/logheartbeat/{user_id}](url)
|
||||
|
||||
- To stop/delete active simulator against student id (Get) (TODO: Change it to post call)
|
||||
[/simulator/stop/{user_id}](url)
|
||||
****
|
||||
|
||||
**Behavior flow:**
|
||||
( 'Team <-> Okta Group'
|
||||
'Competition <-> Okta Application(App)')
|
||||
- Create a team in Okta.
|
||||
- Create a user and add it to a team in Okta.
|
||||
- Create a competition and add a team to competition in Okta.
|
||||
- Front end can call any API as dummy API to pop up Okta login page.
|
||||
- Once login passed, get userId from login session directly from Okta.
|
||||
(OR)
|
||||
Use Okta user API /api/v1/users/me
|
||||
(OR)
|
||||
Use abrstacted user api[/api/user] from backend.
|
||||
|
||||
- Get competition details from Okta apps api for the user by using below API:
|
||||
|
||||
{{url}}/api/v1/apps?filter=user.id+eq+"{{userId}}"
|
||||
|
||||
This will get you competitionId(appid)
|
||||
- Now call competition progress API by passing user id and competition id to get competition tasks progress details
|
||||
[/competition/progress/{user_id}/{comp_id}](url)
|
||||
This will return you all tasks details for the competition. Construct your task list using this response.
|
||||
|
||||
- Create a simulator by calling [/simulator/start/{user_id}/{name}/{pwd}](url) and place the returned URI from API to your respective tasks buttons.
|
||||
(Note: This API takes longer time to respond if simulator is getting created first time. Please use enough timeout at frontend.)
|
||||
|
||||
- Call simulator heart beat api periodically from frontend to keep the simulator active [/simulator/logheartbeat/{user_id}](url) which updates the timestamp of the simulator.
|
||||
If heartbeat api is not called, then simulator would be deleted automatically after 1 hr.
|
||||
There is a scheduler runs periodically at backend which checks the timestamp of created simulator and if simulator timestamp is 1 hr old then it makes an assumption that simulator is not in use.
|
||||
|
||||
- Stop/Delete simulator: To stop/delete simulator, use this api [/simulator/stop/{user_id}](url)
|
||||
|
||||
|
||||
## Understand Cloud
|
||||
|
||||
- Credentials :
|
||||
- SHELLINABOX_PASSWORD spiri-friend2019@
|
||||
- SHELLINABOX_USER Raghav
|
||||
- Gazebo http://3.235.54.48:8080/
|
||||
- Shell terminal http://3.235.54.48:4200/
|
||||
- Once you are inside the shell using the above credentials then you just need to run the following command to spawn a gazebo instance :
|
||||
|
||||
### AWS Fargate :
|
||||
|
||||
- ECR technology to deploy serevr less docker containers
|
||||
- https://aws.amazon.com/fargate/
|
||||
- Ask your network adimintrator at Spiri to give you the credentials and create a I AM USER account for you to do backend testing.
|
||||
|
||||
|
||||
## Install Postman(For checking backend APIs)
|
||||
|
||||
- https://developer.okta.com/code/rest/
|
||||
After you set all the global variables here then hit the following URL :
|
||||
{{url}}/api/v1/users?limit=25
|
||||
Output :
|
||||
{
|
||||
"id": "00u21ycq02wVcoFxT357",
|
||||
"status": "ACTIVE",
|
||||
"created": "2019-11-30T01:42:45.000Z",
|
||||
"activated": null,
|
||||
"statusChanged": "2019-11-30T01:44:07.000Z",
|
||||
"lastLogin": "2020-05-19T16:35:09.000Z",
|
||||
"lastUpdated": "2019-11-30T01:44:08.000Z",
|
||||
"passwordChanged": "2019-11-30T01:44:07.000Z",
|
||||
"type": {
|
||||
"id": "oty21ycpxjH4TjHD1357"
|
||||
|
||||
## Redirect from backend :
|
||||
- HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Location", "localhost:3000/");
|
||||
return new ResponseEntity(headers, HttpStatus.FOUND);
|
||||
|
||||
|
||||
## Important articles and developer documentations :
|
||||
|
||||
- https://docs.google.com/document/d/1fABunlJQTq6DFNJTzCgDcGphiXBCHzwtk5RZju8drmk/edit?usp=sharing (If you cannot access this link then ask Patrick to add you to it)
|
||||
- https://developer.okta.com/blog/2020/03/27/spring-oidc-logout-options
|
||||
- https://developer.okta.com/code/rest/
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
-- MySQL dump 10.13 Distrib 8.0.17, for macos10.14 (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: playground
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 8.0.18
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `student_simulator`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `student_simulator`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `student_simulator` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`student_id` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`task_arn` varchar(512) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`status` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`time_stamp` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `student_simulator`
|
||||
--
|
||||
|
||||
LOCK TABLES `student_simulator` WRITE;
|
||||
/*!40000 ALTER TABLE `student_simulator` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `student_simulator` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2020-01-06 23:21:01
|
|
@ -0,0 +1,54 @@
|
|||
-- MySQL dump 10.13 Distrib 8.0.17, for macos10.14 (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: playground
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 8.0.18
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `task`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `task`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `task` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`type` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`action` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`url` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `task`
|
||||
--
|
||||
|
||||
LOCK TABLES `task` WRITE;
|
||||
/*!40000 ALTER TABLE `task` DISABLE KEYS */;
|
||||
INSERT INTO `task` VALUES (1,'Is simulator launched ?','bool','Launch Simulator',NULL),(2,'Is scripting started ?','bool','Start scripting',NULL),(3,'Is script saved ?','bool','Save script',NULL),(4,'Percentage of code completed ?','string','None',NULL);
|
||||
/*!40000 ALTER TABLE `task` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2020-01-06 23:21:01
|
|
@ -0,0 +1,51 @@
|
|||
-- MySQL dump 10.13 Distrib 8.0.17, for macos10.14 (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: playground
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 8.0.18
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `task_progress`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `task_progress`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `task_progress` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`task_id` int(11) DEFAULT NULL,
|
||||
`task_progress_value` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `task_progress`
|
||||
--
|
||||
|
||||
LOCK TABLES `task_progress` WRITE;
|
||||
/*!40000 ALTER TABLE `task_progress` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `task_progress` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2020-01-06 23:21:01
|
|
@ -0,0 +1,51 @@
|
|||
-- MySQL dump 10.13 Distrib 8.0.17, for macos10.14 (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: playground
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 8.0.18
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `user`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `user`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user` (
|
||||
`id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`email` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `user`
|
||||
--
|
||||
|
||||
LOCK TABLES `user` WRITE;
|
||||
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2020-01-06 23:21:01
|
|
@ -0,0 +1,56 @@
|
|||
-- MySQL dump 10.13 Distrib 8.0.17, for macos10.14 (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: playground
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 8.0.18
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `user_competition`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `user_competition`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_competition` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`comp_id` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`task_id` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`task_name` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`task_progress` varchar(45) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`task_action` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`task_url` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `user_competition`
|
||||
--
|
||||
|
||||
LOCK TABLES `user_competition` WRITE;
|
||||
/*!40000 ALTER TABLE `user_competition` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `user_competition` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2020-01-06 23:21:00
|
|
@ -0,0 +1,24 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
|
@ -0,0 +1,44 @@
|
|||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.<br>
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.<br>
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.<br>
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.<br>
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.<br>
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0",
|
||||
"bootstrap": "4.1.3",
|
||||
"react": "^16.6.0",
|
||||
"react-cookie": "3.0.4",
|
||||
"react-dom": "^16.6.0",
|
||||
"react-router-dom": "4.3.1",
|
||||
"react-scripts": "2.1.0",
|
||||
"reactjs-popup": "^1.5.0",
|
||||
"reactstrap": "6.5.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"proxy": "http://localhost:8080",
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"browserslist": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not ie <= 11",
|
||||
"not op_mini all"
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is added to the
|
||||
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Concours de drones, ENVOL</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
You need to enable JavaScript to run this app.
|
||||
</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
height: 40vmin;
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.container, .container-fluid {
|
||||
margin-top: 20px;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import React, { Component } from 'react';
|
||||
import './App.css';
|
||||
import Home from './Home';
|
||||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
||||
import TaskList from './TaskList';
|
||||
import { CookiesProvider } from 'react-cookie';
|
||||
|
||||
class App extends Component {
|
||||
render() {
|
||||
return (
|
||||
<CookiesProvider>
|
||||
<Router>
|
||||
<Switch>
|
||||
<Route path='/' exact={true} component={Home}/>
|
||||
<Route path='/tasks' exact={true} component={TaskList}/>
|
||||
</Switch>
|
||||
</Router>
|
||||
</CookiesProvider>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
|
@ -0,0 +1,9 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.render(<App />, div);
|
||||
ReactDOM.unmountComponentAtNode(div);
|
||||
});
|
|
@ -0,0 +1,36 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
export default class AppNavbar extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {isOpen: false};
|
||||
this.toggle = this.toggle.bind(this);
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.setState({
|
||||
isOpen: !this.state.isOpen
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return <Navbar color="info" dark expand="md">
|
||||
<NavbarBrand tag={Link} to="/">Home</NavbarBrand>
|
||||
<NavbarToggler onClick={this.toggle}/>
|
||||
<Collapse isOpen={this.state.isOpen} navbar>
|
||||
<Nav className="ml-auto" navbar>
|
||||
<NavItem>
|
||||
<NavLink
|
||||
href="https://pleiadesrobotics.com/">@Spiri</NavLink>
|
||||
</NavItem>
|
||||
<NavItem>
|
||||
<NavLink
|
||||
href="https://pleiadesrobotics.com/contact-form/">Contact</NavLink>
|
||||
</NavItem>
|
||||
</Nav>
|
||||
</Collapse>
|
||||
</Navbar>;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
import React, { Component } from 'react';
|
||||
import './App.css';
|
||||
import AppNavbar from './AppNavbar';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Button, Container } from 'reactstrap';
|
||||
import { withCookies } from 'react-cookie';
|
||||
|
||||
class Home extends Component {
|
||||
state = {
|
||||
isLoading: true,
|
||||
isAuthenticated: false,
|
||||
user: undefined
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const {cookies} = props;
|
||||
this.state.csrfToken = cookies.get('XSRF-TOKEN');
|
||||
this.login = this.login.bind(this);
|
||||
this.logout = this.logout.bind(this);
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
const response = await fetch('/api/user', {credentials: 'include'});
|
||||
const body = await response.text();
|
||||
if (body === '') {
|
||||
this.setState(({isAuthenticated: false}))
|
||||
} else {
|
||||
this.setState({isAuthenticated: true, user: JSON.parse(body)})
|
||||
}
|
||||
}
|
||||
|
||||
login() {
|
||||
let port = (window.location.port ? ':' + window.location.port : '');
|
||||
if (port === ':3000') {
|
||||
port = ':8080';
|
||||
}
|
||||
window.location.href = '//' + window.location.hostname + port + '/private';
|
||||
}
|
||||
|
||||
logout() {
|
||||
fetch('/api/logout', {method: 'POST', credentials: 'include',
|
||||
headers: {'X-XSRF-TOKEN': this.state.csrfToken}}).then(res => res.json())
|
||||
.then(response => {
|
||||
window.location.href = response.logoutUrl + "?id_token_hint=" +
|
||||
response.idToken + "&post_logout_redirect_uri=" + window.location.origin;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
const message = this.state.user ?
|
||||
<h2>Welcome, {this.state.user.name}!</h2> :
|
||||
<p>Please log in to manage your competition.</p>;
|
||||
|
||||
const button = this.state.isAuthenticated ?
|
||||
<div>
|
||||
<Button color="link"><Link to="/tasks">Manage Competition Tasks</Link></Button>
|
||||
<br/>
|
||||
<Button color="link" onClick={this.logout}>Logout</Button>
|
||||
</div> :
|
||||
<Button color="primary" onClick={this.login}>Login</Button>;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<AppNavbar/>
|
||||
<Container fluid>
|
||||
{message}
|
||||
{button}
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withCookies(Home);
|
|
@ -0,0 +1,142 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Button, ButtonGroup, Container, Table } from 'reactstrap';
|
||||
import AppNavbar from './AppNavbar';
|
||||
import { Link, withRouter } from 'react-router-dom';
|
||||
import { instanceOf } from 'prop-types';
|
||||
import { withCookies, Cookies } from 'react-cookie';
|
||||
import axios from 'axios';
|
||||
|
||||
class TaskList extends Component {
|
||||
static propTypes = {
|
||||
cookies: instanceOf(Cookies).isRequired
|
||||
};
|
||||
|
||||
state = {
|
||||
isLoading: true,
|
||||
isAuthenticated: false,
|
||||
user: undefined,
|
||||
simulator: undefined
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const {cookies} = props;
|
||||
this.state = {tasks: [], csrfToken: cookies.get('XSRF-TOKEN'), isLoading: true, simulator: "", timeoutActionTaken: false};
|
||||
this.simulatorWindow = null;
|
||||
// this.remove = this.remove.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.loadUser();
|
||||
}
|
||||
|
||||
async loadUser() {
|
||||
const response = await fetch('/api/user', {credentials: 'include'});
|
||||
const body = await response.text();
|
||||
if (body === '') {
|
||||
this.setState(({isAuthenticated: false}))
|
||||
} else {
|
||||
this.setState({isAuthenticated: true, user: JSON.parse(body)})
|
||||
}
|
||||
|
||||
const userId = this.state.user.sub;
|
||||
const userName = this.state.user.given_name;
|
||||
fetch(`competition/progress/${userId}/13`, {credentials: 'include'})
|
||||
.then(response => response.json())
|
||||
.then(data => this.setState({tasks: data, isLoading: true}))
|
||||
.catch(() => this.props.history.push('/'));
|
||||
|
||||
const httpClient = axios.create();
|
||||
httpClient.defaults.timeout = 600000;
|
||||
|
||||
httpClient.get(`simulator/start/${userId}/${userName}/spiri-friend2019@`, { withCredentials: true })
|
||||
.then(res => {
|
||||
this.setState({simulator: res.data, isLoading: false});
|
||||
})
|
||||
}
|
||||
|
||||
openAction(urlAction, action){
|
||||
const url = urlAction;
|
||||
const type = action;
|
||||
if(type == 'Launch Simulator'){
|
||||
this.simulatorWindow = window.open(url + ":8080", '_blank');
|
||||
}
|
||||
else{
|
||||
this.simulatorWindow = window.open(url + ":4200", '_blank');
|
||||
}
|
||||
//simulatorWindow.opener.alert('helooooo');
|
||||
}
|
||||
|
||||
openAutoTimeout(){
|
||||
setTimeout(function(){console.log('auto close start now...');}.bind(this), 60*1000);
|
||||
}
|
||||
|
||||
openTimeout(){
|
||||
setTimeout(function(){
|
||||
var win = window.open(null, '_blank');
|
||||
this.state.timeoutActionTaken = false;
|
||||
win.focus();
|
||||
|
||||
if(win.confirm("Do you want to keep simulator open and in-use? \nClick 'Ok' for Yes and 'Cancel' for No.\nIf nothing selected, simulator will be shut down automatically.")){
|
||||
// Do nothing, keep simulator alive
|
||||
this.state.timeoutActionTaken = true;
|
||||
//alert('ok clicked');
|
||||
win.close();
|
||||
} else {
|
||||
// send api to backend to stop task
|
||||
this.state.timeoutActionTaken = true;
|
||||
//alert('cancel clicked');
|
||||
win.close();
|
||||
}}.bind(this), 60*60*1000);
|
||||
this.openAutoTimeout();
|
||||
}
|
||||
updateTask(userId, compId, taskId){
|
||||
fetch(`competition/update/${userId}/${compId}/${taskId}`, {credentials: 'include'})
|
||||
.then(response => response.json())
|
||||
.then(data => this.setState({tasks: data, isLoading: false}))
|
||||
.catch(() => this.props.history.push('/'));
|
||||
}
|
||||
|
||||
render() {
|
||||
const {tasks, isLoading, simulator} = this.state;
|
||||
|
||||
if (isLoading) {
|
||||
return <p>Loading tasks and simulator...</p>;
|
||||
}
|
||||
|
||||
const taskList = tasks.map(task => {
|
||||
return <tr key={task.task_id}>
|
||||
<td style={{wordWrap: 'break-word'}}>{task.task_name}</td>
|
||||
<td style={{whiteSpace: 'nowrap'}}>{task.task_progress}</td>
|
||||
<td>
|
||||
<ButtonGroup>
|
||||
<Button width="50%" size="sm" color="primary" disabled={this.state.isLoading} onClick={() => {this.openTimeout(); this.openAction(this.state.simulator.publicIp, task.task_action); this.updateTask(this.state.user.sub, 13, task.task_id);}}>{task.task_action}</Button>
|
||||
</ButtonGroup>
|
||||
</td>
|
||||
</tr>
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<AppNavbar/>
|
||||
<Container fluid>
|
||||
<h3>My Competition Tasks</h3>
|
||||
<Table style={{tableLayout: 'fixed'}} className="mt-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30%">Task Name</th>
|
||||
<th width="20%">Progress</th>
|
||||
<th width="30%">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{taskList}
|
||||
</tbody>
|
||||
</Table>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withCookies(withRouter(TaskList));
|
|
@ -0,0 +1,14 @@
|
|||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
||||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||
monospace;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
||||
// If you want your app to work offline and load faster, you can change
|
||||
// unregister() to register() below. Note this comes with some pitfalls.
|
||||
// Learn more about service workers: http://bit.ly/CRA-PWA
|
||||
serviceWorker.unregister();
|
|
@ -0,0 +1,7 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
|
||||
<g fill="#61DAFB">
|
||||
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
|
||||
<circle cx="420.9" cy="296.5" r="45.7"/>
|
||||
<path d="M520.5 78.1z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.6 KiB |
|
@ -0,0 +1,135 @@
|
|||
// This optional code is used to register a service worker.
|
||||
// register() is not called by default.
|
||||
|
||||
// This lets the app load faster on subsequent visits in production, and gives
|
||||
// it offline capabilities. However, it also means that developers (and users)
|
||||
// will only see deployed updates on subsequent visits to a page, after all the
|
||||
// existing tabs open on the page have been closed, since previously cached
|
||||
// resources are updated in the background.
|
||||
|
||||
// To learn more about the benefits of this model and instructions on how to
|
||||
// opt-in, read http://bit.ly/CRA-PWA
|
||||
|
||||
const isLocalhost = Boolean(
|
||||
window.location.hostname === 'localhost' ||
|
||||
// [::1] is the IPv6 localhost address.
|
||||
window.location.hostname === '[::1]' ||
|
||||
// 127.0.0.1/8 is considered localhost for IPv4.
|
||||
window.location.hostname.match(
|
||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||
)
|
||||
);
|
||||
|
||||
export function register(config) {
|
||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||
// The URL constructor is available in all browsers that support SW.
|
||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
||||
if (publicUrl.origin !== window.location.origin) {
|
||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||
// from what our page is served on. This might happen if a CDN is used to
|
||||
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
||||
return;
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||
|
||||
if (isLocalhost) {
|
||||
// This is running on localhost. Let's check if a service worker still exists or not.
|
||||
checkValidServiceWorker(swUrl, config);
|
||||
|
||||
// Add some additional logging to localhost, pointing developers to the
|
||||
// service worker/PWA documentation.
|
||||
navigator.serviceWorker.ready.then(() => {
|
||||
console.log(
|
||||
'This web app is being served cache-first by a service ' +
|
||||
'worker. To learn more, visit http://bit.ly/CRA-PWA'
|
||||
);
|
||||
});
|
||||
} else {
|
||||
// Is not localhost. Just register service worker
|
||||
registerValidSW(swUrl, config);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function registerValidSW(swUrl, config) {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then(registration => {
|
||||
registration.onupdatefound = () => {
|
||||
const installingWorker = registration.installing;
|
||||
if (installingWorker == null) {
|
||||
return;
|
||||
}
|
||||
installingWorker.onstatechange = () => {
|
||||
if (installingWorker.state === 'installed') {
|
||||
if (navigator.serviceWorker.controller) {
|
||||
// At this point, the updated precached content has been fetched,
|
||||
// but the previous service worker will still serve the older
|
||||
// content until all client tabs are closed.
|
||||
console.log(
|
||||
'New content is available and will be used when all ' +
|
||||
'tabs for this page are closed. See http://bit.ly/CRA-PWA.'
|
||||
);
|
||||
|
||||
// Execute callback
|
||||
if (config && config.onUpdate) {
|
||||
config.onUpdate(registration);
|
||||
}
|
||||
} else {
|
||||
// At this point, everything has been precached.
|
||||
// It's the perfect time to display a
|
||||
// "Content is cached for offline use." message.
|
||||
console.log('Content is cached for offline use.');
|
||||
|
||||
// Execute callback
|
||||
if (config && config.onSuccess) {
|
||||
config.onSuccess(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error during service worker registration:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function checkValidServiceWorker(swUrl, config) {
|
||||
// Check if the service worker can be found. If it can't reload the page.
|
||||
fetch(swUrl)
|
||||
.then(response => {
|
||||
// Ensure service worker exists, and that we really are getting a JS file.
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (
|
||||
response.status === 404 ||
|
||||
(contentType != null && contentType.indexOf('javascript') === -1)
|
||||
) {
|
||||
// No service worker found. Probably a different app. Reload the page.
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.unregister().then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Service worker found. Proceed as normal.
|
||||
registerValidSW(swUrl, config);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
console.log(
|
||||
'No internet connection found. App is running in offline mode.'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function unregister() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.unregister();
|
||||
});
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,4 @@
|
|||
docker container stop springbootapp productdb
|
||||
docker container rm springbootapp productdb
|
||||
docker image rm mariadb:latest spiri-backend-image_test_1:latest
|
||||
docker-compose up -d
|
|
@ -0,0 +1,24 @@
|
|||
version: '2'
|
||||
services:
|
||||
springbootapp:
|
||||
image: spiri-backend-image_test_1:latest
|
||||
container_name: springbootapp
|
||||
depends_on:
|
||||
- mariadb
|
||||
environment:
|
||||
- SPRING_DATASOURCE_URL=jdbc:mysql://productdb:3306/playground?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
||||
mariadb:
|
||||
image: mariadb:latest
|
||||
container_name: productdb
|
||||
volumes:
|
||||
#- /Users/raghav/mysqldump:/docker-entrypoint-initdb.d
|
||||
- /Users/raghav/mysqldocker/:/var/lib/mysql/
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=1234
|
||||
- MYSQL_DATABASE=playground
|
||||
- MYSQL_USER=root
|
||||
- MYSQL_PASSWORD=1234
|
||||
command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
|
||||
'''
|
||||
Command to run this script :
|
||||
executor.sh -e "prod" -b true -r false
|
||||
"environment:clean_build:run:"
|
||||
e -> environment
|
||||
b -> clean_build
|
||||
r -> run
|
||||
'''
|
||||
|
||||
helpFunction()
|
||||
{
|
||||
echo ""
|
||||
echo "Usage: $0 -e environment -b clean_build -r run"
|
||||
echo -e "\t-e Environment for the deplyment"
|
||||
echo -e "\t-b Cleaning docker workspace and building a new docker file"
|
||||
echo -e "\t-r Running the docker file"
|
||||
exit 1 # Exit script after printing help
|
||||
}
|
||||
|
||||
while getopts "e:b:r:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
e ) environment="$OPTARG" ;;
|
||||
b ) clean_build="$OPTARG" ;;
|
||||
r ) run="$OPTARG" ;;
|
||||
? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
|
||||
esac
|
||||
done
|
||||
|
||||
# Print helpFunction in case parameters are empty
|
||||
if [ -z "$environment" ] || [ -z "$clean_build" ] || [ -z "$run" ]
|
||||
then
|
||||
echo "Some or all of the parameters are empty";
|
||||
helpFunction
|
||||
fi
|
||||
|
||||
if [ "$environment" == "prod" ]
|
||||
then
|
||||
if [ "$clean_build" == "true" ];
|
||||
then
|
||||
echo "Cleaning the existing docker images"
|
||||
docker container stop springbootapp productdb
|
||||
docker container rm springbootapp productdb
|
||||
docker image rm mariadb:latest spiri-backend-image_test_1:latest openjdk:8-jdk-alpine
|
||||
#echo "Cleaning the target folder"
|
||||
#rm -r ~/target
|
||||
#echo "Builing the jar file"
|
||||
#mvn clean install
|
||||
echo "Building the docker image"
|
||||
docker build -t spiri-backend-image_test_1 .
|
||||
fi
|
||||
if [ "$run" == "true" ];
|
||||
then
|
||||
echo "Starting to run the docker services mentioned in docker-compose file"
|
||||
docker-compose up -d
|
||||
fi
|
||||
elif [ "$environment" == "dev"] && ["$run" == "true"]
|
||||
then
|
||||
mvn clean install
|
||||
mvn spring-boot:run
|
||||
fi
|
|
@ -0,0 +1,286 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
curl -o "$wrapperJarPath" "$jarUrl"
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
@ -0,0 +1,161 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
echo Found %WRAPPER_JAR%
|
||||
) else (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
|
@ -0,0 +1,189 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.4.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>springbootapp</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>springbootapp</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
|
||||
<node.version>v10.13.0</node.version>
|
||||
<yarn.version>v1.12.1</yarn.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-oauth2-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-oauth2-jose</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk</artifactId>
|
||||
<version>1.11.700</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20190722</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<finalName>springBootApp</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<spring.profiles.active>dev</spring.profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>app/build</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<version>${frontend-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<workingDirectory>app</workingDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install node</id>
|
||||
<goals>
|
||||
<goal>install-node-and-yarn</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<nodeVersion>${node.version}</nodeVersion>
|
||||
<yarnVersion>${yarn.version}</yarnVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>yarn install</id>
|
||||
<goals>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
<phase>generate-resources</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>yarn test</id>
|
||||
<goals>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
<phase>test</phase>
|
||||
<configuration>
|
||||
<arguments>test</arguments>
|
||||
<environmentVariables>
|
||||
<CI>true</CI>
|
||||
</environmentVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>yarn build</id>
|
||||
<goals>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
<phase>compile</phase>
|
||||
<configuration>
|
||||
<arguments>build</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<spring.profiles.active>prod</spring.profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,130 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="jpa" name="JPA">
|
||||
<configuration>
|
||||
<setting name="validation-enabled" value="true" />
|
||||
<setting name="provider-name" value="Hibernate" />
|
||||
<datasource-mapping>
|
||||
<factory-entry name="entityManagerFactory" />
|
||||
</datasource-mapping>
|
||||
<naming-strategy-map />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<webroots />
|
||||
<sourceRoots>
|
||||
<root url="file://$MODULE_DIR$/src/main/java" />
|
||||
<root url="file://$MODULE_DIR$/src/main/resources" />
|
||||
</sourceRoots>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.transaction:javax.transaction-api:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.3.9.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.persistence:javax.persistence-api:2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.23.1-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.9.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss:jandex:2.0.5.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.dom4j:dom4j:2.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.4.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:2.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-orm:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aspects:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.16.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:5.1.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.1.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:5.1.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-oauth2-client:5.1.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nimbusds:oauth2-oidc-sdk:6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.mail:javax.mail:1.6.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.stephenc.jcip:jcip-annotations:1.0-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nimbusds:lang-tag:1.4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-oauth2-core:5.1.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-oauth2-jose:5.1.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nimbusds:nimbus-jose-jwt:6.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.11.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:2.23.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.9.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.15" level="project" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
|
@ -0,0 +1,16 @@
|
|||
package com.example.springbootapp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class SpringbootappApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
//System.setProperty("server.connection-timeout","300000");
|
||||
SpringApplication.run(SpringbootappApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.example.springbootapp.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
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.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
|
||||
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
|
||||
import org.springframework.security.web.savedrequest.RequestCache;
|
||||
import org.springframework.security.web.savedrequest.SimpleSavedRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.oauth2Login().and()
|
||||
.csrf()
|
||||
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/**/*.{js,html,css}").permitAll()
|
||||
.antMatchers("/", "/api/user").permitAll()
|
||||
.anyRequest().authenticated();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Profile("dev")
|
||||
public RequestCache refererRequestCache() {
|
||||
return new HttpSessionRequestCache() {
|
||||
@Override
|
||||
public void saveRequest(HttpServletRequest request, HttpServletResponse response) {
|
||||
String referrer = request.getHeader("referer");
|
||||
if (referrer != null) {
|
||||
request.getSession().setAttribute("SPRING_SECURITY_SAVED_REQUEST", new SimpleSavedRequest(referrer));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.example.springbootapp.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SimpleCORSFilter implements Filter {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(SimpleCORSFilter.class);
|
||||
|
||||
public SimpleCORSFilter() {
|
||||
log.info("SimpleCORSFilter init");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
//request.getHeader("Origin")
|
||||
response.setHeader("Access-Control-Allow-Origin", "http://localhost:3000");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
||||
response.setHeader("Access-Control-Max-Age", "600000");
|
||||
response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me");
|
||||
|
||||
chain.doFilter(req, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.example.springbootapp.controllers;
|
||||
|
||||
import com.example.springbootapp.model.UserCompetition;
|
||||
import com.example.springbootapp.services.CompetitionServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.oauth2.core.user.OAuth2User;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/competition")
|
||||
public class CompetitionController {
|
||||
|
||||
@Autowired
|
||||
private CompetitionServiceImpl service;
|
||||
|
||||
@GetMapping("/progress/{user_id}/{comp_id}")
|
||||
public List<UserCompetition> getAllProduct(@PathVariable String user_id, @PathVariable String comp_id) {
|
||||
return service.getAllTasksProgress(user_id, comp_id);
|
||||
}
|
||||
|
||||
@GetMapping("/update/{user_id}/{comp_id}/{task_id}")
|
||||
public List<UserCompetition> updateTask(@AuthenticationPrincipal OAuth2User user, @PathVariable String user_id, @PathVariable String comp_id, @PathVariable String task_id) throws InterruptedException {
|
||||
if (!user.getAttributes().get("sub").equals(user_id)) {
|
||||
System.out.println("<<<<<<Wrong user id>>>>>>>");
|
||||
return null;
|
||||
} else {
|
||||
return service.updateTask(user_id, comp_id, task_id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.example.springbootapp.controllers;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class RedirectController {
|
||||
|
||||
@GetMapping("/private")
|
||||
public String redirectToRoot() {
|
||||
return "redirect:/";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.example.springbootapp.controllers;
|
||||
|
||||
import com.example.springbootapp.services.SimulatorServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
@RestController
|
||||
@RequestMapping("/simulator")
|
||||
public class SimulatorController {
|
||||
@Autowired
|
||||
private SimulatorServiceImpl service;
|
||||
|
||||
|
||||
@GetMapping("/start/{user_id}/{name}/{pwd}")
|
||||
public Map startSimulator(@PathVariable String user_id, @PathVariable String name, @PathVariable String pwd) throws InterruptedException {
|
||||
return service.startSimulator(user_id, name, pwd);
|
||||
}
|
||||
|
||||
@GetMapping("/stop/{user_id}")
|
||||
public void stopSimulator(@PathVariable String user_id) throws InterruptedException {
|
||||
service.stopSimulator(user_id);
|
||||
}
|
||||
|
||||
@GetMapping("/logheartbeat/{user_id}")
|
||||
public void logHeartBeat(@PathVariable String user_id) throws InterruptedException {
|
||||
service.logHeartBeat(user_id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.example.springbootapp.controllers;
|
||||
|
||||
import com.example.springbootapp.model.Task;
|
||||
import com.example.springbootapp.services.TaskServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/task")
|
||||
public class TaskController {
|
||||
|
||||
@Autowired
|
||||
private TaskServiceImpl service;
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<Task> getAllTask(){
|
||||
return service.getAllTask();
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
public Task updateTask(@RequestBody Task task){
|
||||
return service.createTask(task);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.example.springbootapp.controllers;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.oauth2.client.registration.ClientRegistration;
|
||||
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
|
||||
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
|
||||
import org.springframework.security.oauth2.core.user.OAuth2User;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class UserController {
|
||||
private ClientRegistration registration;
|
||||
|
||||
public UserController(ClientRegistrationRepository registrations) {
|
||||
this.registration = registrations.findByRegistrationId("okta");
|
||||
}
|
||||
|
||||
@GetMapping("/api/user")
|
||||
public ResponseEntity<?> getUser(@AuthenticationPrincipal OAuth2User user) {
|
||||
if (user == null) {
|
||||
return new ResponseEntity<>("", HttpStatus.OK);
|
||||
} else {
|
||||
return ResponseEntity.ok().body(user.getAttributes());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/api/logout")
|
||||
public ResponseEntity<?> logout(HttpServletRequest request,
|
||||
@AuthenticationPrincipal(expression = "idToken") OidcIdToken idToken) {
|
||||
// send logout URL to client so they can initiate logout
|
||||
String logoutUrl = this.registration.getProviderDetails()
|
||||
.getConfigurationMetadata().get("end_session_endpoint").toString();
|
||||
|
||||
Map<String, String> logoutDetails = new HashMap<>();
|
||||
logoutDetails.put("logoutUrl", logoutUrl);
|
||||
logoutDetails.put("idToken", idToken.getTokenValue());
|
||||
request.getSession(false).invalidate();
|
||||
return ResponseEntity.ok().body(logoutDetails);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.example.springbootapp.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "student_simulator")
|
||||
public class StudentSimulator implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter @Setter private Long id;
|
||||
@Getter @Setter private String student_id;
|
||||
@Getter @Setter private String task_arn;
|
||||
@Getter @Setter private String status;
|
||||
@Getter @Setter private LocalDateTime time_stamp;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.example.springbootapp.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "task")
|
||||
public class Task implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter @Setter private Long id;
|
||||
@Getter @Setter private String name;
|
||||
@Getter @Setter private String type;
|
||||
@Getter @Setter private String action;
|
||||
@Getter @Setter private String url;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.springbootapp.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "task_progress")
|
||||
public class TaskProgress implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter
|
||||
@Setter
|
||||
private Long id;
|
||||
@Getter @Setter private Long task_id;
|
||||
@Getter @Setter private String task_progress_value;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.example.springbootapp.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
private String name;
|
||||
private String email;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.example.springbootapp.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user_competition")
|
||||
public class UserCompetition implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter
|
||||
@Setter
|
||||
private Long id;
|
||||
|
||||
@Getter @Setter private String user_id;
|
||||
@Getter @Setter private String comp_id;
|
||||
@Getter @Setter private String task_id;
|
||||
@Getter @Setter private String task_name;
|
||||
@Getter @Setter private String task_progress;
|
||||
@Getter @Setter private String task_action;
|
||||
@Getter @Setter private String task_url;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.springbootapp.repository;
|
||||
|
||||
import com.example.springbootapp.model.UserCompetition;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface CompetitionRepository extends JpaRepository<UserCompetition, Long> {
|
||||
@Query("SELECT u FROM UserCompetition u WHERE u.user_id = ?1 and u.comp_id = ?2")
|
||||
List<UserCompetition> findByUserAndComp(String userId, String compId);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE UserCompetition SET task_progress=1 WHERE user_id = ?1 and comp_id = ?2 and task_id = ?3")
|
||||
void updateByUserAndCompAndTask(String userId, String compId, String taskId);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.example.springbootapp.repository;
|
||||
|
||||
import com.example.springbootapp.model.StudentSimulator;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface SimulatorRepository extends JpaRepository<StudentSimulator, Long> {
|
||||
|
||||
@Query("SELECT s FROM StudentSimulator s WHERE s.student_id = ?1")
|
||||
StudentSimulator findByStudent_id(String studentId);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE StudentSimulator set time_stamp = current_timestamp WHERE student_id = ?1")
|
||||
void updateTimeStamp(String studentId);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.example.springbootapp.repository;
|
||||
|
||||
import com.example.springbootapp.model.Task;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TaskRepository extends JpaRepository<Task, Long> {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.example.springbootapp.repository;
|
||||
|
||||
import com.example.springbootapp.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, String> {
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.example.springbootapp.schedulers;
|
||||
|
||||
|
||||
import com.example.springbootapp.model.StudentSimulator;
|
||||
import com.example.springbootapp.services.SimulatorServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ScheduledTasks {
|
||||
@Autowired
|
||||
private SimulatorServiceImpl service;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
|
||||
|
||||
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
|
||||
@Scheduled(fixedRate = 60*60*1000)
|
||||
public void scheduleTaskWithFixedRate() {
|
||||
logger.info("Simulators clean up scan started :: Execution Time - {}", dateTimeFormatter.format(LocalDateTime.now()) );
|
||||
List<StudentSimulator> simulators = service.getAllSimulators();
|
||||
for(StudentSimulator s : simulators) {
|
||||
if (s.getTime_stamp().plusHours(1).isBefore(LocalDateTime.now())) {
|
||||
logger.info("Deleting simulator task arn :: " + s.getTask_arn());
|
||||
service.deleteSimulator(s.getId(), s.getTask_arn());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.example.springbootapp.services;
|
||||
|
||||
import com.example.springbootapp.model.UserCompetition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CompetitionService {
|
||||
public List<UserCompetition> getAllTasksProgress(String userId, String compId);
|
||||
public void copyTasks(String userId, String compId);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.example.springbootapp.services;
|
||||
|
||||
import com.example.springbootapp.model.Task;
|
||||
import com.example.springbootapp.model.UserCompetition;
|
||||
import com.example.springbootapp.repository.CompetitionRepository;
|
||||
import com.example.springbootapp.repository.TaskRepository;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CompetitionServiceImpl implements CompetitionService{
|
||||
@Autowired
|
||||
@Getter @Setter private CompetitionRepository repository;
|
||||
@Autowired
|
||||
@Getter @Setter private TaskRepository taskRepository;
|
||||
|
||||
public List<UserCompetition> getAllTasksProgress(String userId, String compId){
|
||||
if(getAllTasksProgressCount(userId, compId) == 0){
|
||||
//Copy tasks from tasks master table
|
||||
copyTasks(userId, compId);
|
||||
}
|
||||
return repository.findByUserAndComp(userId, compId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<UserCompetition> updateTask(String userId, String compId, String taskId){
|
||||
repository.updateByUserAndCompAndTask(userId, compId, taskId);
|
||||
return repository.findByUserAndComp(userId, compId);
|
||||
}
|
||||
|
||||
|
||||
public void copyTasks(String userId, String compId){
|
||||
List<Task> tasks = taskRepository.findAll();
|
||||
for(Task t : tasks)
|
||||
{
|
||||
UserCompetition userCompetition = new UserCompetition();
|
||||
userCompetition.setUser_id(userId);
|
||||
userCompetition.setComp_id(compId);
|
||||
userCompetition.setTask_id(String.valueOf(t.getId()));
|
||||
userCompetition.setTask_name(t.getName());
|
||||
userCompetition.setTask_progress("0");
|
||||
userCompetition.setTask_action(t.getAction());
|
||||
userCompetition.setTask_url(t.getUrl());
|
||||
repository.save(userCompetition);
|
||||
}
|
||||
}
|
||||
|
||||
private int getAllTasksProgressCount(String userId, String compId){
|
||||
return repository.findByUserAndComp(userId, compId).size();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.example.springbootapp.services;
|
||||
|
||||
import com.example.springbootapp.model.StudentSimulator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SimulatorService {
|
||||
public Map startSimulator(String user_id, String user, String pwd) throws InterruptedException;
|
||||
public boolean deleteSimulator(Long student_id, String task_arn);
|
||||
public List<StudentSimulator> getAllSimulators();
|
||||
public StudentSimulator getSimulator(String student_id);
|
||||
public void stopSimulator(String student_id);
|
||||
public void logHeartBeat(String student_id);
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
package com.example.springbootapp.services;
|
||||
|
||||
import com.amazonaws.auth.AWSCredentials;
|
||||
import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
||||
import com.amazonaws.auth.BasicAWSCredentials;
|
||||
import com.amazonaws.services.ec2.AmazonEC2;
|
||||
import com.amazonaws.services.ec2.AmazonEC2ClientBuilder;
|
||||
import com.amazonaws.services.ec2.model.DescribeNetworkInterfacesRequest;
|
||||
import com.amazonaws.services.ec2.model.DescribeNetworkInterfacesResult;
|
||||
import com.amazonaws.services.ecs.model.Tag;
|
||||
import com.amazonaws.services.ecs.AmazonECS;
|
||||
import com.amazonaws.services.ecs.AmazonECSClientBuilder;
|
||||
import com.amazonaws.services.ecs.model.*;
|
||||
import com.example.springbootapp.model.StudentSimulator;
|
||||
import com.example.springbootapp.repository.SimulatorRepository;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class SimulatorServiceImpl implements SimulatorService {
|
||||
|
||||
private static String SPIRI_CLUSTER = "SpiriWeb";
|
||||
private static String SPIRI_TASK_DEF = "SpiriSim:2";
|
||||
private static String SPIRI_SUB_NET= "subnet-00ac98979fde47408";
|
||||
private static String SPIRI_SECURITY_GROUP= "sg-0a323534e6fbcabae";
|
||||
private static String SHELLINABOX_ALLOW_SUDO= "SHELLINABOX_ALLOW_SUDO";
|
||||
private static String SHELLINABOX_USER= "SHELLINABOX_USER";
|
||||
private static String SHELLINABOX_PASSWORD= "SHELLINABOX_PASSWORD";
|
||||
private static String CONTAINER_OVERRIDE_NAME= "SpiriSim";
|
||||
|
||||
//TODO: Move these to config or at some other secured location.
|
||||
private static String ACCESS_KEY= "AKIA5465B7PEHHJRUIXB";
|
||||
private static String SECRET_KEY= "FBk4mBeOSxUINeqa17lbUgFU0Bv49NOINl/HLMBD";
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
@Setter
|
||||
private SimulatorRepository simulatorRepository;
|
||||
|
||||
String nwInterface = "";
|
||||
AWSCredentials credentials = new BasicAWSCredentials(
|
||||
ACCESS_KEY,
|
||||
SECRET_KEY
|
||||
);
|
||||
|
||||
AmazonECS ecsClient = AmazonECSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion("us-east-1").build();
|
||||
|
||||
private String getTaskDetails(String arn) throws InterruptedException {
|
||||
|
||||
DescribeTasksRequest requestTaskDetails = new DescribeTasksRequest().withTasks(arn).withCluster(SPIRI_CLUSTER);
|
||||
DescribeTasksResult responseTaskDetails = ecsClient.describeTasks(requestTaskDetails);
|
||||
if (!responseTaskDetails.getTasks().get(0).getLastStatus().equals("RUNNING")) {
|
||||
Thread.sleep(10 * 1000);
|
||||
getTaskDetails(arn);
|
||||
} else {
|
||||
Thread.sleep(5 * 1000);
|
||||
nwInterface = responseTaskDetails.getTasks().get(0).getAttachments().get(0).getDetails().get(1).getValue();
|
||||
}
|
||||
return nwInterface;
|
||||
}
|
||||
|
||||
private String createTask(String studentId, String name, String pwd) throws InterruptedException {
|
||||
System.out.println("StudentId: " + studentId + " name: " + name
|
||||
+ " pwd: " + pwd);
|
||||
|
||||
ArrayList<String> securityGroups = new ArrayList<>();
|
||||
securityGroups.add(SPIRI_SECURITY_GROUP);
|
||||
|
||||
ArrayList<String> subNets = new ArrayList<>();
|
||||
subNets.add(SPIRI_SUB_NET);
|
||||
|
||||
AwsVpcConfiguration awsVpcConfiguration = new AwsVpcConfiguration();
|
||||
awsVpcConfiguration.setAssignPublicIp("ENABLED");
|
||||
awsVpcConfiguration.setSecurityGroups(securityGroups);
|
||||
awsVpcConfiguration.setSubnets(subNets);
|
||||
|
||||
NetworkConfiguration networkConfiguration = new NetworkConfiguration();
|
||||
networkConfiguration.setAwsvpcConfiguration(awsVpcConfiguration);
|
||||
|
||||
|
||||
Tag tag = new Tag().withKey("Student").withValue(studentId);
|
||||
Collection<com.amazonaws.services.ecs.model.Tag> tags = new ArrayList<>();
|
||||
tags.add(tag);
|
||||
|
||||
KeyValuePair shellSudo = new KeyValuePair();
|
||||
shellSudo.withName(SHELLINABOX_ALLOW_SUDO).withValue("1");
|
||||
|
||||
KeyValuePair shellUser = new KeyValuePair();
|
||||
shellUser.withName(SHELLINABOX_USER).withValue(name);
|
||||
|
||||
KeyValuePair shellPwd = new KeyValuePair();
|
||||
shellPwd.withName(SHELLINABOX_PASSWORD).withValue(pwd);
|
||||
|
||||
Collection<KeyValuePair> envVariables = new ArrayList<>();
|
||||
envVariables.add(shellSudo);
|
||||
envVariables.add(shellUser);
|
||||
envVariables.add(shellPwd);
|
||||
|
||||
ContainerOverride containerOverride = new ContainerOverride();
|
||||
containerOverride.setEnvironment(envVariables);
|
||||
containerOverride.setName(CONTAINER_OVERRIDE_NAME);
|
||||
|
||||
Collection<ContainerOverride> containerOverrideCollection = new ArrayList<>();
|
||||
containerOverrideCollection.add(containerOverride);
|
||||
|
||||
TaskOverride taskOverride = new TaskOverride();
|
||||
taskOverride.setContainerOverrides(containerOverrideCollection);
|
||||
|
||||
RunTaskRequest request = new RunTaskRequest()
|
||||
.withCluster(SPIRI_CLUSTER)
|
||||
.withTaskDefinition(SPIRI_TASK_DEF)
|
||||
.withNetworkConfiguration(networkConfiguration)
|
||||
.withEnableECSManagedTags(true)
|
||||
.withTags(tags)
|
||||
.withOverrides(taskOverride)
|
||||
.withLaunchType("FARGATE");
|
||||
|
||||
RunTaskResult response = ecsClient.runTask(request);
|
||||
System.out.println("RunTaskResult response: " + response);
|
||||
return response.getTasks().get(0).getTaskArn();
|
||||
}
|
||||
|
||||
private String getPublicIp(String taskArn) throws InterruptedException {
|
||||
String nwInterface = getTaskDetails(taskArn);
|
||||
|
||||
AmazonEC2 ec2Client = AmazonEC2ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion("us-east-1").build();
|
||||
DescribeNetworkInterfacesRequest networkInterfacesRequest = new DescribeNetworkInterfacesRequest().withNetworkInterfaceIds(nwInterface);
|
||||
DescribeNetworkInterfacesResult networkInterfacesResponse = ec2Client.describeNetworkInterfaces(networkInterfacesRequest);
|
||||
|
||||
System.out.println("networkInterfacesResponse response: " + networkInterfacesResponse);
|
||||
|
||||
System.out.println("<<<<public ip address:::: " + networkInterfacesResponse.getNetworkInterfaces().get(0).getAssociation().getPublicIp());
|
||||
return networkInterfacesResponse.getNetworkInterfaces().get(0).getAssociation().getPublicIp();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map startSimulator(String user_id, String name, String pwd) throws InterruptedException {
|
||||
String taskArn = "";
|
||||
if(getSimulator(user_id) != null){
|
||||
taskArn = getSimulator(user_id).getTask_arn();
|
||||
}
|
||||
|
||||
if(taskArn.equals("")){
|
||||
taskArn = createTask(user_id, name, pwd);
|
||||
|
||||
System.out.println("<<<<ARN>>>> :::: " + taskArn);
|
||||
|
||||
StudentSimulator studentSimulator = new StudentSimulator();
|
||||
studentSimulator.setStudent_id(user_id);
|
||||
studentSimulator.setTask_arn(taskArn);
|
||||
studentSimulator.setStatus("true");
|
||||
studentSimulator.setTime_stamp(LocalDateTime.now());
|
||||
simulatorRepository.save(studentSimulator);
|
||||
}
|
||||
|
||||
String publicIp = getPublicIp(taskArn);
|
||||
Map simulatorResponse = new HashMap();
|
||||
simulatorResponse.put("publicIp", "http://"+ publicIp);
|
||||
return simulatorResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSimulator(Long student_id, String task_arn) {
|
||||
try{
|
||||
StopTaskRequest stopRequest = new StopTaskRequest()
|
||||
.withCluster(SPIRI_CLUSTER)
|
||||
.withReason("InActiveDetected")
|
||||
.withTask(task_arn);
|
||||
StopTaskResult response = ecsClient.stopTask(stopRequest);
|
||||
System.out.println("StopTaskResult response: " + response);}
|
||||
catch (Exception e){
|
||||
System.out.println("Exception in AWS task deletion: " + e.getMessage());
|
||||
}finally {
|
||||
simulatorRepository.deleteById(student_id);
|
||||
}
|
||||
//TODO: Check the response type and return bool value accordingly.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StudentSimulator> getAllSimulators() {
|
||||
return simulatorRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StudentSimulator getSimulator(String student_id) {
|
||||
return simulatorRepository.findByStudent_id(student_id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void stopSimulator(String student_id) {
|
||||
StudentSimulator simulator = getSimulator(student_id);
|
||||
deleteSimulator(simulatorRepository.findByStudent_id(student_id).getId(), simulator.getTask_arn());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void logHeartBeat(String student_id) {
|
||||
simulatorRepository.updateTimeStamp(student_id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.example.springbootapp.services;
|
||||
|
||||
import com.example.springbootapp.model.Task;
|
||||
import java.util.List;
|
||||
|
||||
public interface TaskService {
|
||||
public List<Task> getAllTask();
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.example.springbootapp.services;
|
||||
|
||||
import com.example.springbootapp.model.Task;
|
||||
import com.example.springbootapp.repository.TaskRepository;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TaskServiceImpl implements TaskService{
|
||||
@Autowired
|
||||
@Getter @Setter private TaskRepository repository;
|
||||
|
||||
public List<Task> getAllTask(){
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public Task createTask(Task task){
|
||||
return repository.save(task);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
registration:
|
||||
okta:
|
||||
client-id: 0oa21yqmlw0cI8weJ357
|
||||
client-secret: ggYpEpAF-I_vs492y33fwZvXT2a8LoLBdvnHzoZQ
|
||||
scope: openid, email, profile
|
||||
|
||||
provider:
|
||||
okta:
|
||||
issuer-uri: https://dev-125890.okta.com/oauth2/default
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
password: riddhidave
|
||||
url: jdbc:mysql://localhost:3306/playground?userSSL=false
|
||||
username: root
|
||||
jpa:
|
||||
generate-ddl: true
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
show-sql: true
|
||||
server:
|
||||
connection-timeout: 600000
|
|
@ -0,0 +1,16 @@
|
|||
package com.example.springbootapp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SpringbootappApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
registration:
|
||||
okta:
|
||||
client-id: 0oa21yqmlw0cI8weJ357
|
||||
client-secret: ggYpEpAF-I_vs492y33fwZvXT2a8LoLBdvnHzoZQ
|
||||
scope: openid, email, profile
|
||||
|
||||
provider:
|
||||
okta:
|
||||
issuer-uri: https://dev-125890.okta.com/oauth2/default
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
password: riddhidave
|
||||
url: jdbc:mysql://localhost:3306/playground?userSSL=false
|
||||
username: root
|
||||
jpa:
|
||||
generate-ddl: true
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
show-sql: true
|
||||
server:
|
||||
connection-timeout: 600000
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
#Created by Apache Maven 3.6.0
|
||||
groupId=com.example
|
||||
artifactId=springbootapp
|
||||
version=0.0.1-SNAPSHOT
|
|
@ -0,0 +1,25 @@
|
|||
com/example/springbootapp/repository/UserRepository.class
|
||||
com/example/springbootapp/repository/TaskRepository.class
|
||||
com/example/springbootapp/config/SecurityConfiguration$1.class
|
||||
com/example/springbootapp/services/CompetitionServiceImpl.class
|
||||
com/example/springbootapp/controllers/UserController.class
|
||||
com/example/springbootapp/services/SimulatorServiceImpl.class
|
||||
com/example/springbootapp/config/SecurityConfiguration.class
|
||||
com/example/springbootapp/services/TaskService.class
|
||||
com/example/springbootapp/repository/CompetitionRepository.class
|
||||
com/example/springbootapp/model/UserCompetition.class
|
||||
com/example/springbootapp/model/User.class
|
||||
com/example/springbootapp/repository/SimulatorRepository.class
|
||||
com/example/springbootapp/config/SimpleCORSFilter.class
|
||||
com/example/springbootapp/controllers/RedirectController.class
|
||||
com/example/springbootapp/model/Task.class
|
||||
com/example/springbootapp/controllers/SimulatorController.class
|
||||
com/example/springbootapp/services/CompetitionService.class
|
||||
com/example/springbootapp/services/TaskServiceImpl.class
|
||||
com/example/springbootapp/model/StudentSimulator.class
|
||||
com/example/springbootapp/model/TaskProgress.class
|
||||
com/example/springbootapp/SpringbootappApplication.class
|
||||
com/example/springbootapp/controllers/CompetitionController.class
|
||||
com/example/springbootapp/controllers/TaskController.class
|
||||
com/example/springbootapp/schedulers/ScheduledTasks.class
|
||||
com/example/springbootapp/services/SimulatorService.class
|
|
@ -0,0 +1,24 @@
|
|||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/model/User.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/repository/CompetitionRepository.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/model/StudentSimulator.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/services/TaskServiceImpl.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/services/SimulatorServiceImpl.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/services/CompetitionService.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/config/SecurityConfiguration.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/repository/SimulatorRepository.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/schedulers/ScheduledTasks.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/model/Task.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/controllers/CompetitionController.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/controllers/TaskController.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/model/TaskProgress.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/SpringbootappApplication.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/services/SimulatorService.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/services/TaskService.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/controllers/SimulatorController.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/repository/UserRepository.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/controllers/RedirectController.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/services/CompetitionServiceImpl.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/config/SimpleCORSFilter.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/controllers/UserController.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/model/UserCompetition.java
|
||||
/home/riddhi/simulation/backend/src/main/java/com/example/springbootapp/repository/TaskRepository.java
|
|
@ -0,0 +1 @@
|
|||
com/example/springbootapp/SpringbootappApplicationTests.class
|
|
@ -0,0 +1 @@
|
|||
/home/riddhi/simulation/backend/src/test/java/com/example/springbootapp/SpringbootappApplicationTests.java
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,4 @@
|
|||
-------------------------------------------------------------------------------
|
||||
Test set: com.example.springbootapp.SpringbootappApplicationTests
|
||||
-------------------------------------------------------------------------------
|
||||
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.668 s - in com.example.springbootapp.SpringbootappApplicationTests
|
Binary file not shown.
Loading…
Reference in New Issue