blob: b2f426e4fa22fb6921b583cde9b898f73eb8c924 (
plain)
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
|
package pl.edu.mimuw.cloudatlas.querysigner;
import pl.edu.mimuw.cloudatlas.querysignerapi.QuerySignerApi;
import java.io.IOException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.security.PrivateKey;
import java.security.PublicKey;
public class QuerySigner {
public static class InvalidQueryException extends Exception {
InvalidQueryException() {
super("Query invalid");
}
}
public static QuerySignerApiImplementation initApi() throws IOException {
String publicKeyFile = System.getProperty("public_key_file");
String privateKeyFile = System.getProperty("private_key_file");
PublicKey publicKey = KeyUtils.getPublicKey(publicKeyFile);
PrivateKey privateKey = KeyUtils.getPrivateKey(privateKeyFile);
return new QuerySignerApiImplementation(publicKey, privateKey);
}
public static void runRegistry() {
try {
QuerySignerApiImplementation api = initApi();
QuerySignerApi apiStub =
(QuerySignerApi) UnicastRemoteObject.exportObject(api, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind("QuerySignerApi", apiStub);
System.out.println("QuerySigner: api bound");
} catch (Exception e) {
System.err.println("QuerySigner registry initialization exception:");
e.printStackTrace();
}
}
public static void main(String[] args) {
runRegistry();
}
}
|