当前位置: 首页>>代码示例>>Java>>正文


Java TenantManager类代码示例

本文整理汇总了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");
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:SAMLSSOServiceProviderDAOTest.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:RestApiRequestAuthorizationHandler.java

示例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;
}
 
开发者ID:apache,项目名称:stratos,代码行数:19,代码来源:StratosApiV40.java

示例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;
}
 
开发者ID:apache,项目名称:stratos,代码行数:20,代码来源:StratosApiV40.java

示例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;
}
 
开发者ID:apache,项目名称:stratos,代码行数:28,代码来源:StratosApiV41Utils.java

示例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;
}
 
开发者ID:apache,项目名称:stratos,代码行数:31,代码来源:StratosApiV41Utils.java

示例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;
}
 
开发者ID:apache,项目名称:stratos,代码行数:25,代码来源:StratosUserManagerUtils.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:16,代码来源:LoggingUtil.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:11,代码来源:CarbonMemoryAppender.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:11,代码来源:HostUtil.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:11,代码来源:AuthenticationHandler.java

示例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;
}
 
开发者ID:wso2,项目名称:product-es,代码行数:15,代码来源:MigrateFrom200to210.java

示例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;
}
 
开发者ID:wso2,项目名称:product-es,代码行数:10,代码来源:ProviderMigrationClient.java

示例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;
}
 
开发者ID:wso2,项目名称:product-es,代码行数:15,代码来源:EmailUserNameMigrationClient.java

示例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;
}
 
开发者ID:wso2,项目名称:product-es,代码行数:16,代码来源:MigrateData.java


注:本文中的org.wso2.carbon.user.core.tenant.TenantManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。