use of com.yahoo.athenz.common.config.AthenzConfig in project athenz by yahoo.
the class FilePublicKeyStore method init.
public void init() {
String rootDir = System.getenv("ROOT");
if (rootDir == null) {
rootDir = "/home/athenz";
}
String confFileName = System.getProperty(ZpeConsts.ZPE_PROP_ATHENZ_CONF, rootDir + ZPE_ATHENZ_CONFIG);
try {
Path path = Paths.get(confFileName);
AthenzConfig conf = JSON.fromBytes(Files.readAllBytes(path), AthenzConfig.class);
loadPublicKeys(conf.getZtsPublicKeys(), ztsPublicKeyMap);
loadPublicKeys(conf.getZmsPublicKeys(), zmsPublicKeyMap);
} catch (Exception ex) {
LOG.error("Unable to extract ZMS Url from {} exc: {}", confFileName, ex.getMessage());
return;
}
}
use of com.yahoo.athenz.common.config.AthenzConfig in project athenz by yahoo.
the class ZMSClient method lookupZMSUrl.
String lookupZMSUrl() {
String rootDir = System.getenv(STR_ENV_ROOT);
if (rootDir == null) {
rootDir = STR_DEF_ROOT;
}
String confFileName = System.getProperty(ZMS_CLIENT_PROP_ATHENZ_CONF, rootDir + "/conf/athenz/athenz.conf");
String url = null;
try {
Path path = Paths.get(confFileName);
AthenzConfig conf = JSON.fromBytes(Files.readAllBytes(path), AthenzConfig.class);
url = conf.getZmsUrl();
} catch (Exception ex) {
LOGGER.error("Unable to extract ZMS Url from {} exc: {}", confFileName, ex.getMessage());
}
return url;
}
use of com.yahoo.athenz.common.config.AthenzConfig in project athenz by yahoo.
the class DataStore method loadZMSPublicKeys.
void loadZMSPublicKeys() {
final String rootDir = ZTSImpl.getRootDir();
String confFileName = System.getProperty(ZTSConsts.ZTS_PROP_ATHENZ_CONF, rootDir + "/conf/athenz/athenz.conf");
Path path = Paths.get(confFileName);
AthenzConfig conf = null;
try {
conf = JSON.fromBytes(Files.readAllBytes(path), AthenzConfig.class);
ArrayList<com.yahoo.athenz.zms.PublicKeyEntry> publicKeys = conf.getZmsPublicKeys();
if (publicKeys != null) {
for (com.yahoo.athenz.zms.PublicKeyEntry publicKey : publicKeys) {
String id = publicKey.getId();
String key = publicKey.getKey();
if (key == null || id == null) {
continue;
}
PublicKey zmsKey = Crypto.loadPublicKey(Crypto.ybase64DecodeString(key));
zmsPublicKeyCache.put(id, zmsKey);
}
}
} catch (IOException e) {
LOGGER.info("Unable to parse conf file " + confFileName);
return;
}
}
use of com.yahoo.athenz.common.config.AthenzConfig in project athenz by yahoo.
the class ZTSClient method lookupZTSUrl.
public static void lookupZTSUrl() {
String rootDir = System.getenv("ROOT");
if (rootDir == null) {
rootDir = "/home/athenz";
}
String confFileName = System.getProperty(ZTS_CLIENT_PROP_ATHENZ_CONF, rootDir + "/conf/athenz/athenz.conf");
try {
Path path = Paths.get(confFileName);
AthenzConfig conf = JSON.fromBytes(Files.readAllBytes(path), AthenzConfig.class);
confZtsUrl = conf.getZtsUrl();
} catch (Exception ex) {
// if we have a zts client service specified and we have keys
// in our service loader cache then we're running within
// some managed framework (e.g. hadoop) so we're going to
// report this exception as a warning rather than an error
// and default to localhost as the url to avoid further
// warnings from our generated client
LOG.warn("Unable to extract ZTS Url from conf file {}, exc: {}", confFileName, ex.getMessage());
if (!svcLoaderCacheKeys.get().isEmpty()) {
confZtsUrl = "https://localhost:4443/";
}
}
}
use of com.yahoo.athenz.common.config.AthenzConfig in project athenz by yahoo.
the class PolicyUpdaterConfiguration method init.
public void init(String pathToAthenzConfigFile, String pathToZPUConfigFile) throws Exception {
AthenzConfig athenzConfFile = null;
if (pathToAthenzConfigFile == null) {
athenzConfFile = readAthenzConfiguration(defaultAthenzConfigFile);
} else {
athenzConfFile = readAthenzConfiguration(pathToAthenzConfigFile);
}
LOG.info("Policy Updater configuration is set to:");
LOG.info("policyFileDir: " + policyFileDir);
List<PublicKeyEntry> publicKeys = athenzConfFile.getZtsPublicKeys();
if (publicKeys != null) {
for (PublicKeyEntry publicKey : publicKeys) {
String keyId = publicKey.getId();
String key = publicKey.getKey();
if (key == null || keyId == null) {
continue;
}
addZtsPublicKey(keyId, Crypto.loadPublicKey(Crypto.ybase64DecodeString(key)));
LOG.info("Loaded ztsPublicKey keyId: " + keyId + " key: " + key);
}
}
publicKeys = athenzConfFile.getZmsPublicKeys();
if (publicKeys != null) {
for (PublicKeyEntry publicKey : publicKeys) {
String keyId = publicKey.getId();
String key = publicKey.getKey();
if (key == null || keyId == null) {
continue;
}
addZmsPublicKey(keyId, Crypto.loadPublicKey(Crypto.ybase64DecodeString(key)));
LOG.info("Loaded zmsPublicKey keyId: " + keyId + " key: " + key);
}
}
Struct zpuConfFile = null;
if (pathToZPUConfigFile == null) {
zpuConfFile = readZpuConfiguration(defaultZPUConfigFile);
} else {
zpuConfFile = readZpuConfiguration(pathToZPUConfigFile);
}
String domains = zpuConfFile.getString(ZPU_CONFIG_DOMAINS);
if (domains != null && !domains.isEmpty()) {
domainList = Arrays.asList(domains.split(","));
}
zpuDirOwner = zpuConfFile.getString(ZPU_CONFIG_USER);
if (zpuDirOwner == null || zpuDirOwner.isEmpty()) {
zpuDirOwner = ZPU_USER_DEFAULT;
}
if (isDebugMode()) {
LOG.debug("config-init: user: " + zpuDirOwner + " file=" + pathToZPUConfigFile);
}
}
Aggregations