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


Java MultitenantConstants类代码示例

本文整理汇总了Java中org.wso2.carbon.utils.multitenancy.MultitenantConstants的典型用法代码示例。如果您正苦于以下问题:Java MultitenantConstants类的具体用法?Java MultitenantConstants怎么用?Java MultitenantConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MultitenantConstants类属于org.wso2.carbon.utils.multitenancy包,在下文中一共展示了MultitenantConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startTenantFlow

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:FrameworkUtils.java

示例2: getInstance

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:32,代码来源:EntitlementEngine.java

示例3: get

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
public EntitlementEngine get(int key) {
    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        EntitlementEngine entitlementEngine = getEntitlementCache().get(key);
        if (entitlementEngine != null) {
            if (log.isDebugEnabled()) {
                log.debug("Cache : " + ENTITLEMENT_ENGINE_CACHE + "  is HIT " +
                        "for tenantId : " + key);
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Cache : " + ENTITLEMENT_ENGINE_CACHE + "  is MISSED " +
                        "for tenantId : " + key);
            }
        }
        return entitlementEngine;
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:EntitlementEngineCache.java

示例4: contains

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
public boolean contains(int key) {
    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        boolean contain = getEntitlementCache().containsKey(key);
        if (contain) {
            if (log.isDebugEnabled()) {
                log.debug("Cache : " + ENTITLEMENT_ENGINE_CACHE + "  is HIT " +
                        "for tenantId : " + key);
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Cache : " + ENTITLEMENT_ENGINE_CACHE + "  is MISSED " +
                        "for tenantId : " + key);
            }
        }
        return contain;
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:EntitlementEngineCache.java

示例5: getAuthenticatorInfo

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * @param conn
 * @param tenantId
 * @param authenticatorId
 * @return
 * @throws SQLException
 */
private Map<String, String> getAuthenticatorInfo(Connection conn, int tenantId,
                                                 int authenticatorId) throws SQLException {
    PreparedStatement prepStmt = null;
    ResultSet rs = null;
    String sqlStmt = ApplicationMgtDBQueries.LOAD_IDP_AND_AUTHENTICATOR_NAMES;
    Map<String, String> returnData = new HashMap<String, String>();
    try {
        prepStmt = conn.prepareStatement(sqlStmt);
        prepStmt.setInt(1, authenticatorId);
        prepStmt.setInt(2, tenantId);
        prepStmt.setInt(3, tenantId);
        prepStmt.setInt(4, MultitenantConstants.SUPER_TENANT_ID);
        prepStmt.setInt(5, MultitenantConstants.SUPER_TENANT_ID);
        rs = prepStmt.executeQuery();
        while (rs.next()) {
            returnData.put(ApplicationConstants.IDP_NAME, rs.getString(1));
            returnData.put(ApplicationConstants.IDP_AUTHENTICATOR_NAME, rs.getString(2));
            returnData
                    .put(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME, rs.getString(3));
        }
    } finally {
        IdentityApplicationManagementUtil.closeStatement(prepStmt);
    }
    return returnData;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:ApplicationDAOImpl.java

示例6: addToCache

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * Add a cache entry.
 *
 * @param key   Key which cache entry is indexed.
 * @param entry Actual object where cache entry is placed.
 */
public void addToCache(K key, V entry) {
    if (!isEnabled()) {
        return;
    }

    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
                .getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        // Element already in the cache. Remove it first
        Cache<K, V> cache = getBaseCache();
        if (cache != null) {
            cache.put(key, entry);
        }
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:BaseCache.java

示例7: getValueFromCache

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * Retrieves a cache entry.
 *
 * @param key CacheKey
 * @return Cached entry.
 */
public V getValueFromCache(K key) {
    if (!isEnabled()) {
        return null;
    }

    if(key == null) {
        return null;
    }

    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
                .getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        Cache<K, V> cache = getBaseCache();
        if (cache != null && cache.get(key) != null) {
            return (V) cache.get(key);
        }
        return null;
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:31,代码来源:BaseCache.java

示例8: clearCacheEntry

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * Clears a cache entry.
 *
 * @param key Key to clear cache.
 */
public void clearCacheEntry(K key) {
    if (!isEnabled()) {
        return;
    }

    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
                .getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        Cache<K, V> cache = getBaseCache();
        if (cache != null) {
            cache.remove(key);
        }
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:BaseCache.java

示例9: clear

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * Remove everything in the cache.
 */
public void clear() {
    if (!isEnabled()) {
        return;
    }

    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
                .getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        Cache<K, V> cache = getBaseCache();
        if (cache != null) {
            cache.removeAll();
        }
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:BaseCache.java

示例10: getRegistryForAnonymousSession

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static Registry getRegistryForAnonymousSession(String domainName, String username)
        throws IdentityException {
    try {
        if (domainName == null && username == null) {
            domainName = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
        }
        if (username == null) {
            return AnonymousSessionUtil.getSystemRegistryByDomainName(registryService,
                    realmService, domainName);
        } else {
            return AnonymousSessionUtil.getSystemRegistryByUserName(registryService,
                    realmService, username);
        }
    } catch (CarbonException e) {
        log.error("Error obtaining a registry instance", e);
        throw IdentityException.error("Error obtaining a registry instance", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:IdentityTenantUtil.java

示例11: getRealmForAnonymousSession

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
private static UserRealm getRealmForAnonymousSession(String domainName, String username)
        throws IdentityException {

    try {
        if (username != null) {
            return AnonymousSessionUtil.getRealmByUserName(registryService, realmService,
                    username);
        }

        if (domainName == null) {
            domainName = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
        }

        return AnonymousSessionUtil.getRealmByTenantDomain(registryService, realmService,
                domainName);

    } catch (CarbonException e) {
        throw IdentityException.error("Error Obtaining a realm for user name: " + username + " and " +
                "domain:" + domainName, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:IdentityTenantUtil.java

示例12: getTenantId

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
public static int getTenantId(String tenantDomain) throws IdentityRuntimeException {

        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
        try {
            tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
        } catch (UserStoreException e) {
            // Ideally user.core should be throwing an unchecked exception, in which case no need to wrap at this
            // level once more without adding any valuable contextual information. Because we don't have exception
            // enrichment properly implemented, we are appending the error message from the UserStoreException to the
            // new message
            throw IdentityRuntimeException.error("Error occurred while retrieving tenantId for tenantDomain: " +
                    tenantDomain + e.getMessage(), e);
        }
        if(tenantId == MultitenantConstants.INVALID_TENANT_ID){
            throw IdentityRuntimeException.error("Invalid tenant domain " + tenantDomain);
        } else {
            return tenantId;
        }

    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:IdentityTenantUtil.java

示例13: getTenantIdOfUser

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * Get the tenant id of the given user.
 *
 * @param username Username
 * @return Tenant Id of domain user belongs to.
 * @throws IdentityRuntimeException Error when getting the tenant Id from tenant domain
 */
public static int getTenantIdOfUser(String username) throws IdentityRuntimeException {

    int tenantId = MultitenantConstants.INVALID_TENANT_ID;
    String domainName = MultitenantUtils.getTenantDomain(username);
    if (domainName != null) {
        try {
            TenantManager tenantManager = IdentityTenantUtil.getRealmService().getTenantManager();
            tenantId = tenantManager.getTenantId(domainName);
        } catch (UserStoreException e) {
            String errorMsg = "Error when getting the tenant id from the tenant domain : " + domainName;
            throw IdentityRuntimeException.error(errorMsg, e);
        }
    }
    if(tenantId == MultitenantConstants.INVALID_TENANT_ID){
        throw IdentityRuntimeException.error("Invalid tenant domain of user " + username);
    } else {
        return tenantId;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:IdentityTenantUtil.java

示例14: sendEmail

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
private void sendEmail(String userName, int tenantId, String notification) {
    UserRecoveryDTO dto;
    String tenantDomain = IdentityTenantUtil.getTenantDomain(tenantId);

    if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        dto = new UserRecoveryDTO(userName);
    } else {
        UserDTO userDTO = new UserDTO(UserCoreUtil.addTenantDomainToEntry(userName, tenantDomain));
        userDTO.setTenantId(tenantId);
        dto = new UserRecoveryDTO(userDTO);
    }
    dto.setNotification(notification);
    dto.setNotificationType(EMAIL_NOTIFICATION_TYPE);
    try {
        IdentityMgtServiceComponent.getRecoveryProcessor().recoverWithNotification(dto);
    } catch (IdentityException e) {
        //proceed with the rest of the flow even if the email is not sent
        log.error("Email notification sending failed for user:" + userName + " for " + notification);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:IdentityMgtEventListener.java

示例15: getVerifiedChallenges

import org.wso2.carbon.utils.multitenancy.MultitenantConstants; //导入依赖的package包/类
/**
 * gets no of verified user challenges
 *
 * @param userDTO bean class that contains user and tenant Information
 * @return no of verified challenges
 * @throws IdentityException if fails
 */
public static int getVerifiedChallenges(UserDTO userDTO) throws IdentityException {

    int noOfChallenges = 0;

    try {
        UserRegistry registry = IdentityMgtServiceComponent.getRegistryService().
                getConfigSystemRegistry(MultitenantConstants.SUPER_TENANT_ID);
        String identityKeyMgtPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_CHALLENGES +
                RegistryConstants.PATH_SEPARATOR + userDTO.getUserId() +
                RegistryConstants.PATH_SEPARATOR + userDTO.getUserId();

        Resource resource;
        if (registry.resourceExists(identityKeyMgtPath)) {
            resource = registry.get(identityKeyMgtPath);
            String property = resource.getProperty(IdentityMgtConstants.VERIFIED_CHALLENGES);
            if (property != null) {
                return Integer.parseInt(property);
            }
        }
    } catch (RegistryException e) {
        log.error("Error while processing userKey", e);
    }

    return noOfChallenges;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:Utils.java


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