use of com.cloud.domain.DomainVO in project cloudstack by apache.
the class DomainManagerImplTest method createDomainVoTestValidInformedUuid.
@Test
public void createDomainVoTestValidInformedUuid() {
DomainVO domainVo = domainManager.createDomainVo("test", 1L, 2L, "NetworkTest", "testUuid");
Assert.assertEquals("testUuid", domainVo.getUuid());
}
use of com.cloud.domain.DomainVO in project cloudstack by apache.
the class DomainManagerImplTest method createDomainVoTestCreateValidUuidIfWhiteSpace.
@Test
public void createDomainVoTestCreateValidUuidIfWhiteSpace() {
DomainVO domainVo = domainManager.createDomainVo("test", 1L, 2L, "NetworkTest", " ");
Assert.assertTrue(UuidUtils.validateUUID(domainVo.getUuid()));
}
use of com.cloud.domain.DomainVO in project cloudstack by apache.
the class DomainManagerImplTest method validateUniqueDomainNameTestUniqueNameDoesNotThrowException.
@Test
public void validateUniqueDomainNameTestUniqueNameDoesNotThrowException() {
SearchCriteria scMock = Mockito.mock(SearchCriteria.class);
ArrayList<DomainVO> listMock = Mockito.mock(ArrayList.class);
Mockito.doReturn(scMock).when(domainDaoMock).createSearchCriteria();
Mockito.doReturn(listMock).when(domainDaoMock).search(Mockito.any(SearchCriteria.class), Mockito.any());
Mockito.doReturn(true).when(listMock).isEmpty();
domainManager.validateUniqueDomainName("testUnique", 1L);
Mockito.verify(domainDaoMock).createSearchCriteria();
Mockito.verify(scMock).addAnd("name", SearchCriteria.Op.EQ, "testUnique");
Mockito.verify(scMock).addAnd("parent", SearchCriteria.Op.EQ, 1L);
Mockito.verify(domainDaoMock).search(scMock, null);
Mockito.verify(listMock).isEmpty();
}
use of com.cloud.domain.DomainVO in project cloudstack by apache.
the class AnnotationManagerImpl method isEntityOwnedByTheUser.
private boolean isEntityOwnedByTheUser(String entityType, String entityUuid, UserVO callingUser) {
try {
if (!isCallingUserRole(RoleType.Admin)) {
EntityType type = EntityType.valueOf(entityType);
List<EntityType> notAllowedTypes = EntityType.getNotAllowedTypesForNonAdmins(getCallingUserRole());
if (notAllowedTypes.contains(type)) {
return false;
}
if (isCallingUserRole(RoleType.DomainAdmin)) {
if (type == EntityType.SERVICE_OFFERING || type == EntityType.DISK_OFFERING) {
return true;
} else if (type == EntityType.DOMAIN) {
DomainVO domain = domainDao.findByUuid(entityUuid);
AccountVO account = accountDao.findById(callingUser.getAccountId());
accountService.checkAccess(account, domain);
return true;
}
}
ControlledEntity entity = getEntityFromUuidAndType(entityUuid, type);
if (entity == null) {
String errMsg = String.format("Could not find an entity with type: %s and ID: %s", entityType, entityUuid);
LOGGER.error(errMsg);
throw new CloudRuntimeException(errMsg);
}
if (type == EntityType.NETWORK && entity instanceof NetworkVO && ((NetworkVO) entity).getAclType() == ControlledEntity.ACLType.Domain) {
NetworkVO network = (NetworkVO) entity;
DomainVO domain = domainDao.findById(network.getDomainId());
AccountVO account = accountDao.findById(callingUser.getAccountId());
accountService.checkAccess(account, domain);
} else {
accountService.checkAccess(callingUser, entity);
}
}
} catch (IllegalArgumentException e) {
LOGGER.error("Could not parse entity type " + entityType, e);
return false;
} catch (PermissionDeniedException e) {
LOGGER.debug(e.getMessage(), e);
return false;
}
return true;
}
use of com.cloud.domain.DomainVO in project cloudstack by apache.
the class CertServiceImpl method createCertResponse.
public SslCertResponse createCertResponse(final SslCertVO cert, final List<LoadBalancerCertMapVO> lbCertMap) {
Preconditions.checkNotNull(cert);
final SslCertResponse response = new SslCertResponse();
final Account account = _accountDao.findByIdIncludingRemoved(cert.getAccountId());
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
// find the project
final Project project = _projectMgr.findByProjectAccountIdIncludingRemoved(account.getId());
if (project != null) {
response.setProjectId(project.getUuid());
response.setProjectName(project.getName());
}
response.setAccountName(account.getAccountName());
} else {
response.setAccountName(account.getAccountName());
}
final DomainVO domain = _domainDao.findByIdIncludingRemoved(cert.getDomainId());
response.setDomainId(domain.getUuid());
response.setDomainName(domain.getName());
response.setObjectName("sslcert");
response.setId(cert.getUuid());
response.setCertificate(cert.getCertificate());
response.setFingerprint(cert.getFingerPrint());
response.setName(cert.getName());
if (cert.getChain() != null) {
response.setCertchain(cert.getChain());
}
if (lbCertMap != null && !lbCertMap.isEmpty()) {
final List<String> lbIds = new ArrayList<String>();
for (final LoadBalancerCertMapVO mapVO : lbCertMap) {
final LoadBalancer lb = _entityMgr.findById(LoadBalancerVO.class, mapVO.getLbId());
if (lb != null) {
lbIds.add(lb.getUuid());
}
}
response.setLbIds(lbIds);
}
return response;
}
Aggregations