View Javadoc
1   /*
2    * Copyright (c) Patrick Magauran 2018.
3    *   Licensed under the AGPLv3. All conditions of said license apply.
4    *       This file is part of ABOS.
5    *
6    *       ABOS is free software: you can redistribute it and/or modify
7    *       it under the terms of the GNU Affero General Public License as published by
8    *       the Free Software Foundation, either version 3 of the License, or
9    *       (at your option) any later version.
10   *
11   *       ABOS is distributed in the hope that it will be useful,
12   *       but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   *       GNU Affero General Public License for more details.
15   *
16   *       You should have received a copy of the GNU Affero General Public License
17   *       along with ABOS.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  import Exceptions.AccessException;
21  import Utilities.DbInt;
22  import javafx.application.Application;
23  import javafx.stage.Stage;
24  import javafx.util.Pair;
25  
26  import java.util.Map;
27  
28  @SuppressWarnings("UseOfSystemOutOrSystemErr")
29  public class addFlyWay extends Application {
30      public static void main(String[] args) { launch(args); }
31  
32      @Override
33      public void start(final Stage stage) {
34          Map<String, String> params = getParameters().getNamed();
35          if (params.containsKey("username") && params.containsKey("password")) {
36              if (!DbInt.verifyLoginAndUser(new Pair<>(params.get("username"), params.get("password")))) {
37                  System.out.println("Error Logging in");
38                  System.exit(0);
39  
40              }
41  
42          }
43          DbInt.getDatabses().forEach((db) -> {
44              try {
45                  DbInt.baselineDatabse(db);
46              } catch (AccessException ignored) {
47                  System.out.println("You must be admin");
48                  System.exit(0);
49              }
50          });
51          System.exit(0);
52  
53      }
54  }