Skip to content

Commit ca9ea64

Browse files
gaynor@illinois.edugaynor@illinois.edu
authored andcommitted
Rename of classes
1 parent 936a351 commit ca9ea64

54 files changed

Lines changed: 361 additions & 324 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/artifacts/unnamed.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 87 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<module>util</module>
5050
<module>servlet</module>
5151
<module>storage</module>
52-
<module>sat-server</module>
52+
<module>sas-server</module>
5353
</modules>
5454
<build>
5555
<plugins>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>sat-server</artifactId>
13-
14-
<packaging>war</packaging>
12+
<artifactId>sas-server</artifactId>
13+
<name>Secure API Service</name>
14+
<!--<packaging>war</packaging>-->
1515

1616
<properties>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

sat-server/src/main/java/edu/uiuc/ncsa/sat/Client.java renamed to sas-server/src/main/java/edu/uiuc/ncsa/sas/Client.java

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package edu.uiuc.ncsa.sat;
1+
package edu.uiuc.ncsa.sas;
22

33
import edu.uiuc.ncsa.security.core.Identifier;
44
import edu.uiuc.ncsa.security.core.exceptions.GeneralException;
@@ -12,7 +12,6 @@
1212
import edu.uiuc.ncsa.security.util.crypto.KeyUtil;
1313
import edu.uiuc.ncsa.security.util.jwk.JSONWebKey;
1414
import edu.uiuc.ncsa.security.util.jwk.JSONWebKeyUtil;
15-
import edu.uiuc.ncsa.security.util.jwk.JSONWebKeys;
1615
import edu.uiuc.ncsa.security.util.ssl.SSLConfiguration;
1716
import net.sf.json.JSONObject;
1817
import org.apache.commons.codec.binary.Base64;
@@ -36,7 +35,7 @@
3635
* <p>Created by Jeff Gaynor<br>
3736
* on 8/18/22 at 3:14 PM
3837
*/
39-
public class Client extends ServiceClient implements SATConstants {
38+
public class Client extends ServiceClient implements SASConstants {
4039

4140
public Client(URI address, SSLConfiguration sslConfiguration) {
4241
super(address, sslConfiguration);
@@ -46,7 +45,7 @@ public Client(URI address) {
4645
super(address);
4746
}
4847

49-
public static final String FLAG_NEW = "-edit";
48+
public static final String FLAG_EDIT = "-edit";
5049
public static final String FLAG_CONFIG = "-cfg"; // name of config file
5150
public static final String FLAG_HELP = "--help"; // help
5251
public static final String FLAG_VERBOSE = "-v"; // help
@@ -74,6 +73,7 @@ public static void say(Object x) {
7473

7574
/**
7675
* Read a single line
76+
*
7777
* @return
7878
* @throws IOException
7979
*/
@@ -106,6 +106,7 @@ protected static XMLMap readConfig(String fileName) throws IOException {
106106
return map;
107107
}
108108

109+
109110
/*
110111
-cfg path.properties is config
111112
-type is type.
@@ -116,7 +117,7 @@ protected static void createConfig(String filename) throws IOException {
116117
xmlMap.put(CONFIG_CLIENT_ID, getInput("enter client id"));
117118
say("enter private key, PKCS 8 or a single JWK");
118119
String x = multiLineInput("", CONFIG_PRIVATE_KEY);
119-
xmlMap.put(CONFIG_PRIVATE_KEY, x);
120+
xmlMap.put(CONFIG_PRIVATE_KEY, x.trim()); // If a JWK, any leading blanks will cause JSON library to fail.
120121
xmlMap.put(CONFIG_HOST, getInput("enter server address"));
121122

122123
if ("y".equals(getInput("enter ssl configuration (y/n)?"))) {
@@ -142,48 +143,36 @@ protected static void createConfig(String filename) throws IOException {
142143
}
143144
}
144145

145-
/*
146-
SSLConfiguration sslConfiguration = new SSLConfiguration();
147-
sslConfiguration.setTrustRootPath("/home/ncsa/certs/localhost-2020.jks");
148-
sslConfiguration.setTrustRootPassword("vnlH814i");
149-
sslConfiguration.setTrustRootType("JKS");
150-
sslConfiguration.setTrustRootCertDN("CN=localhost");
151-
sslConfiguration.setUseDefaultTrustManager(false);
152-
153-
Client client = new Client(URI.create("https://localhost:9443/sat-server/sat"), sslConfiguration);
154-
JSONWebKeys keys = JSONWebKeyUtil.fromJSON(new File("/home/ncsa/dev/ncsa-git/security-lib/crypto/src/main/resources/keys.jwk"));
155-
keys.setDefaultKeyID("2D700DF531E09B455B9E74D018F9A133"); // for testing!
156-
client.setKeys(keys);
157-
client.doLogon(BasicIdentifier.newID("sat:client/debug_client"));
158-
client.doExecute("w00f!");
159-
client.doLogoff();
160146

161-
*/
162147
public static void main(String[] args) throws Throwable {
163-
JSONWebKeys keys = JSONWebKeyUtil.fromJSON(new File("/home/ncsa/dev/ncsa-git/security-lib/crypto/src/main/resources/keys.jwk"));
164-
keys.setDefaultKeyID("2D700DF531E09B455B9E74D018F9A133"); // for testing!
165-
System.out.println(JSONWebKeyUtil.toJSON(keys));
166148
Vector<String> vector = new Vector<>();
167149
vector.add("dummy"); // Dummy zero-th arg.
168150
for (String arg : args) {
169151
vector.add(arg);
170152
}
171153
InputLine inputLine = new InputLine(vector); // now we have a bunch of utilities for this
172-
154+
if (inputLine.hasArg(FLAG_HELP)) {
155+
showHelp();
156+
return;
157+
}
173158
boolean isVerbose = inputLine.hasArg(FLAG_VERBOSE);
159+
if (inputLine.hasArg(FLAG_EDIT)) {
160+
if (inputLine.hasArg(FLAG_CONFIG)) {
161+
File f = new File(inputLine.getNextArgFor(FLAG_CONFIG));
162+
if (!f.exists()) {
163+
if ("y".equals(getInput("Create a new configuration?"))) {
164+
createConfig(f.getAbsolutePath());
165+
return;
166+
}
167+
}
168+
}
174169

170+
}
175171
if (!inputLine.hasArg(FLAG_CONFIG)) {
176-
if ("y".equals(getInput("Create a new configuration?"))) {
177-
createConfig(null);
178-
return;
179-
}
180172
say("No configuration. exiting...");
181173
}
182174

183-
if (inputLine.hasArg(FLAG_HELP)) {
184-
showHelp();
185-
return;
186-
}
175+
187176
XMLMap config;
188177
if (inputLine.hasArg(FLAG_CONFIG)) {
189178
try {
@@ -200,15 +189,16 @@ public static void main(String[] args) throws Throwable {
200189
return;
201190
}
202191

192+
203193
SSLConfiguration sslConfiguration = new SSLConfiguration();
204194
sslConfiguration.setTrustRootPath(config.getString(CONFIG_TR_FILE));
205195
sslConfiguration.setTrustRootPassword(config.getString(CONFIG_TR_PASSWORD));
206196
sslConfiguration.setTrustRootType(config.getString(CONFIG_TR_TYPE));
207197
sslConfiguration.setTrustRootCertDN(config.getString(CONFIG_TR_DN));
208198
sslConfiguration.setUseDefaultTrustManager(false);
209199

210-
//Client client = new Client(URI.create("https://localhost:9443/sat-server/sat"), sslConfiguration);
211200
Client client = new Client(URI.create(config.getString(CONFIG_HOST)), sslConfiguration);
201+
client.setConfig(config);
212202
String rawKey = config.getString(CONFIG_PRIVATE_KEY);
213203
PrivateKey privateKey = null;
214204
try {
@@ -224,14 +214,48 @@ public static void main(String[] args) throws Throwable {
224214
return;
225215
}
226216
client.setPrivateKey(privateKey);
227-
client.doLogon(BasicIdentifier.newID(config.getString(CONFIG_CLIENT_ID)));
228-
//client.doLogon(BasicIdentifier.newID("sat:client/debug_client"));
229-
client.doExecute("w00f!");
230-
client.doLogoff();
217+
client.repl();
218+
}
219+
220+
public XMLMap getConfig() {
221+
return config;
222+
}
223+
224+
public void setConfig(XMLMap config) {
225+
this.config = config;
226+
}
227+
228+
XMLMap config;
229+
230+
protected void repl() throws Throwable {
231+
boolean doIt = true;
232+
while (doIt) {
233+
String lineIne = getInput("sas");
234+
switch (lineIne) {
235+
case "/q":
236+
return;
237+
case "/logon":
238+
doLogon(BasicIdentifier.newID(getConfig().getString(CONFIG_CLIENT_ID)));
239+
say("login complete");
240+
break;
241+
case "/logoff":
242+
doLogoff();
243+
say("logged off..");
244+
break;
245+
default:
246+
doExecute(lineIne);
247+
break;
248+
}
249+
}
231250
}
232251

233252
private static void showHelp() {
234-
say("Help for " + Client.class.getName());
253+
say(Client.class.getName() + " " + FLAG_CONFIG + " config_file {" + FLAG_EDIT + "} {" + FLAG_HELP + "} {" + FLAG_VERBOSE + "}");
254+
say(FLAG_CONFIG + " the name of an existing configuration file ");
255+
say(FLAG_EDIT + " edit existing file or update current ");
256+
say(FLAG_HELP + " display this help message ");
257+
say(FLAG_VERBOSE + " print more output about functioning of this. Mostly for debugging.");
258+
say("If you simply supply the " + FLAG_EDIT + " flag, you will be prompted to create a new configuration file.");
235259
}
236260

237261
UUID sessionID;
@@ -260,7 +284,7 @@ protected void doLogoff() throws Throwable {
260284
JSONObject sat = new JSONObject();
261285

262286
sat.put(KEYS_ACTION, ACTION_LOGOFF);
263-
top.put(SATConstants.KEYS_SAT, sat);
287+
top.put(SASConstants.KEYS_SAT, sat);
264288
String raw = doPost(top.toString());
265289
String jj = sDecrypt(raw);
266290
System.out.println(jj);

sat-server/src/main/java/edu/uiuc/ncsa/sat/EncryptionException.java renamed to sas-server/src/main/java/edu/uiuc/ncsa/sas/EncryptionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package edu.uiuc.ncsa.sat;
1+
package edu.uiuc.ncsa.sas;
22

33
import edu.uiuc.ncsa.security.core.exceptions.GeneralException;
44

sat-server/src/main/java/edu/uiuc/ncsa/sat/Executable.java renamed to sas-server/src/main/java/edu/uiuc/ncsa/sas/Executable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package edu.uiuc.ncsa.sat;
1+
package edu.uiuc.ncsa.sas;
22

3-
import edu.uiuc.ncsa.sat.thing.Action;
3+
import edu.uiuc.ncsa.sas.thing.Action;
44
import edu.uiuc.ncsa.security.util.cli.IOInterface;
55

66
/**

0 commit comments

Comments
 (0)