use of com.yahoo.athenz.zms.Access in project athenz by yahoo.
the class ZMSTLSClient method main.
public static void main(String[] args) {
// parse our command line to retrieve required input
CommandLine cmd = parseCommandLine(args);
final String resource = cmd.getOptionValue("resource").toLowerCase();
final String action = cmd.getOptionValue("action").toLowerCase();
final String principal = cmd.getOptionValue("principal").toLowerCase();
final String zmsUrl = cmd.getOptionValue("zmsurl");
final String keyPath = cmd.getOptionValue("key");
final String certPath = cmd.getOptionValue("cert");
final String trustStorePath = cmd.getOptionValue("trustStorePath");
final String trustStorePassword = cmd.getOptionValue("trustStorePassword");
try {
KeyRefresher keyRefresher = Utils.generateKeyRefresher(trustStorePath, trustStorePassword, certPath, keyPath);
SSLContext sslContext = Utils.buildSSLContext(keyRefresher.getKeyManagerProxy(), keyRefresher.getTrustManagerProxy());
try (ZMSClient zmsClient = new ZMSClient(zmsUrl, sslContext)) {
try {
Access access = zmsClient.getAccess(action, resource, null, principal);
System.out.println("Access: " + access.getGranted());
} catch (ZMSClientException ex) {
System.out.println("Unable to carry out access check: " + ex.getMessage());
System.exit(2);
}
}
} catch (Exception ex) {
System.out.println("Exception: " + ex.getMessage());
ex.printStackTrace();
System.exit(1);
}
}
Aggregations