-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
144 lines (133 loc) · 5.14 KB
/
Copy pathMain.java
File metadata and controls
144 lines (133 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import java.util.Scanner;
public final class Main {
public static AuthlyX AuthlyXApp = new AuthlyX(
envOrDefault("AUTHLYX_OWNER_ID", "b49d11af8c42"),
envOrDefault("AUTHLYX_APP_NAME", "TEST"),
envOrDefault("AUTHLYX_VERSION", "1.3"),
envOrDefault("AUTHLYX_SECRET", "1L0edLKqHlFv0AL3NIQ7uPpikN2ECr7aZSHrNWMo"),
true,
envOrDefault("AUTHLYX_API", "https://authly.cc/api/v2")
);
public static void main(String[] args) {
System.out.println("==============================================");
System.out.println(" AUTHLYX JAVA EXAMPLE ");
System.out.println("==============================================");
System.out.println();
System.out.println("Initializing AuthlyX connection...");
boolean ok = AuthlyXApp.Init();
if (!ok) {
System.out.println("Init failed: " + AuthlyXApp.response.message);
waitKey();
return;
}
System.out.println("Init success.");
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println();
System.out.println("1. Username + Password Login");
System.out.println("2. License Login");
System.out.println("3. Device Login");
System.out.println("4. Get Variable");
System.out.println("5. Set Variable");
System.out.println("6. Validate Session");
System.out.println("7. Show User Info");
System.out.println("0. Exit");
System.out.print("Choice: ");
String choice = sc.nextLine().trim();
if ("0".equals(choice)) break;
switch (choice) {
case "1": {
System.out.print("Username: ");
String u = sc.nextLine();
System.out.print("Password: ");
String p = sc.nextLine();
boolean r = AuthlyXApp.Login(u, p, null);
System.out.println(r ? "Login SUCCESS" : "Login FAILED");
System.out.println("Message: " + AuthlyXApp.response.message);
break;
}
case "2": {
System.out.print("License Key: ");
String k = sc.nextLine();
boolean r = AuthlyXApp.Login(k);
System.out.println(r ? "Login SUCCESS" : "Login FAILED");
System.out.println("Message: " + AuthlyXApp.response.message);
break;
}
case "3": {
System.out.print("Device Type (motherboard/processor): ");
String t = sc.nextLine();
System.out.print("Device ID: ");
String id = sc.nextLine();
boolean r = AuthlyXApp.Login(id, null, t);
System.out.println(r ? "Login SUCCESS" : "Login FAILED");
System.out.println("Message: " + AuthlyXApp.response.message);
break;
}
case "4": {
System.out.print("Var key: ");
String k = sc.nextLine();
String v = AuthlyXApp.GetVariable(k);
System.out.println("Value: " + v);
break;
}
case "5": {
System.out.print("Var key: ");
String k = sc.nextLine();
System.out.print("Var value: ");
String v = sc.nextLine();
boolean r = AuthlyXApp.SetVariable(k, v);
System.out.println(r ? "SetVariable SUCCESS" : "SetVariable FAILED");
System.out.println("Message: " + AuthlyXApp.response.message);
break;
}
case "6": {
boolean r = AuthlyXApp.ValidateSession();
System.out.println(r ? "ValidateSession SUCCESS" : "ValidateSession FAILED");
System.out.println("Message: " + AuthlyXApp.response.message);
break;
}
case "7": {
printUserInfo();
break;
}
default:
System.out.println("Invalid choice.");
}
}
System.out.println("Bye.");
}
private static void printUserInfo() {
AuthlyX.UserData u = AuthlyXApp.userData;
System.out.println();
System.out.println("==================================================");
System.out.println("USER PROFILE");
System.out.println("==================================================");
System.out.println("Username: " + na(u.Username));
System.out.println("Email: " + na(u.Email));
System.out.println("License Key: " + na(u.LicenseKey));
System.out.println("Subscription: " + na(u.Subscription));
System.out.println("Subscription Level: " + na(u.SubscriptionLevel));
System.out.println("Expiry Date: " + na(u.ExpiryDate));
System.out.println("Days Left: " + u.DaysLeft);
System.out.println("Last Login: " + na(u.LastLogin));
System.out.println("Registered At: " + na(u.RegisteredAt));
System.out.println("HWID/SID: " + na(u.Hwid));
System.out.println("IP Address: " + na(u.IpAddress));
System.out.println("==================================================");
}
private static String na(String s) {
return (s == null || s.isBlank()) ? "N/A" : s;
}
private static void waitKey() {
System.out.println("Press Enter to exit...");
try {
new Scanner(System.in).nextLine();
} catch (Exception ignored) {
}
}
private static String envOrDefault(String name, String fallback) {
String value = System.getenv(name);
return (value == null || value.isBlank()) ? fallback : value;
}
}