-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGenerateApiKey.java
More file actions
47 lines (35 loc) · 886 Bytes
/
GenerateApiKey.java
File metadata and controls
47 lines (35 loc) · 886 Bytes
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
// GenerateApiKey.java
// Bobby Krupczak
// javac -cp ./core-0.2.5-SNAPSHOT.jar GenerateApiKey.java
// java -cp .:./core-0.2.5-SNAPSHOT.jar GenerateApiKey
import org.json.JSONObject;
import com.openathena.core.ApiKey;
public class GenerateApiKey
{
public static void usage()
{
System.out.println("GenerateApiKey: [user|admin] organization contact-email");
System.exit(-1);
}
public static void main(String[] args)
{
if (args.length == 0) {
usage();
}
String permission = args[0];
if ((args[0].equals("user") == false) &&
(args[0].equals("admin") == false)) {
usage();
}
String org = args[1];
String email = args[2];
if (email.indexOf('@') == -1) {
usage();
}
ApiKey key = new ApiKey();
key.permission = permission;
key.organization = org;
key.contact = email;
System.out.println(key.toJSON().toString());
}
}