88import javafx .stage .Stage ;
99import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
1010
11+ import java .io .FileNotFoundException ;
12+ import java .io .FileOutputStream ;
13+ import java .io .PrintStream ;
14+
1115public class SystemLogAnalyzerApp extends Application {
1216
17+ private boolean app_Log = false ;
18+
1319 private AnnotationConfigApplicationContext springContext ;
1420
21+ private static Boolean elevatedFlag = false ; // Admin permissions
22+
1523 @ Override
1624 public void init () {
1725 springContext = new AnnotationConfigApplicationContext (SpringConfig .class );
26+
27+ if (app_Log ) { // debug app.log in main directory
28+ PrintStream out = null ;
29+ try {
30+ out = new PrintStream (new FileOutputStream ("app.log" , true ), true );
31+ } catch (FileNotFoundException e ) {
32+ throw new RuntimeException (e );
33+ }
34+ System .setOut (out );
35+ System .setErr (out );
36+ }
37+
38+
39+
1840 }
1941
2042 @ Override
2143 public void start (Stage primaryStage ) throws Exception {
2244 FXMLLoader loader = new FXMLLoader (getClass ().getResource ("/view/WelcomeView.fxml" ));
2345 loader .setControllerFactory (springContext ::getBean );
2446
25- Parent root = loader .load ();
47+ boolean elevated = getParameters ().getRaw ().contains ("--elevated" );
48+ elevatedFlag = elevated ; // Admin profile checker
2649
50+ System .out .println ("ARGS = " + getParameters ().getRaw ()); // Admin permission check to debug file
51+
52+ com .project .system_log_analyzer .config .appConfig cfg = springContext .getBean (com .project .system_log_analyzer .config .appConfig .class );
53+
54+ if (elevated ) {
55+ cfg .setCsvSecurity (true );
56+ }
57+
58+ try {
59+ cfg .setCsvSecurity (elevated );
60+ IO .println ("Elevated mode: " + elevated );
61+ } catch (Exception e ) {
62+ System .err .println ("Could not set elevated flag in appConfig: " + e .getMessage ());
63+ }
64+
65+ Parent root = loader .load ();
2766 SpringConfig .APP_READY = true ;
2867
2968 Scene scene = new Scene (root );
@@ -37,6 +76,10 @@ public void stop() {
3776 springContext .close ();
3877 }
3978
79+ public static boolean isElevated () {
80+ return Boolean .TRUE .equals (elevatedFlag );
81+ }
82+
4083 public static void main (String [] args ) {
4184 launch (args );
4285 }
0 commit comments