use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class FileConnection method listServiceHosts.
@Override
public List<String> listServiceHosts(String domainName, String serviceName) {
DomainStruct domainStruct = getDomainStruct(domainName);
if (domainStruct == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "domain not found", "listServiceHosts");
}
ServiceIdentity service = getServiceObject(domainStruct, serviceName);
if (service == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "service not found", "deletePublicKeyEntry");
}
return service.getHosts();
}
use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class FileConnection method updateServiceIdentity.
@Override
public boolean updateServiceIdentity(String domainName, ServiceIdentity service) {
DomainStruct domainStruct = getDomainStruct(domainName);
if (domainStruct == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "domain not found", "updateServiceIdentity");
}
if (domainStruct.getServices() == null) {
domainStruct.setServices(new HashMap<String, ServiceIdentity>());
}
HashMap<String, ServiceIdentity> services = domainStruct.getServices();
service.setModified(Timestamp.fromCurrentTime());
String serviceName = extractServiceName(domainName, service.getName());
// here we only need to update the main attrs and not
// the public keys and hosts
List<PublicKeyEntry> publicKeys = service.getPublicKeys();
List<String> hosts = service.getHosts();
ServiceIdentity originalService = getServiceObject(domainStruct, serviceName);
if (originalService != null) {
service.setPublicKeys(originalService.getPublicKeys());
service.setHosts(originalService.getHosts());
} else {
service.setPublicKeys(null);
service.setHosts(null);
}
service.setModified(Timestamp.fromCurrentTime());
services.put(serviceName, service);
putDomainStruct(domainName, domainStruct);
service.setPublicKeys(publicKeys);
service.setHosts(hosts);
return true;
}
use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class FileConnection method deletePublicKeyEntry.
@Override
public boolean deletePublicKeyEntry(String domainName, String serviceName, String keyId) {
DomainStruct domainStruct = getDomainStruct(domainName);
if (domainStruct == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "domain not found", "deletePublicKeyEntry");
}
ServiceIdentity service = getServiceObject(domainStruct, serviceName);
if (service == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "service not found", "deletePublicKeyEntry");
}
List<PublicKeyEntry> keyList = service.getPublicKeys();
boolean keyRemoved = removePublicKeyEntry(keyList, keyId);
if (!keyRemoved) {
return false;
}
putDomainStruct(domainName, domainStruct);
return true;
}
use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class FileConnection method insertServiceHost.
@Override
public boolean insertServiceHost(String domainName, String serviceName, String hostName) {
DomainStruct domainStruct = getDomainStruct(domainName);
if (domainStruct == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "domain not found", "insertServiceHost");
}
ServiceIdentity service = getServiceObject(domainStruct, serviceName);
if (service == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "service not found", "insertServiceHost");
}
if (service.getHosts() == null) {
service.setHosts(new ArrayList<String>());
}
List<String> hosts = service.getHosts();
hosts.add(hostName);
putDomainStruct(domainName, domainStruct);
return true;
}
use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class FileConnection method updateServiceIdentityModTimestamp.
@Override
public boolean updateServiceIdentityModTimestamp(String domainName, String serviceName) {
DomainStruct domainStruct = getDomainStruct(domainName);
if (domainStruct == null) {
throw ZMSUtils.error(ResourceException.NOT_FOUND, "domain not found", "updateServiceIdentityModTimestamp");
}
ServiceIdentity service = getServiceObject(domainStruct, serviceName);
service.setModified(Timestamp.fromCurrentTime());
putDomainStruct(domainName, domainStruct);
return true;
}
Aggregations