本文整理汇总了Java中org.wso2.carbon.user.core.tenant.TenantManager类的典型用法代码示例。如果您正苦于以下问题:Java TenantManager类的具体用法?Java TenantManager怎么用?Java TenantManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TenantManager类属于org.wso2.carbon.user.core.tenant包,在下文中一共展示了TenantManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetServiceProvider
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
@Test
public void testGetServiceProvider() throws Exception {
mockStatic(IdentityTenantUtil.class);
RealmService mockRealmService = mock(RealmService.class);
TenantManager mockTenantManager = mock(TenantManager.class);
when(IdentityTenantUtil.getRealmService()).thenReturn(mockRealmService);
when(mockRealmService.getTenantManager()).thenReturn(mockTenantManager);
when(mockTenantManager.getDomain(anyInt())).thenReturn("test.com");
Properties dummyResourceProperties = new Properties();
dummyResourceProperties.putAll(dummyBasicProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(dummyResourceProperties);
String path = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
when(mockRegistry.resourceExists(path)).thenReturn(true);
when(mockRegistry.get(path)).thenReturn(dummyResource);
SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.getServiceProvider(dummyResource.getProperty
(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
assertEquals(serviceProviderDO.getTenantDomain(), "test.com", "Retrieved resource's tenant domain mismatch");
}
示例2: getTenantIdOFUser
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
private int getTenantIdOFUser(String username) throws UserStoreException {
int tenantId = 0;
String domainName = MultitenantUtils.getTenantDomain(username);
if (domainName != null) {
try {
RealmService service = (RealmService) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getOSGiService(RealmService.class, null);
TenantManager tenantManager = service.getTenantManager();
tenantId = tenantManager.getTenantId(domainName);
} catch (UserStoreException e) {
String errorMsg = "Error when getting the tenant id from the tenant domain : " +
domainName;
log.error(errorMsg, e);
throw e;
}
}
return tenantId;
}
示例3: getAllTenants
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
private List<TenantInfoBean> getAllTenants() throws RestAPIException {
TenantManager tenantManager = ServiceHolder.getTenantManager();
Tenant[] tenants;
try {
tenants = (Tenant[]) tenantManager.getAllTenants();
} catch (Exception e) {
String msg = "Error in retrieving the tenant information";
log.error(msg, e);
throw new RestAPIException(msg);
}
List<TenantInfoBean> tenantList = new ArrayList<TenantInfoBean>();
for (Tenant tenant : tenants) {
TenantInfoBean bean = TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant);
tenantList.add(bean);
}
return tenantList;
}
示例4: searchPartialTenantsDomains
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
private List<TenantInfoBean> searchPartialTenantsDomains(String domain) throws RestAPIException {
TenantManager tenantManager = ServiceHolder.getTenantManager();
Tenant[] tenants;
try {
domain = domain.trim();
tenants = (Tenant[]) tenantManager.getAllTenantsForTenantDomainStr(domain);
} catch (Exception e) {
String msg = "Error in retrieving the tenant information.";
log.error(msg, e);
throw new RestAPIException(msg);
}
List<TenantInfoBean> tenantList = new ArrayList<TenantInfoBean>();
for (Tenant tenant : tenants) {
TenantInfoBean bean = TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant);
tenantList.add(bean);
}
return tenantList;
}
示例5: getAllTenants
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
/**
* Get a list of available Tenants
*
* @return list of available Tenants
* @throws RestAPIException
*/
public static List<org.apache.stratos.common.beans.TenantInfoBean> getAllTenants() throws RestAPIException {
TenantManager tenantManager = ServiceHolder.getTenantManager();
Tenant[] tenants;
try {
tenants = (Tenant[]) tenantManager.getAllTenants();
} catch (Exception e) {
String msg = "Error in retrieving the tenant information";
log.error(msg, e);
throw new RestAPIException(msg);
}
List<org.apache.stratos.common.beans.TenantInfoBean> tenantList
= new ArrayList<org.apache.stratos.common.beans.TenantInfoBean>();
for (Tenant tenant : tenants) {
org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean = ObjectConverter
.convertCarbonTenantInfoBeanToTenantInfoBean(
TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant));
tenantList.add(tenantInfoBean);
}
return tenantList;
}
示例6: searchPartialTenantsDomains
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
/**
* Get List of Partial Tenant Domains
*
* @param domain domain Name
* @return List of Partial Tenant Domains
* @throws RestAPIException
*/
public static List<org.apache.stratos.common.beans.TenantInfoBean> searchPartialTenantsDomains(String domain)
throws RestAPIException {
TenantManager tenantManager = ServiceHolder.getTenantManager();
Tenant[] tenants;
try {
domain = domain.trim();
tenants = (Tenant[]) tenantManager.getAllTenantsForTenantDomainStr(domain);
} catch (Exception e) {
String msg = "Error in retrieving the tenant information.";
log.error(msg, e);
throw new RestAPIException(msg);
}
List<org.apache.stratos.common.beans.TenantInfoBean> tenantList
= new ArrayList<org.apache.stratos.common.beans.TenantInfoBean>();
for (Tenant tenant : tenants) {
org.apache.stratos.common.beans.TenantInfoBean bean = ObjectConverter
.convertCarbonTenantInfoBeanToTenantInfoBean(
TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant));
tenantList.add(bean);
}
return tenantList;
}
示例7: getTenantDomain
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
public static String getTenantDomain(int tenantId) {
if(tenantId == -1234) {
return "carbon.super";
}
TenantManager tenantManager = getTenantManager();
Tenant[] tenants = null;
try {
tenants = (Tenant[]) tenantManager.getAllTenants();
} catch (Exception e) {
String msg = "Error in retrieving the tenant information";
log.error(msg, e);
}
if(tenants != null) {
for(Tenant tenant : tenants) {
if(tenant.getId() == tenantId) {
return tenant.getDomain();
}
}
}
log.warn(String.format("Could not find tenant domain: [tenant-id] %d", tenantId));
return null;
}
示例8: getTenantIdForDomain
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
public static int getTenantIdForDomain(String tenantDomain) throws LogViewerException {
int tenantId;
TenantManager tenantManager = LoggingServiceComponent.getTenantManager();
if (tenantDomain == null || tenantDomain.equals("")) {
tenantId = MultitenantConstants.SUPER_TENANT_ID;
} else {
try {
tenantId = tenantManager.getTenantId(tenantDomain);
} catch (UserStoreException e) {
throw new LogViewerException("Cannot find tenant id for the given tenant domain.");
}
}
return tenantId;
}
示例9: getTenantIdForDomain
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
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;
}
示例10: getTenantDomainFromTID
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
public static String getTenantDomainFromTID(int tenantId) {
String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
TenantManager tenantManager = DataHolder.getInstance().getRealmService().getTenantManager();
try {
tenantDomain = tenantManager.getTenant(tenantId).getDomain();
} catch (UserStoreException e) {
log.error("error while getting tenant" ,e);
}
return tenantDomain;
}
示例11: getTenantId
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
private int getTenantId(String tenantDomain) {
RealmService realmService = RegistryContext.getBaseInstance().getRealmService();
TenantManager mgr = realmService.getTenantManager();
try {
return mgr.getTenantId(tenantDomain);
} catch (UserStoreException e) {
log.error("Identity exception thrown while getting tenantID for : " + tenantDomain, e);
}
return 0;
}
示例12: getTenantsArray
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
/**
* This method returns the list of tenants.
* @return list of tenants
* @throws org.wso2.carbon.user.api.UserStoreException
*/
private List<Tenant> getTenantsArray() throws UserStoreException {
TenantManager tenantManager = ServiceHolder.getRealmService().getTenantManager();
List<Tenant> tenantsArray = new ArrayList<Tenant>(Arrays.asList(tenantManager.getAllTenants()));
Tenant superTenant = new Tenant();
superTenant.setDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
superTenant.setId(MultitenantConstants.SUPER_TENANT_ID);
tenantsArray.add(superTenant);
return tenantsArray;
}
示例13: getTenantsArray
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
private List<Tenant> getTenantsArray() throws UserStoreException {
TenantManager tenantManager = ServiceHolder.getRealmService().getTenantManager();
List<Tenant> tenantsArray = new ArrayList<Tenant>(Arrays.asList(tenantManager.getAllTenants()));
Tenant superTenant = new Tenant();
superTenant.setDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
superTenant.setId(MultitenantConstants.SUPER_TENANT_ID);
tenantsArray.add(superTenant);
return tenantsArray;
}
示例14: getTenantsArray
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
/**
* This method returns the list of tenants.
* @return list of tenants
* @throws UserStoreException
*/
private List<Tenant> getTenantsArray() throws UserStoreException {
TenantManager tenantManager = ServiceHolder.getRealmService().getTenantManager();
List<Tenant> tenantsArray = new ArrayList<Tenant>(Arrays.asList(tenantManager.getAllTenants()));
Tenant superTenant = new Tenant();
superTenant.setDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
superTenant.setId(MultitenantConstants.SUPER_TENANT_ID);
tenantsArray.add(superTenant);
return tenantsArray;
}
示例15: getTenantsArray
import org.wso2.carbon.user.core.tenant.TenantManager; //导入依赖的package包/类
/**
* This method returns the list of tenants.
*
* @return list of tenants
* @throws UserStoreException
*/
private List<Tenant> getTenantsArray() throws UserStoreException {
TenantManager tenantManager = ServiceHolder.getRealmService().getTenantManager();
List<Tenant> tenantsArray = new ArrayList<Tenant>(Arrays.asList(tenantManager.getAllTenants()));
Tenant superTenant = new Tenant();
superTenant.setDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
superTenant.setId(MultitenantConstants.SUPER_TENANT_ID);
tenantsArray.add(superTenant);
return tenantsArray;
}