@Given("^I set the database to device timestamp indexing$") public void setDatabaseToDeviceTimestampIndexing() throws KapuaException { Account account = (Account) stepData.get("LastAccount"); updateConfiguration(messageStoreService, account.getId(), account.getScopeId(), DataIndexBy.DEVICE_TIMESTAMP, MetricsIndexBy.TIMESTAMP, 30, true); }
ArgumentValidator.notNull(account.getId(), "account.id"); ArgumentValidator.notEmptyOrNull(account.getName(), "account.name"); ArgumentValidator.notNull(account.getOrganization(), "account.organization"); ArgumentValidator.match(account.getOrganization().getEmail(), CommonsValidationRegex.EMAIL_REGEXP, "account.organization.email"); if (KapuaSecurityUtils.getSession().getScopeId().equals(account.getId())) { authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.write, account.getId())); } else { authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.write, account.getScopeId())); Account oldAccount = find(account.getId()); if (oldAccount == null) { throw new KapuaEntityNotFoundException(Account.TYPE, account.getId()); if (oldAccount.getScopeId() != null) { parentAccount = KapuaSecurityUtils.doPrivileged(() -> find(oldAccount.getScopeId())); if (parentAccount != null && parentAccount.getExpirationDate() != null) { if (account.getExpirationDate() == null || parentAccount.getExpirationDate().before(account.getExpirationDate())) { throw new KapuaIllegalArgumentException("expirationDate", account.getExpirationDate() != null ? account.getExpirationDate().toString() : "no expiration date set"); if (account.getExpirationDate() != null) { AccountListResult childrenAccounts = findChildsRecursively(account.getId()); if (childrenAccounts.getItems().stream().anyMatch(childAccount -> {
if (account.getExpirationDate() != null && !account.getExpirationDate().after(new Date())) { throw new ExpiredAccountException(account.getExpirationDate()); credentialServiceConfig = KapuaSecurityUtils.doPrivileged(() -> credentialService.getConfigValues(account.getId())); boolean lockoutPolicyEnabled = (boolean) credentialServiceConfig.get("lockoutPolicy.enabled"); if (lockoutPolicyEnabled) {
if (parentAccount != null && parentAccount.getExpirationDate() != null) { if (accountCreator.getExpirationDate() == null || parentAccount.getExpirationDate().before(accountCreator.getExpirationDate())) { String parentAccountPath = AccountDAO.find(em, null, accountCreator.getScopeId()).getParentAccountPath() + "/" + account.getId(); account.setParentAccountPath(parentAccountPath); return AccountDAO.update(em, account); });
@Override public AccountListResult findChildsRecursively(KapuaId scopeId) throws KapuaException { // // Argument validation ArgumentValidator.notNull(scopeId, "scopeId"); // // Make sure account exists Account account = findById(scopeId); if (account == null) { throw new KapuaEntityNotFoundException(Account.TYPE, scopeId); } // // Check Access authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.read, account.getId())); return entityManagerSession.onResult(em -> { AccountListResult result = null; TypedQuery<Account> q; q = em.createNamedQuery("Account.findChildAccountsRecursive", Account.class); q.setParameter("parentAccountPath", "\\" + account.getParentAccountPath() + "/%"); result = new AccountListResultImpl(); result.addItems(q.getResultList()); return result; }); }
kcc.update(accessToken, account.getName(), accessToken.getScopeId(), accessToken.getUserId(), (((TransportConnector) context.getConnector()).getName()), brokerIpResolver.getBrokerIpOrHostName(), MULTI_ACCOUNT_CLIENT_ID); kcc.updateOldConnectionId(CONNECTION_MAP.get(kcc.getFullClientId()));
Account account = KapuaSecurityUtils.doPrivileged(() -> ACCOUNT_SERVICE.find(permission.getTargetScopeId())); if (account != null && account.getScopeId() != null) { String parentAccountPath = account.getParentAccountPath();
query.setScopeId(account.getScopeId()); endpointInfoCount = EndpointInfoDAO.count(em, query);
if (account.getExpirationDate() != null && !account.getExpirationDate().after(new Date())) { throw new ExpiredAccountException(account.getExpirationDate());
if (account.getExpirationDate() != null && !account.getExpirationDate().after(new Date())) { throw new ExpiredAccountException(account.getExpirationDate()); credentialServiceConfig = KapuaSecurityUtils.doPrivileged(() -> credentialService.getConfigValues(account.getId())); boolean lockoutPolicyEnabled = (boolean) credentialServiceConfig.get("lockoutPolicy.enabled"); if (lockoutPolicyEnabled) {
if (parentAccount != null && parentAccount.getExpirationDate() != null) { if (accountCreator.getExpirationDate() == null || parentAccount.getExpirationDate().before(accountCreator.getExpirationDate())) { String parentAccountPath = AccountDAO.find(em, null, accountCreator.getScopeId()).getParentAccountPath() + "/" + account.getId(); account.setParentAccountPath(parentAccountPath); return AccountDAO.update(em, account); });
@Override public AccountListResult findChildsRecursively(KapuaId scopeId) throws KapuaException { // // Argument validation ArgumentValidator.notNull(scopeId, "scopeId"); // // Make sure account exists Account account = findById(scopeId); if (account == null) { throw new KapuaEntityNotFoundException(Account.TYPE, scopeId); } // // Check Access authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.read, account.getId())); return entityManagerSession.onResult(em -> { AccountListResult result = null; TypedQuery<Account> q; q = em.createNamedQuery("Account.findChildAccountsRecursive", Account.class); q.setParameter("parentAccountPath", "\\" + account.getParentAccountPath() + "/%"); result = new AccountListResultImpl(); result.addItems(q.getResultList()); return result; }); }
Account account = KapuaSecurityUtils.doPrivileged(() -> ACCOUNT_SERVICE.find(permission.getTargetScopeId())); if (account != null && account.getScopeId() != null) { String parentAccountPath = account.getParentAccountPath();
query.setScopeId(account.getScopeId()); endpointInfoListResult = EndpointInfoDAO.query(em, query);
if (account.getExpirationDate() != null && !account.getExpirationDate().after(new Date())) { throw new ExpiredAccountException(account.getExpirationDate());
@Override protected Map<String, Object> getConfigValues(Account entity) throws KapuaException { return super.getConfigValues(entity.getId()); } }
@Given("^I set the database to server timestamp indexing$") public void setDatabaseToServerTimestampIndexing() throws KapuaException { Account account = (Account) stepData.get("LastAccount"); updateConfiguration(messageStoreService, account.getId(), account.getScopeId(), DataIndexBy.SERVER_TIMESTAMP, MetricsIndexBy.TIMESTAMP, 30, true); }
ArgumentValidator.notNull(account.getId(), "account.id"); ArgumentValidator.notEmptyOrNull(account.getName(), "account.name"); ArgumentValidator.notNull(account.getOrganization(), "account.organization"); ArgumentValidator.match(account.getOrganization().getEmail(), CommonsValidationRegex.EMAIL_REGEXP, "account.organization.email"); if (KapuaSecurityUtils.getSession().getScopeId().equals(account.getId())) { authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.write, account.getId())); } else { authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.write, account.getScopeId())); Account oldAccount = find(account.getId()); if (oldAccount == null) { throw new KapuaEntityNotFoundException(Account.TYPE, account.getId()); if (oldAccount.getScopeId() != null) { parentAccount = KapuaSecurityUtils.doPrivileged(() -> find(oldAccount.getScopeId())); if (parentAccount != null && parentAccount.getExpirationDate() != null) { if (account.getExpirationDate() == null || parentAccount.getExpirationDate().before(account.getExpirationDate())) { throw new KapuaIllegalArgumentException("expirationDate", account.getExpirationDate() != null ? account.getExpirationDate().toString() : "no expiration date set"); if (account.getExpirationDate() != null) { SystemSetting setting = SystemSetting.getInstance(); if (setting.getString(SystemSettingKey.SYS_ADMIN_ACCOUNT).equals(account.getName())) {