use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class ZMSFileChangeLogStoreTest method testGetLocalDomainListMultiple.
@Test
public void testGetLocalDomainListMultiple() {
ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null);
ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
Struct data = new Struct();
data.put("key", "val1");
cstore.put("test1", JSON.bytes(data));
data = new Struct();
data.put("key", "val1");
cstore.put("test2", JSON.bytes(data));
data = new Struct();
data.put("key", "val1");
cstore.put("test3", JSON.bytes(data));
List<String> ls = fstore.getLocalDomainList();
assertEquals(ls.size(), 3);
assertTrue(ls.contains("test1"));
assertTrue(ls.contains("test2"));
assertTrue(ls.contains("test3"));
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class CloudStore method getSshKeyReqType.
String getSshKeyReqType(String sshKeyReq) {
Struct keyReq = JSON.fromString(sshKeyReq, Struct.class);
if (keyReq == null) {
LOGGER.error("getSshKeyReqType: Unable to parse ssh key req: {}", sshKeyReq);
return null;
}
String sshType = keyReq.getString(ZTSConsts.ZTS_SSH_TYPE);
if (sshType == null) {
LOGGER.error("getSshKeyReqType: SSH Key request does not have certtype: {}", sshKeyReq);
}
return sshType;
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class CloudStore method fetchRoleCredentials.
boolean fetchRoleCredentials() {
if (awsRole == null || awsRole.isEmpty()) {
LOGGER.error("CloudStore: awsRole is not available to fetch role credentials");
return false;
}
final String creds = getMetaData("/meta-data/iam/security-credentials/" + awsRole);
if (creds == null) {
return false;
}
Struct credsStruct = JSON.fromString(creds, Struct.class);
if (credsStruct == null) {
LOGGER.error("CloudStore: unable to parse role credentials data: {}", creds);
return false;
}
String accessKeyId = credsStruct.getString("AccessKeyId");
String secretAccessKey = credsStruct.getString("SecretAccessKey");
String token = credsStruct.getString("Token");
credentials = new BasicSessionCredentials(accessKeyId, secretAccessKey, token);
return true;
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class DBServiceTest method testExecutePutEntityUpdate.
@Test
public void testExecutePutEntityUpdate() {
String domainName = "createentitydom1-mod";
String entityName = "entity1";
TopLevelDomain dom1 = createTopLevelDomainObject(domainName, "Test Domain1", "testOrg", adminUser);
zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
Entity entity1 = createEntityObject(domainName, entityName);
zms.dbService.executePutEntity(mockDomRsrcCtx, domainName, entityName, entity1, auditRef, "putEntity");
Struct value = new Struct();
value.put("Key2", "Value2");
entity1.setValue(value);
zms.dbService.executePutEntity(mockDomRsrcCtx, domainName, entityName, entity1, auditRef, "putEntity");
Entity entity2 = zms.getEntity(mockDomRsrcCtx, domainName, entityName);
assertNotNull(entity2);
assertEquals(entity2.getName(), ResourceUtils.entityResourceName(domainName, entityName));
value = entity2.getValue();
assertEquals("Value2", value.getString("Key2"));
zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName, auditRef);
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class InstanceAWSProvider method validateAWSDocument.
boolean validateAWSDocument(final String provider, AWSAttestationData info, final String awsAccount, final String instanceId, StringBuilder errMsg) {
final String document = info.getDocument();
if (!validateAWSSignature(document, info.getSignature(), errMsg)) {
return false;
}
// convert our document into a struct that we can extract data
Struct instanceDocument = JSON.fromString(document, Struct.class);
if (instanceDocument == null) {
errMsg.append("Unable to parse identity document");
LOGGER.error("Identity Document: {}", document);
return false;
}
if (!validateAWSProvider(provider, instanceDocument.getString(ATTR_REGION), errMsg)) {
return false;
}
if (!validateAWSAccount(awsAccount, instanceDocument.getString(ATTR_ACCOUNT_ID), errMsg)) {
return false;
}
// verify the request has the expected account id
final String infoInstanceId = getInstanceId(info, instanceDocument);
if (!validateAWSInstanceId(instanceId, infoInstanceId, errMsg)) {
return false;
}
if (!validateInstanceBootTime(instanceDocument, errMsg)) {
return false;
}
return true;
}
Aggregations