@Override public Account validateToken(String password) { String[] parts = password.split(":"); if (parts.length != 3) { return null; } Date date = null; try { long time = Long.parseLong(parts[1]); if (System.currentTimeMillis() > (time + RegistrationToken.getAllowedTime())) { return null; } date = new Date(time); } catch (NumberFormatException e) { return null; } Credential cred = authDao.getCredential(parts[0]); if (cred == null) { return null; } String token = RegistrationToken.createToken(cred.getPublicValue(), cred.getSecretValue(), date); if (!password.equals(token)) { return null; } Account account = objectManager.loadResource(Account.class, cred.getAccountId()); if (account == null || !accountDao.isActiveAccount(account) || account.getRemoved() != null) { return null; } return account; }
protected void startStacks(Account account) throws IOException { if (account.getRemoved() != null) { return; } List<Long> createdStackIds = DataAccessor.fieldLongList(account, AccountConstants.FIELD_CREATED_STACKS); List<Long> startedStackIds = DataAccessor.fieldLongList(account, AccountConstants.FIELD_STARTED_STACKS); if (!startedStackIds.isEmpty() || createdStackIds.isEmpty()) { return; } if (!hostDao.hasActiveHosts(account.getId())) { return; } startedStackIds = new ArrayList<>(); for (Long stackId : createdStackIds) { Stack stack = objectManager.loadResource(Stack.class, stackId); if (stack == null) { continue; } stack = resourceMonitor.waitForNotTransitioning(stack); if (CommonStatesConstants.ACTIVE.equals(stack.getState())) { for (Service service : objectManager.find(Service.class, SERVICE.STACK_ID, stackId, SERVICE.REMOVED, null)) { processManager.scheduleStandardProcess(StandardProcess.ACTIVATE, service, null); } } startedStackIds.add(stackId); } objectManager.setFields(account, AccountConstants.FIELD_STARTED_STACKS, startedStackIds); }
if (account != null && account.getRemoved() == null) { deactivateThenScheduleRemove(account, state.getData()); for (Long accountId : authedRoleAccountIds) { account = objectManager.loadResource(Account.class, accountId); if (account != null && account.getRemoved() == null) { deactivateThenScheduleRemove(account, state.getData());
protected void process(long accountId) throws IOException { Account account = objectManager.loadResource(Account.class, accountId); if (account == null || account.getRemoved() != null) { return;
/** * {@inheritDoc} */ @Override public void from(io.cattle.platform.core.model.Account from) { setId(from.getId()); setName(from.getName()); setKind(from.getKind()); setUuid(from.getUuid()); setDescription(from.getDescription()); setState(from.getState()); setCreated(from.getCreated()); setRemoved(from.getRemoved()); setRemoveTime(from.getRemoveTime()); setData(from.getData()); setExternalId(from.getExternalId()); setExternalIdType(from.getExternalIdType()); setHealthState(from.getHealthState()); setProjectTemplateId(from.getProjectTemplateId()); setDefaultNetworkId(from.getDefaultNetworkId()); setVersion(from.getVersion()); setRevision(from.getRevision()); }