Skip to content

Commit bc8a0c1

Browse files
Remove "self-injection" of AccountManagerImpl (#2619)
While working on other PRs I noticed that the singleton AccountManagerImpl had a reference for itself. That is not needed. Therefore, I removed it.
1 parent 55f45e7 commit bc8a0c1

1 file changed

Lines changed: 17 additions & 25 deletions

File tree

server/src/main/java/com/cloud/user/AccountManagerImpl.java

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@
123123
import com.cloud.projects.ProjectVO;
124124
import com.cloud.projects.dao.ProjectAccountDao;
125125
import com.cloud.projects.dao.ProjectDao;
126+
import com.cloud.region.ha.GlobalLoadBalancingRulesService;
126127
import com.cloud.server.auth.UserAuthenticator;
127128
import com.cloud.server.auth.UserAuthenticator.ActionOnFailedAuthentication;
128129
import com.cloud.storage.VMTemplateVO;
129130
import com.cloud.storage.Volume;
130131
import com.cloud.storage.VolumeApiService;
131132
import com.cloud.storage.VolumeVO;
132-
import com.cloud.storage.dao.SnapshotDao;
133133
import com.cloud.storage.dao.VMTemplateDao;
134134
import com.cloud.storage.dao.VolumeDao;
135135
import com.cloud.storage.snapshot.SnapshotManager;
@@ -180,9 +180,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
180180
@Inject
181181
private AccountDao _accountDao;
182182
@Inject
183-
private AccountManager _accountMgr;
184-
@Inject
185-
ConfigurationDao _configDao;
183+
private ConfigurationDao _configDao;
186184
@Inject
187185
private ResourceCountDao _resourceCountDao;
188186
@Inject
@@ -204,10 +202,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
204202
@Inject
205203
private VMInstanceDao _vmDao;
206204
@Inject
207-
protected SnapshotDao _snapshotDao;
208-
@Inject
209-
protected VMTemplateDao _vmTemplateDao;
210-
@Inject
211205
private SecurityGroupManager _networkGroupMgr;
212206
@Inject
213207
private NetworkOrchestrationService _networkMgr;
@@ -250,11 +244,11 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
250244
@Inject
251245
private VpcManager _vpcMgr;
252246
@Inject
253-
Site2SiteVpnManager _vpnMgr;
247+
private Site2SiteVpnManager _vpnMgr;
254248
@Inject
255249
private AutoScaleManager _autoscaleMgr;
256250
@Inject
257-
VolumeApiService volumeService;
251+
private VolumeApiService volumeService;
258252
@Inject
259253
private AffinityGroupDao _affinityGroupDao;
260254
@Inject
@@ -272,29 +266,29 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
272266
@Inject
273267
private SSHKeyPairDao _sshKeyPairDao;
274268

275-
List<QuerySelector> _querySelectors;
269+
private List<QuerySelector> _querySelectors;
276270

277271
@Inject
278-
MessageBus _messageBus;
272+
private MessageBus _messageBus;
279273

280274
@Inject
281-
public com.cloud.region.ha.GlobalLoadBalancingRulesService _gslbService;
275+
private GlobalLoadBalancingRulesService _gslbService;
282276

283277
private List<UserAuthenticator> _userAuthenticators;
284-
List<UserAuthenticator> _userPasswordEncoders;
278+
protected List<UserAuthenticator> _userPasswordEncoders;
285279

286280
@Inject
287-
protected IpAddressManager _ipAddrMgr;
281+
private IpAddressManager _ipAddrMgr;
288282

289283
private final ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AccountChecker"));
290284

291-
int _allowedLoginAttempts;
285+
private int _allowedLoginAttempts;
292286

293-
UserVO _systemUser;
294-
AccountVO _systemAccount;
287+
private UserVO _systemUser;
288+
private AccountVO _systemAccount;
295289

296-
List<SecurityChecker> _securityCheckers;
297-
int _cleanupInterval;
290+
private List<SecurityChecker> _securityCheckers;
291+
private int _cleanupInterval;
298292

299293
public List<UserAuthenticator> getUserAuthenticators() {
300294
return _userAuthenticators;
@@ -493,8 +487,6 @@ public void checkAccess(Account caller, Domain domain) throws PermissionDeniedEx
493487
return;
494488
}
495489
}
496-
497-
assert false : "How can all of the security checkers pass on checking this caller?";
498490
throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to " + domain);
499491
}
500492

@@ -2292,8 +2284,8 @@ public UserAccount authenticateUser(final String username, final String password
22922284
}
22932285

22942286
// We authenticated successfully by now, let's check if we are allowed to login from the ip address the reqest comes from
2295-
final Account account = _accountMgr.getAccount(user.getAccountId());
2296-
final DomainVO domain = (DomainVO)_domainMgr.getDomain(account.getDomainId());
2287+
final Account account = getAccount(user.getAccountId());
2288+
final DomainVO domain = (DomainVO) _domainMgr.getDomain(account.getDomainId());
22972289

22982290
// Get the CIDRs from where this account is allowed to make calls
22992291
final String accessAllowedCidrs = ApiServiceConfiguration.ApiAllowedSourceCidrList.valueIn(account.getId()).replaceAll("\\s", "");
@@ -2858,4 +2850,4 @@ public String getConfigComponentName() {
28582850
public ConfigKey<?>[] getConfigKeys() {
28592851
return new ConfigKey<?>[] {UseSecretKeyInResponse};
28602852
}
2861-
}
2853+
}

0 commit comments

Comments
 (0)