mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Initialize user context from AccountManager
Conflicts: server/src/com/cloud/configuration/DefaultComponentLibrary.java server/src/com/cloud/network/vpc/VpcManagerImpl.java
This commit is contained in:
parent
9e1b8caec4
commit
da26302049
@ -16,14 +16,11 @@
|
||||
// under the License.
|
||||
package com.cloud.user;
|
||||
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
|
||||
public class UserContext {
|
||||
|
||||
private static ThreadLocal<UserContext> s_currentContext = new ThreadLocal<UserContext>();
|
||||
private static final ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||
private static final AccountService _accountMgr = locator.getManager(AccountService.class);
|
||||
private static UserContext s_adminContext = null;
|
||||
|
||||
private long userId;
|
||||
private String sessionId;
|
||||
@ -33,9 +30,7 @@ public class UserContext {
|
||||
private String eventDetails;
|
||||
|
||||
private boolean apiServer;
|
||||
|
||||
private static UserContext s_adminContext = new UserContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
|
||||
|
||||
|
||||
public UserContext() {
|
||||
}
|
||||
|
||||
@ -134,4 +129,10 @@ public class UserContext {
|
||||
public String getEventDetails() {
|
||||
return eventDetails;
|
||||
}
|
||||
|
||||
public static synchronized void setAdminContext(UserContext adminContext) {
|
||||
if (adminContext == null) {
|
||||
UserContext.s_adminContext = adminContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,6 +239,9 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
if (_userAuthenticators == null || !_userAuthenticators.isSet()) {
|
||||
s_logger.error("Unable to find an user authenticator.");
|
||||
}
|
||||
|
||||
//initialize admin context
|
||||
UserContext.setAdminContext(new UserContext(getSystemUser().getId(), getSystemAccount(), null, false));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user