本文整理汇总了Java中org.wso2.carbon.utils.multitenancy.MultitenantConstants.SUPER_TENANT_ID属性的典型用法代码示例。如果您正苦于以下问题:Java MultitenantConstants.SUPER_TENANT_ID属性的具体用法?Java MultitenantConstants.SUPER_TENANT_ID怎么用?Java MultitenantConstants.SUPER_TENANT_ID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.wso2.carbon.utils.multitenancy.MultitenantConstants
的用法示例。
在下文中一共展示了MultitenantConstants.SUPER_TENANT_ID属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTenantFlow
/**
* Starts the tenant flow for the given tenant domain
*
* @param tenantDomain tenant domain
*/
public static void startTenantFlow(String tenantDomain) {
String tenantDomainParam = tenantDomain;
int tenantId = MultitenantConstants.SUPER_TENANT_ID;
if (tenantDomainParam != null && !tenantDomainParam.trim().isEmpty()) {
try {
tenantId = FrameworkServiceComponent.getRealmService().getTenantManager()
.getTenantId(tenantDomain);
} catch (UserStoreException e) {
log.error("Error while getting tenantId from tenantDomain query param", e);
}
} else {
tenantDomainParam = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
}
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
.getThreadLocalCarbonContext();
carbonContext.setTenantId(tenantId);
carbonContext.setTenantDomain(tenantDomainParam);
}
示例2: getInstance
/**
* Get a EntitlementEngine instance for that tenant. This method will return an
* EntitlementEngine instance if exists, or creates a new one
*
* @return EntitlementEngine instance for that tenant
*/
public static EntitlementEngine getInstance() {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
if (entitlementEngine == null) {
synchronized (lock) {
if (entitlementEngine == null) {
entitlementEngine = new EntitlementEngine(tenantId);
}
}
}
return entitlementEngine;
}
if (!entitlementEngines.contains(tenantId)) {
synchronized (lock) {
if (!entitlementEngines.contains(tenantId)) {
entitlementEngines.put(tenantId, new EntitlementEngine(tenantId));
}
}
}
return entitlementEngines.get(tenantId);
}
示例3: getTenantId
public static int getTenantId() {
//TODO: Get the tenant id proper way. This is has to be fix for test to run.
int tenantId;
tenantId = MultitenantConstants.SUPER_TENANT_ID;
/* try {
if (PrivilegedCarbonContext.getThreadLocalCarbonContext() != null) {
tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
} else {
tenantId = MultitenantConstants.SUPER_TENANT_ID;
}
} catch (Exception e) {
}*/
return tenantId;
}
示例4: getRequestMessage
private String getRequestMessage() {
String msg;
String targetEpr = config.getTargetEpr();
String tenantDomain = this.tenantDomain;
if (tenantDomain == null) {
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
}
if (tenantDomain != null && targetEpr.indexOf("/carbon") > 0 &&
MultitenantUtils.getTenantDomainFromRequestURL(targetEpr) == null &&
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true)!= MultitenantConstants.SUPER_TENANT_ID) {
targetEpr = targetEpr.replace("/carbon", "/" +
MultitenantConstants.TENANT_AWARE_URL_PREFIX + "/" + tenantDomain + "/carbon");
}
if (config.getEmailBody().length() == 0) {
msg = EmailVerifierConfig.DEFAULT_VALUE_MESSAGE + "\n" + targetEpr + "?"
+ CONF_STRING + "=" + secretKey + "\n";
} else {
msg = config.getEmailBody() + "\n" + targetEpr + "?" + CONF_STRING + "="
+ secretKey + "\n";
}
if (config.getEmailFooter() != null) {
msg = msg + "\n" + config.getEmailFooter();
}
return msg;
}
示例5: getAdminUserNameFromTenantId
/**
* Method to get the name of the admin user given the tenant id
*
* @param tenantId tenant id
* @return admin user name
* @throws Exception UserStoreException
*/
public static String getAdminUserNameFromTenantId(RealmService realmService, int tenantId)
throws Exception {
if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
return realmService.getBootstrapRealmConfiguration().getAdminUserName();
}
String tenantAdminName = "";
try {
if (realmService.getTenantManager().getTenant(tenantId) != null) {
tenantAdminName = realmService.getTenantManager().getTenant(tenantId).getAdminName();
}
} catch (org.wso2.carbon.user.api.UserStoreException e) {
String msg = "Unable to retrieve the admin name for the tenant with the tenant Id: " +
tenantId;
log.error(msg, e);
throw new Exception(msg, e);
}
return tenantAdminName;
}
示例6: getAdminUserNameFromTenantId
/**
* Method to get the name of the admin user given the tenant id
*
* @param tenantId
* tenant id
* @return admin user name
* @throws Exception
* UserStoreException
*/
public static String getAdminUserNameFromTenantId(RealmService realmService, int tenantId)
throws Exception {
if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
return realmService.getBootstrapRealmConfiguration().getAdminUserName();
}
String tenantAdminName ="";
try {
if (realmService.getTenantManager().getTenant(tenantId) != null) {
tenantAdminName = realmService.getTenantManager().getTenant(tenantId).getAdminName();
}
} catch (org.wso2.carbon.user.api.UserStoreException e) {
String msg = "Unable to retrieve the admin name for the tenant with the tenant Id: " +
tenantId;
log.error(msg, e);
throw new Exception(msg, e);
}
return tenantAdminName;
}
示例7: getKeyStores
private KeyStoreData[] getKeyStores(UserRegistry systemRegistry) throws Exception {
KeyStoreAdmin admin = new KeyStoreAdmin(CarbonContext.getThreadLocalCarbonContext()
.getTenantId(), systemRegistry);
boolean isSuperAdmin = MultitenantConstants.SUPER_TENANT_ID == CarbonContext
.getThreadLocalCarbonContext().getTenantId() ? true : false;
return admin.getKeyStores(isSuperAdmin);
}
示例8: getLoggedInUserName
/**
* Gets logged in user's username
*
* @return username
*/
private static String getLoggedInUserName() {
String userName;
if (CarbonContext.getThreadLocalCarbonContext().getTenantId() != MultitenantConstants.SUPER_TENANT_ID) {
userName = CarbonContext.getThreadLocalCarbonContext().getUsername() + "!"
+ CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
} else {
userName = CarbonContext.getThreadLocalCarbonContext().getUsername();
}
return userName.trim();
}
示例9: getUserRoles
/**
* Retrieves the current user's roles given the username.
*
* @param username The username
* @return The user roles
* @throws DataServiceFault
*/
public static String[] getUserRoles(String username) throws DataServiceFault {
RealmService realmService = DataServicesDSComponent.getRealmService();
RegistryService registryService = DataServicesDSComponent.getRegistryService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
if (tenantId < MultitenantConstants.SUPER_TENANT_ID) {
tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
}
if (tenantId < MultitenantConstants.SUPER_TENANT_ID) {
/* the tenant doesn't exist. */
log.error("The tenant doesn't exist. Tenant domain:" + tenantDomain);
throw new DataServiceFault("Access Denied. You are not authorized.");
}
if (tenantId != MultitenantConstants.SUPER_TENANT_ID){ //tenant space users can't access super tenant
username = MultitenantUtils.getTenantAwareUsername(username);
}
if (!realmService.getTenantManager().isTenantActive(tenantId)) {
/* the tenant is not active. */
log.error("The tenant is not active. Tenant domain:" + tenantDomain);
throw new DataServiceFault("The tenant is not active. Tenant domain:"
+ tenantDomain);
}
UserRealm realm = registryService.getUserRealm(tenantId);
String roles[] = realm.getUserStoreManager().getRoleListOfUser(username);
return roles;
} catch (Exception e) {
String msg = "Error in retrieving the realm for the tenant id: " + tenantId
+ ", username: " + username + ". " + e.getMessage();
throw new DataServiceFault(msg);
}
}
示例10: getUserRealm
private UserRealm getUserRealm(String username) {
UserRealm userRealm = null;
RealmService realmService = AuthenticationServiceDataHolder.getInstance().getRealmService();
if (null != realmService) {
try {
// Get tenant ID
int tenantID = MultitenantConstants.SUPER_TENANT_ID;
int domainNameSeparatorIndex = username.lastIndexOf(DOMAIN_NAME_SEPARATOR);
PrivilegedCarbonContext.destroyCurrentContext();
PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext();
cc.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
cc.setTenantId(tenantID);
if (-1 != domainNameSeparatorIndex) { // Service case
String domainName = username.substring(domainNameSeparatorIndex + 1);
tenantID = realmService.getTenantManager().getTenantId(domainName);
}
// Get Realm
userRealm = realmService.getTenantUserRealm(tenantID);
} catch (org.wso2.carbon.user.api.UserStoreException e) {
logger.error("Error while getting tenant user realm for user " + username, e);
}
}
return userRealm;
}
示例11: search
@Override
public TermData[] search(Map<String, String> query) throws RegistryException {
int tenantId;
try {
tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
} catch (Exception ignored) {
tenantId = MultitenantConstants.SUPER_TENANT_ID;
}
if (tenantId == MultitenantConstants.INVALID_TENANT_ID) {
tenantId = MultitenantConstants.SUPER_TENANT_ID;
}
return search(tenantId, query);
}
示例12: getRegistry
public UserRegistry getRegistry(int tenantId) {
if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
return registry;
} else {
try {
return Utils.getRegistryService().getRegistry(CarbonConstants.REGISTRY_SYSTEM_USERNAME, tenantId);
} catch (RegistryException ignore) {
return null;
}
}
}
示例13: getCurrentUserTenantId
/**
* This method is to get current user tenant ID, This will be only called when creating data service with
* role based filtering. So a user will invoke this method hence there should be active session when this is
* called.
*
* @return tenantId
* @throws DataServiceFault
*/
public static int getCurrentUserTenantId() throws DataServiceFault {
RealmService realmService = DataServicesDSComponent.getRealmService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
if (tenantId < MultitenantConstants.SUPER_TENANT_ID) {
tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
}
if (tenantId < MultitenantConstants.SUPER_TENANT_ID) {
/* the tenant doesn't exist. */
log.error("The tenant doesn't exist. Tenant domain:" + tenantDomain);
throw new DataServiceFault("Access Denied. You are not authorized.");
}
if (!realmService.getTenantManager().isTenantActive(tenantId)) {
/* the tenant is not active. */
log.error("The tenant is not active. Tenant domain:" + tenantDomain);
throw new DataServiceFault("The tenant is not active. Tenant domain:"
+ tenantDomain);
}
return tenantId;
} catch (Exception e) {
String msg = "Error in retrieving the realm for the tenant id: " + tenantId
+ ". " + e.getMessage();
throw new DataServiceFault(msg);
}
}
示例14: getGovernanceUserRegistry
/**
* Obtains the governance user registry from the given root registry instance. This is useful
* when creating a governance user registry out of a remote client registry instance.
*
* @param registry the remote client registry instance.
* @param username the name of the user to connect as.
* @return the system registry.
* @throws RegistryException throws if an error occurs
*/
@SuppressWarnings("unused")
public static Registry getGovernanceUserRegistry(Registry registry, String username)
throws RegistryException {
if (RegistryContext.getBaseInstance() == null) {
RegistryContext.getBaseInstance(null, false);
}
return new UserRegistry(username, MultitenantConstants.SUPER_TENANT_ID, registry, null,
RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
}
示例15: getTenantIdForDomain
public int getTenantIdForDomain(String tenantDomain) throws UserStoreException {
int tenantId;
TenantManager tenantManager = LoggingServiceComponent.getTenantManager();
if (tenantDomain == null || tenantDomain.equals("")) {
tenantId = MultitenantConstants.SUPER_TENANT_ID;
} else {
tenantId = tenantManager.getTenantId(tenantDomain);
}
return tenantId;
}