From 76a165b1089a3139e80ebe785852fd91c26aad24 Mon Sep 17 00:00:00 2001 From: Rishabh Poddar Date: Wed, 4 Jan 2023 23:57:51 +0530 Subject: [PATCH] Ee feature flag (#533) * adds empty ee module * changes to runBuild to add ee jar * adds ee built jar * adds test function to ee module * removes test function * adds skeleton logic for feature flag * fixes a bug related to no syncing on init * makes logic simpler * renames * improves code flow * adds a TODO * adds logic for querying API and also for formatting code for sub modules of the core * adds comments about all scenarios of api and db liveness * adds TODOs for long term future changes * changes ee to be dynamically loaded instead of statically * adds ee jar initially * adds ee stuff to downloader * updates contributing guide * gets ee package to dynamically load in the core * modifies a comment * adds a small TODO comment in test * changes logging message * changes copyright and adds storage layer to EE * clarifies some TODOs * adds core version and telemetry ID to license key sync API * adds telemetry ID on core startup * adds code for license check cronjob * fails core start if licese check in db fails * refactors and removes some old TODOs * adds API to load license key * renames file * refactors and adds skeleton for airgapped license check * adds more APIs for ee stuff * adds new API to get enabled features * adds logger * adds logging * refactors code * adds a TODO comment * fixes small bug * adds s TODO * adds more API and skeleton for paid feature * adds db queries * adds JWT verification code * removes unnecessary code * small fix * fixes a bug * changes license check path * small change * adds public key info for stateless lilcense key * changes public key * adds a TODO and adds test feature * removes TODO * Ee feature flag tests (#545) * inital commit * adds some basic tests * adds more test * small changes * small changes * small changes * reverses dependency * moves ee test to ee folder * adds test files to ee folder Co-authored-by: rishabhpoddar * removes wrong copyright from ee folder files * adds a few tests * adds more tests * adds more tests * adds JWT parsing test * adds more tests * removes unnecessary comment * adds more tests * more tests * small bug fix * adds more tests * adds test keys * adds more test keys * modifies one test * removes unnecesary logging and refactors function name * adds more tests * more tests * adds more tests * adds more tests * more tests * fixes a bug * adds more tests * fixes test for in mem * fixes bug in test * test: Adds API tests for EE feature flag (#547) * starts adding tests * adds more tests * adds more SetLicenseKeyAPITests * adds more tests * fixes * fixes * implements feedback * fixes * updates licenses, cdi version and changelog Co-authored-by: Joel Coutinho --- .github/PULL_REQUEST_TEMPLATE.md | 23 +- .gitignore | 1 + CHANGELOG.md | 4 + CONTRIBUTING.md | 125 +- LICENSE.md | 13 +- build.gradle | 3 +- .../main/java/io/supertokens/cli/Main.java | 16 +- .../main/java/io/supertokens/cli/Utils.java | 15 +- .../HashingCalibrateHandler.java | 48 +- .../cli/commandHandler/help/HelpHandler.java | 5 +- .../install/InstallHandler.java | 44 +- .../cli/commandHandler/list/ListHandler.java | 4 +- .../commandHandler/start/StartHandler.java | 12 +- .../cli/commandHandler/stop/StopHandler.java | 26 +- .../uninstall/UninstallHandler.java | 8 +- .../commandHandler/version/VersionFile.java | 12 +- .../cli/httpRequest/HTTPRequest.java | 5 +- .../supertokens/cli/processes/Processes.java | 6 +- coreDriverInterfaceSupported.json | 3 +- .../java/io/supertokens/downloader/Main.java | 3 + ee/LICENSE.md | 36 + ee/build.gradle | 137 ++ ee/jar/ee.jar | Bin 0 -> 10956 bytes ee/runBuild | 25 + .../java/io/supertokens/ee/EEFeatureFlag.java | 317 +++++ .../ee/cronjobs/EELicenseCheck.java | 53 + ...rtokens.featureflag.EEFeatureFlagInterface | 1 + .../io/supertokens/ee/test/CronjobTest.java | 293 ++++ .../java/io/supertokens/ee/test/EETest.java | 1255 +++++++++++++++++ .../supertokens/ee/test/ProcessConsumer.java | 6 + .../java/io/supertokens/ee/test/Retry.java | 58 + .../ee/test/TestingProcessManager.java | 130 ++ .../test/TestingProcessManagerException.java | 11 + .../java/io/supertokens/ee/test/Utils.java | 139 ++ .../ee/test/api/DeleteLicenseKeyAPITest.java | 101 ++ .../ee/test/api/GetFeatureFlagAPITest.java | 77 + .../ee/test/api/GetLicenseKeyAPITest.java | 104 ++ .../ee/test/api/SetLicenseKeyAPITest.java | 174 +++ .../httpRequest/HttpRequestForTesting.java | 216 +++ .../test/httpRequest/HttpRequestMocking.java | 42 + .../httpRequest/HttpResponseException.java | 12 + runBuild | 6 + src/main/java/io/supertokens/Main.java | 50 +- .../java/io/supertokens/ProcessState.java | 7 +- .../cronjobs/telemetry/Telemetry.java | 25 +- .../featureflag/EEFeatureFlagInterface.java | 51 + .../supertokens/featureflag/EE_FEATURES.java | 41 + .../supertokens/featureflag/FeatureFlag.java | 148 ++ .../featureflag/FeatureFlagTestContent.java | 51 + .../InvalidLicenseKeyException.java | 27 + .../NoLicenseKeyFoundException.java | 20 + .../io/supertokens/webserver/Webserver.java | 2 + .../supertokens/webserver/WebserverAPI.java | 4 +- .../webserver/api/core/EEFeatureFlagAPI.java | 63 + .../webserver/api/core/LicenseKeyAPI.java | 96 ++ .../io/supertokens/test/FeatureFlagTest.java | 114 ++ src/test/java/io/supertokens/test/Utils.java | 13 +- 57 files changed, 4092 insertions(+), 189 deletions(-) create mode 100644 ee/LICENSE.md create mode 100644 ee/build.gradle create mode 100644 ee/jar/ee.jar create mode 100755 ee/runBuild create mode 100644 ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java create mode 100644 ee/src/main/java/io/supertokens/ee/cronjobs/EELicenseCheck.java create mode 100644 ee/src/main/resources/META-INF/services/io.supertokens.featureflag.EEFeatureFlagInterface create mode 100644 ee/src/test/java/io/supertokens/ee/test/CronjobTest.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/EETest.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/ProcessConsumer.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/Retry.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/TestingProcessManager.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/TestingProcessManagerException.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/Utils.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/api/DeleteLicenseKeyAPITest.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/api/GetFeatureFlagAPITest.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/api/GetLicenseKeyAPITest.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/api/SetLicenseKeyAPITest.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/httpRequest/HttpRequestForTesting.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/httpRequest/HttpRequestMocking.java create mode 100644 ee/src/test/java/io/supertokens/ee/test/httpRequest/HttpResponseException.java create mode 100644 src/main/java/io/supertokens/featureflag/EEFeatureFlagInterface.java create mode 100644 src/main/java/io/supertokens/featureflag/EE_FEATURES.java create mode 100644 src/main/java/io/supertokens/featureflag/FeatureFlag.java create mode 100644 src/main/java/io/supertokens/featureflag/FeatureFlagTestContent.java create mode 100644 src/main/java/io/supertokens/featureflag/exceptions/InvalidLicenseKeyException.java create mode 100644 src/main/java/io/supertokens/featureflag/exceptions/NoLicenseKeyFoundException.java create mode 100644 src/main/java/io/supertokens/webserver/api/core/EEFeatureFlagAPI.java create mode 100644 src/main/java/io/supertokens/webserver/api/core/LicenseKeyAPI.java create mode 100644 src/test/java/io/supertokens/test/FeatureFlagTest.java diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0eedb6948..294f35e52 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,29 +1,40 @@ ## Summary of change + (A few sentences about this PR) ## Related issues + - Link to issue1 here - Link to issue1 here ## Test Plan -(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!) + +(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your +changes work. Bonus points for screenshots and videos!) ## Documentation changes -(If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) + +(If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here +highlighting the necessary changes) ## Checklist for important updates + - [ ] Changelog has been updated - [ ] If there are any db schema changes, mention those changes clearly - [ ] `coreDriverInterfaceSupported.json` file has been updated (if needed) - [ ] `pluginInterfaceSupported.json` file has been updated (if needed) - [ ] Changes to the version if needed - - In `build.gradle` + - In `build.gradle` +- [ ] If added a new paid feature, edit the `getPaidFeatureStats` function in FeatureFlag.java file - [ ] Had installed and ran the pre-commit hook -- [ ] If there are new dependencies that have been added in `build.gradle`, please make sure to add them in `implementationDependencies.json`. +- [ ] If there are new dependencies that have been added in `build.gradle`, please make sure to add them + in `implementationDependencies.json`. - [ ] Issue this PR against the latest non released version branch. - - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. - - If no such branch exists, then create one from the latest released branch. + - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the + latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. + - If no such branch exists, then create one from the latest released branch. ## Remaining TODOs for this PR + - [ ] Item1 - [ ] Item2 diff --git a/.gitignore b/.gitignore index 9ab70cb65..977eb3fb8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ gradle-app.setting !jar/**/*.jar !cli/jar/**/*.jar !downloader/jar/**/*.jar +!ee/jar/**/*.jar *target* *.war diff --git a/CHANGELOG.md b/CHANGELOG.md index 62115c71c..23dfc0819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [unreleased] +## [4.3.0] - 2023-01-05 + +- Adds feature flag, ee folder and APIs to add / remove license keys for enterprise features. + ## [4.2.1] - 2022-11-24 - Updates the type of `access_token_validity` in the CoreConfig from `int` to `long` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d67f52556..440a1554f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,119 +1,154 @@ # Contributing -We're so excited you're interested in helping with SuperTokens! We are happy to help you get started, even if you don't have any previous open-source experience :blush: +We're so excited you're interested in helping with SuperTokens! We are happy to help you get started, even if you don't +have any previous open-source experience :blush: ## New to Open Source? -1. Take a look at [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github) -2. Go through the [SuperTokens Code of Conduct](https://github.com/supertokens/supertokens-core/blob/master/CODE_OF_CONDUCT.md) + +1. Take a look + at [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github) +2. Go through + the [SuperTokens Code of Conduct](https://github.com/supertokens/supertokens-core/blob/master/CODE_OF_CONDUCT.md) ## Where to ask Questions? -1. Check our [Github Issues](https://github.com/supertokens/supertokens-core/issues) to see if someone has already answered your question. -2. Join our community on [Discord](https://supertokens.io/discord) and feel free to ask us your questions -As you gain experience with SuperTokens, please help answer other people's questions! :pray: +1. Check our [Github Issues](https://github.com/supertokens/supertokens-core/issues) to see if someone has already + answered your question. +2. Join our community on [Discord](https://supertokens.io/discord) and feel free to ask us your questions + +As you gain experience with SuperTokens, please help answer other people's questions! :pray: ## What to Work On? + You can get started by taking a look at our [Github issues](https://github.com/supertokens/supertokens-core/issues) -If you find one that looks interesting and no one else is already working on it, comment in the issue that you are going to work on it. +If you find one that looks interesting and no one else is already working on it, comment in the issue that you are going +to work on it. -Please ask as many questions as you need, either directly in the issue or on [Discord](https://supertokens.io/discord). We're happy to help!:raised_hands: +Please ask as many questions as you need, either directly in the issue or on [Discord](https://supertokens.io/discord). +We're happy to help!:raised_hands: -### Contributions that are ALWAYS welcome +### Contributions that are ALWAYS welcome 1. More tests -2. Contributing to discussions that can be found [here](https://github.com/supertokens/supertokens-core/issues?q=is%3Aissue+is%3Aopen+label%3Adiscussions) +2. Contributing to discussions that can be + found [here](https://github.com/supertokens/supertokens-core/issues?q=is%3Aissue+is%3Aopen+label%3Adiscussions) 3. Improved error messages 4. Educational content like blogs, videos, courses - ## Development Setup ### With Gitpod + 1. Navigate to the [supertokens-root](https://github.com/supertokens/supertokens-root) repository 2. Click on the `Open in Gitpod` button ### Local Setup Prerequisites + - OS: Linux or macOS. Or if using Windows, you need to use [wsl2](https://docs.microsoft.com/en-us/windows/wsl/about). -- JDK: openjdk 15.0.1. Installation instructions for Mac and Linux can be found in [our wiki](https://github.com/supertokens/supertokens-core/wiki/Installing-OpenJDK-for-Mac-and-Linux) +- JDK: openjdk 15.0.1. Installation instructions for Mac and Linux can be found + in [our wiki](https://github.com/supertokens/supertokens-core/wiki/Installing-OpenJDK-for-Mac-and-Linux) - IDE: [IntelliJ](https://www.jetbrains.com/idea/download/)(recommended) or equivalent IDE ### Familiarize yourself with SuperTokens + 1. [Architecture of SuperTokens](https://github.com/supertokens/supertokens-core/wiki/SuperTokens-Architecture) 2. [SuperTokens code and file structure overview](https://github.com/supertokens/supertokens-core/wiki/Code-and-file-structure-overview) 3. [Versioning methodology](https://github.com/supertokens/supertokens-core/wiki/Versioning,-git-and-releases) - ### Project Setup -1. Fork the [supertokens-core](https://github.com/supertokens/supertokens-core) repository (**Skip this step if you are NOT modifying supertokens-core**) + +1. Fork the [supertokens-core](https://github.com/supertokens/supertokens-core) repository (**Skip this step if you are + NOT modifying supertokens-core**) 2. `git clone https://github.com/supertokens/supertokens-root.git` 3. `cd supertokens-root` 4. Open the `modules.txt` file in an editor (**Skip this step if you are NOT modifying supertokens-core**): - - The `modules.txt` file contains the core, plugin-interface, the type of plugin and their branches(versions) - - By default the `master` branch is used but you can change the branch depending on which version you want to modify + - The `modules.txt` file contains the core, plugin-interface, the type of plugin and their branches(versions) + - By default the `master` branch is used but you can change the branch depending on which version you want to modify - The `sqlite-plugin` is used as the default plugin as it is an in-memory database and requires no setup - - [core](https://github.com/supertokens/supertokens-core) - - [plugin-interface](https://github.com/supertokens/supertokens-plugin-interface) - - Check the repository branches by clicking on the links listed above, click the branch tab and check for all the available versions + - [core](https://github.com/supertokens/supertokens-core) + - [plugin-interface](https://github.com/supertokens/supertokens-plugin-interface) + - Check the repository branches by clicking on the links listed above, click the branch tab and check for all + the available versions - Add your github `username` separated by a ',' after `core,master` in `modules.txt` - - If, for example, your github `username` is `helloworld` then modules.txt should look like... + - If, for example, your github `username` is `helloworld` then modules.txt should look like... ``` // put module name like module name,branch name,github username(if contributing with a forked repository) and then call ./loadModules script core,master,helloworld plugin-interface,master sqlite-plugin,master ``` - -5. Run loadModules to clone the required repositories -`./loadModules` +5. Run loadModules to clone the required repositories + `./loadModules` ## Modifying code + 1. Open `supetokens-root` in your IDE -2. After gradle has imported all the dependencies you can start modifying the code +2. After gradle has imported all the dependencies you can start modifying the code -## Testing +## Testing ### On your local machine -1. Navigate to the `supertokens-root` repository + +1. Navigate to the `supertokens-root` repository 2. Run all tests -`./startTestEnv` -3. If all tests pass the terminal should display + `./startTestEnv` +3. If all tests pass the terminal should display + - core tests: -![core tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/core-tests-passing.png) + ![core tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/core-tests-passing.png) - plugin tests: -![plugin tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/plugin-tests-passing.png) + ![plugin tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/plugin-tests-passing.png) ### Using github actions + 1. Go to the supertokens-core repo on github (or your forked version of it). 2. Navigate to the Actions tab. 3. Find the action named "Run tests" and navigate to it. 4. Click on the "Run workflow" button. 5. Set the config variables in the drop down: - - **supertokens-plugin-interface repo owner name**: If you have forked the supertokens-plugin-interface repo, then set the value of this to your github username. - - **supertokens-plugin-interface repos branch name**: If the core version you are working on is compatible with a plugin-interface version that is not in the master branch, then set the correct branch name in this value. + - **supertokens-plugin-interface repo owner name**: If you have forked the supertokens-plugin-interface repo, then + set the value of this to your github username. + - **supertokens-plugin-interface repos branch name**: If the core version you are working on is compatible with a + plugin-interface version that is not in the master branch, then set the correct branch name in this value. 6. Click on "Run workflow". ## Running the core manually + 1. Run `startTestEnv --wait` in a terminal, and keep it running 2. Then open `supertokens-root` in another terminal and run `cp ./temp/config.yaml .` -3. Then run `java -classpath "./core/*:./plugin-interface/*" io.supertokens.Main ./ DEV`. This will start the core to listen on `http://localhost:3567` +3. Then run `java -classpath "./core/*:./plugin-interface/*:./ee/*" io.supertokens.Main ./ DEV`. This will start the + core to listen on `http://localhost:3567` ## Pull Request -1. Before submitting a pull request make sure all tests have passed -2. Reference the relevant issue or pull request and give a clear description of changes/features added when submitting a pull request + +1. Before submitting a pull request make sure all tests have passed +2. Reference the relevant issue or pull request and give a clear description of changes/features added when submitting a + pull request 3. Make sure the PR title follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) specification -## SuperTokens Community -SuperTokens is made possible by a passionate team and a strong community of developers. If you have any questions or would like to get more involved in the SuperTokens community you can check out: - - [Github Issues](https://github.com/supertokens/supertokens-core/issues) - - [Discord](https://supertokens.io/discord) - - [Twitter](https://twitter.com/supertokensio) - - or [email us](mailto:team@supertokens.io) - +## Install the supertokens CLI manually + +1. Setup test env and keep it running +2. In `supertokens-root`, run `cp temp/config.yaml .` +3. On a different terminal, go to `supertokens-root` folder and + run `java -classpath "./cli/*" io.supertokens.cli.Main true install` + +## SuperTokens Community + +SuperTokens is made possible by a passionate team and a strong community of developers. If you have any questions or +would like to get more involved in the SuperTokens community you can check out: + +- [Github Issues](https://github.com/supertokens/supertokens-core/issues) +- [Discord](https://supertokens.io/discord) +- [Twitter](https://twitter.com/supertokensio) +- or [email us](mailto:team@supertokens.io) + Additional resources you might find useful: - - [SuperTokens Docs](https://supertokens.io/docs/community/getting-started/installation) - - [Blog Posts](https://supertokens.io/blog/) - - [Development guideline for the backend and frontend recipes](https://github.com/supertokens/supertokens-core/wiki/Development-guideline-for-the-backend-and-frontend-recipes) + +- [SuperTokens Docs](https://supertokens.io/docs/community/getting-started/installation) +- [Blog Posts](https://supertokens.io/blog/) +- [Development guideline for the backend and frontend recipes](https://github.com/supertokens/supertokens-core/wiki/Development-guideline-for-the-backend-and-frontend-recipes) diff --git a/LICENSE.md b/LICENSE.md index c6b6ccb24..728963a30 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,3 +1,12 @@ +Portions of this software are licensed as follows: + +* All content that resides under the "ee/" directory of this repository, if that directory exists, is licensed under the + license defined in "ee/LICENSE.md". +* All third party components incorporated into the SuperTokens Software are licensed under the original license provided + by the owner of the applicable component. +* Content outside of the above mentioned directories or restrictions above is available under the "Apache 2.0" + license as defined below. + Apache License Version 2.0, January 2004 @@ -176,7 +185,7 @@ END OF TERMS AND CONDITIONS - Copyright 2020 SuperTokens, Inc. + Copyright 2020-2023 SuperTokens, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -188,4 +197,4 @@ 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. + limitations under the License. \ No newline at end of file diff --git a/build.gradle b/build.gradle index b52a52529..fe8e62519 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ compileTestJava { options.encoding = "UTF-8" } // } //} -version = "4.2.1" +version = "4.3.0" repositories { @@ -29,6 +29,7 @@ repositories { dependencies { // https://mvnrepository.com/artifact/com.google.code.gson/gson + // if this changes, remember to also change in the ee folder's build.gradle implementation group: 'com.google.code.gson', name: 'gson', version: '2.3.1' // https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml diff --git a/cli/src/main/java/io/supertokens/cli/Main.java b/cli/src/main/java/io/supertokens/cli/Main.java index 6a65ba972..a9b5b2775 100644 --- a/cli/src/main/java/io/supertokens/cli/Main.java +++ b/cli/src/main/java/io/supertokens/cli/Main.java @@ -71,8 +71,8 @@ public static void main(String[] args) { } // java -classpath "./cli/*" io.supertokens.cli.Main - // - args: true [--path ] --> via installer is true - // - args: false <...command args> + // - args: true [--path ] --> via installer is true + // - args: false <...command args> private static void start(String[] args) { boolean viaInstaller = Boolean.parseBoolean(args[0]); String installationDir; @@ -82,18 +82,16 @@ private static void start(String[] args) { if (viaInstaller) { installationDir = "ignored"; command = "install"; - options = java.util.Arrays.stream(args, 1, args.length) - .toArray(String[]::new); + options = java.util.Arrays.stream(args, 1, args.length).toArray(String[]::new); } else { installationDir = args[1]; if (args.length == 2) { - args = new String[]{args[0], args[1], "--help"}; + args = new String[] { args[0], args[1], "--help" }; } command = args[2]; - options = java.util.Arrays.stream(args, 3, args.length) - .toArray(String[]::new); + options = java.util.Arrays.stream(args, 3, args.length).toArray(String[]::new); } initCommandHandlers(); @@ -103,8 +101,8 @@ private static void start(String[] args) { handler.handleCommand(installationDir, viaInstaller, options); } } else { - throw new QuitProgramException("Unknown command '" + command + - "'. Please use \"supertokens --help\" to see the list of available commands", null); + throw new QuitProgramException("Unknown command '" + command + + "'. Please use \"supertokens --help\" to see the list of available commands", null); } } diff --git a/cli/src/main/java/io/supertokens/cli/Utils.java b/cli/src/main/java/io/supertokens/cli/Utils.java index c56688d44..7a34e5f56 100644 --- a/cli/src/main/java/io/supertokens/cli/Utils.java +++ b/cli/src/main/java/io/supertokens/cli/Utils.java @@ -49,10 +49,9 @@ public static void copyFolderOrFile(File sourceFolder, File destinationFolder) t try { Files.copy(sourceFolder.toPath(), destinationFolder.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (AccessDeniedException e) { - throw new QuitProgramException( - "Moving content to installation location failed. Try again with" + - ((OperatingSystem.getOS() == OperatingSystem.OS.WINDOWS) ? " root permissions." : - " sudo."), null); + throw new QuitProgramException("Moving content to installation location failed. Try again with" + + ((OperatingSystem.getOS() == OperatingSystem.OS.WINDOWS) ? " root permissions." : " sudo."), + null); } } } @@ -61,10 +60,9 @@ private static void createAllDirs(File destinationFolder) { if (destinationFolder != null && !destinationFolder.exists()) { boolean success = destinationFolder.mkdirs(); if (!success) { - throw new QuitProgramException( - "Moving content to installation location failed. Try again with" + - ((OperatingSystem.getOS() == OperatingSystem.OS.WINDOWS) ? " root permissions." : - " sudo."), null); + throw new QuitProgramException("Moving content to installation location failed. Try again with" + + ((OperatingSystem.getOS() == OperatingSystem.OS.WINDOWS) ? " root permissions." : " sudo."), + null); } } } @@ -105,7 +103,6 @@ public static String formatWithFixedSpaces(String first, String second, int seco spaces.append(" ".repeat(Math.max(0, numberOfSpaces))); String actual = first + spaces + second; - StringBuilder maxSpaces = new StringBuilder(); maxSpaces.append(" ".repeat(Math.max(0, secondStart))); String[] splittedString = actual.split(" "); diff --git a/cli/src/main/java/io/supertokens/cli/commandHandler/hashingCalibrate/HashingCalibrateHandler.java b/cli/src/main/java/io/supertokens/cli/commandHandler/hashingCalibrate/HashingCalibrateHandler.java index d25d70dba..ca10b5b76 100644 --- a/cli/src/main/java/io/supertokens/cli/commandHandler/hashingCalibrate/HashingCalibrateHandler.java +++ b/cli/src/main/java/io/supertokens/cli/commandHandler/hashingCalibrate/HashingCalibrateHandler.java @@ -71,9 +71,9 @@ protected void doCommand(String installationDir, boolean viaInstaller, String[] Logging.error(""); Logging.error("====FAILED===="); Logging.error( - "Optimal Argon2 settings could not be calculated. Try increasing the amount of memory given " + - "(using --with_argon2_max_memory_mb), or reducing the amount of concurrent hashing " + - "(using --with_argon2_hashing_pool_size)"); + "Optimal Argon2 settings could not be calculated. Try increasing the amount of memory given " + + "(using --with_argon2_max_memory_mb), or reducing the amount of concurrent hashing " + + "(using --with_argon2_hashing_pool_size)"); } } else { Logging.error("Please provide one of --with_alg=argon2 or --with_alg=bcrypt"); @@ -86,19 +86,18 @@ protected List