private Domain getDomain(LdapUser user) { Domain domain; if (_domain != null) { //this means either domain id or groupname is passed and this will be same for all the users in this call. hence returning it. domain = _domain; } else { if (domainId != null) { // a domain Id is passed. use it for this user and all the users in the same api call (by setting _domain) domain = _domain = _domainService.getDomain(domainId); } else { // a group name is passed. use it for this user and all the users in the same api call(by setting _domain) domain = _domain = getDomainForName(groupName); if (domain == null) { //use the domain from the LDAP for this user domain = getDomainForName(user.getDomain()); } } if (domain == null) { // could not get a domain using domainId / LDAP group / OU of LDAP user. using ROOT domain for this user domain = _domainService.getDomain(Domain.ROOT_DOMAIN); } } return domain; }
private Domain getDomainForName(String name) { Domain domain = null; if (StringUtils.isNotBlank(name)) { //removing all the special characters and trimming its length to 190 to make the domain valid. String domainName = StringUtils.substring(name.replaceAll("\\W", ""), 0, 190); if (StringUtils.isNotBlank(domainName)) { domain = _domainService.getDomainByName(domainName, Domain.ROOT_DOMAIN); if (domain == null) { domain = _domainService.createDomain(domainName, Domain.ROOT_DOMAIN, domainName, UUID.randomUUID().toString()); } } } return domain; }
@Override public void execute() { Pair<List<? extends Domain>, Integer> result = _domainService.searchForDomainChildren(this); ListResponse<DomainResponse> response = new ListResponse<DomainResponse>(); List<DomainResponse> domainResponses = new ArrayList<DomainResponse>(); for (Domain domain : result.first()) { DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain); domainResponse.setObjectName("domain"); domainResponses.add(domainResponse); } response.setResponses(domainResponses, result.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); } }
@Override public void execute() { CallContext.current().setEventDetails("Domain Name: " + getDomainName() + ((getParentDomainId() != null) ? ", Parent DomainId :" + getParentDomainId() : "")); Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID()); if (domain != null) { DomainResponse response = _responseGenerator.createDomainResponse(domain); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain"); } } }
final String pwd = ((password == null) ? null : password[0]); try { final Domain userDomain = _domainService.findDomainByIdOrPath(domainId, domain); if (userDomain != null) { domainId = userDomain.getId();
@Override public void execute() { CallContext.current().setEventDetails("Domain Name: " + getDomainName() + ((getParentDomainId() != null) ? ", Parent DomainId :" + getParentDomainId() : "")); final Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID(), getEmail()); if (domain != null) { final DomainResponse response = _responseGenerator.createDomainResponse(domain); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain"); } }
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId())); if (networks.size() == 0) { String domain = _domainService.getDomain(getDomainId()).getName(); throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
@Override public void execute() { final Pair<List<? extends Domain>, Integer> result = _domainService.searchForDomainChildren(this); final ListResponse<DomainResponse> response = new ListResponse<>(); final List<DomainResponse> domainResponses = new ArrayList<>(); for (final Domain domain : result.first()) { final DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain); domainResponse.setObjectName("domain"); domainResponses.add(domainResponse); } response.setResponses(domainResponses, result.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); }
List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId())); if (networks.size() == 0) { String domain = _domainService.getDomain(getDomainId()).getName(); throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
for (UserAccountVO userAccount: switchableAccounts) { User user = _userDao.getUser(userAccount.getId()); Domain domain = _domainService.getDomain(userAccount.getDomainId()); SamlUserAccountResponse accountResponse = new SamlUserAccountResponse(); accountResponse.setUserId(user.getUuid());
@Override public void execute() { // Check permissions UserAccount userAccount = _accountService.getUserAccountById(getId()); if (userAccount == null) { throw new ServerApiException(ApiErrorCode.ACCOUNT_ERROR , "Unable to find a user account with the given ID"); } Domain domain = _domainService.getDomain(userAccount.getDomainId()); Account account = _accountService.getAccount(userAccount.getAccountId()); _accountService.checkAccess(CallContext.current().getCallingAccount(), domain); _accountService.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, true, account); CallContext.current().setEventDetails("UserId: " + getId()); SuccessResponse response = new SuccessResponse(); Boolean status = false; if (_samlAuthManager.authorizeUser(getId(), getEntityId(), getEnable())) { status = true; } response.setResponseName(getCommandName()); response.setSuccess(status); setResponseObject(response); } }
final List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId())); if (networks.size() == 0) { final String domain = _domainService.getDomain(getDomainId()).getName(); throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
final List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId())); if (networks.size() == 0) { final String domain = _domainService.getDomain(getDomainId()).getName(); throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());