Search in sources :

Example 1 with ServiceIdentity

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();
}
Also used : ServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity)

Example 2 with ServiceIdentity

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;
}
Also used : PublicKeyEntry(com.yahoo.athenz.zms.PublicKeyEntry) ServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity)

Example 3 with ServiceIdentity

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;
}
Also used : PublicKeyEntry(com.yahoo.athenz.zms.PublicKeyEntry) ServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity)

Example 4 with ServiceIdentity

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;
}
Also used : ServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity)

Example 5 with ServiceIdentity

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;
}
Also used : ServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity)

Aggregations

ServiceIdentity (com.yahoo.athenz.zms.ServiceIdentity)53 Test (org.testng.annotations.Test)32 ArrayList (java.util.ArrayList)29 DomainData (com.yahoo.athenz.zms.DomainData)21 DataCache (com.yahoo.athenz.zts.cache.DataCache)17 Role (com.yahoo.athenz.zms.Role)11 JDBCConnection (com.yahoo.athenz.zms.store.jdbc.JDBCConnection)11 MockZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.MockZMSFileChangeLogStore)11 ZMSFileChangeLogStore (com.yahoo.athenz.zts.store.impl.ZMSFileChangeLogStore)11 RoleMember (com.yahoo.athenz.zms.RoleMember)8 SignedDomain (com.yahoo.athenz.zms.SignedDomain)8 Domain (com.yahoo.athenz.zms.Domain)6 PublicKeyEntry (com.yahoo.athenz.zms.PublicKeyEntry)5 HostServices (com.yahoo.athenz.zts.HostServices)5 Set (java.util.Set)5 Policy (com.yahoo.athenz.zms.Policy)4 ResourceException (com.yahoo.athenz.zms.ResourceException)4 SQLException (java.sql.SQLException)4 Assertion (com.yahoo.athenz.zms.Assertion)3 MemberRole (com.yahoo.athenz.zts.cache.MemberRole)3