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


Java PrivilegedCarbonContext.setTenantDomain方法代码示例

本文整理汇总了Java中org.wso2.carbon.context.PrivilegedCarbonContext.setTenantDomain方法的典型用法代码示例。如果您正苦于以下问题:Java PrivilegedCarbonContext.setTenantDomain方法的具体用法?Java PrivilegedCarbonContext.setTenantDomain怎么用?Java PrivilegedCarbonContext.setTenantDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.context.PrivilegedCarbonContext的用法示例。


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

示例1: startTenantFlow

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的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: get

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的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

示例3: contains

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的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

示例4: addToCache

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的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

示例5: getValueFromCache

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的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

示例6: clearCacheEntry

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的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

示例7: clear

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的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

示例8: bundleChanged

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
@Override
public void bundleChanged(BundleEvent event) {
    Bundle bundle = event.getBundle();
    try {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

        if (event.getType() == BundleEvent.STARTED) {
            addUIPermissionFromBundle(bundle);
        }
    } catch (Exception e) {
        log.error("Error occured when processing component xml in bundle " +
                bundle.getSymbolicName(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:17,代码来源:ManagementPermissionsAdder.java

示例9: run

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public void run() {

        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext context = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        context.setTenantDomain(tenantDomain);
        context.setTenantId(tenantId);
        context.setUsername(userName);
        try {
            publish();
        } finally {
            PrivilegedCarbonContext.endTenantFlow();
        }

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

示例10: put

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public void put(int key, EntitlementEngine engine) {
    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        getEntitlementCache().put(key, engine);
        if (log.isDebugEnabled()) {
            log.debug("Cache : " + ENTITLEMENT_ENGINE_CACHE + " is populated with new entry " +
                    "with tenantId : " + key);
        }
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:16,代码来源:EntitlementEngineCache.java

示例11: destroySpProvConnectors

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
private void destroySpProvConnectors(String applicationName, String tenantDomain) {

        try {

            PrivilegedCarbonContext.startTenantFlow();
            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
                    .getThreadLocalCarbonContext();
            carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
            carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);

            // reading from the cache
            ServiceProviderProvisioningConnectorCacheKey key =
                    new ServiceProviderProvisioningConnectorCacheKey(applicationName, tenantDomain);

            ServiceProviderProvisioningConnectorCacheEntry entry = ServiceProviderProvisioningConnectorCache
                    .getInstance().getValueFromCache(key);

            // cache hit
            if (entry != null) {
                ServiceProviderProvisioningConnectorCache.getInstance().clearCacheEntry(key);
                if (log.isDebugEnabled()) {
                    log.debug("Provisioning cached entry removed for sp " + applicationName);
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("Provisioning cached entry not found for sp " + applicationName);
                }
            }

        } finally {
            PrivilegedCarbonContext.endTenantFlow();
        }

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

示例12: onSuccessLogin

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
private void onSuccessLogin(ThriftSession authSession) throws IdentityException {

        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();

        try {
            carbonContext.setUsername((String) (authSession.getAttribute(ServerConstants.AUTHENTICATION_SERVICE_USERNAME)));
            carbonContext.setTenantDomain((String) (authSession.getAttribute(MultitenantConstants.TENANT_DOMAIN)));
            carbonContext.setTenantId((Integer) (authSession.getAttribute(MultitenantConstants.TENANT_ID)));
        } catch (Exception e) {
            String authErrorMsg = "Error populating current carbon context from thrift auth session: " + e.getMessage();
            throw IdentityException.error(authErrorMsg);
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:14,代码来源:ThriftAuthenticatorServiceImpl.java

示例13: start

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public void start(BundleContext bc, RegistryService registryService) throws Exception {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

    addPermissions(registryService);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:8,代码来源:UserMgtInitializer.java

示例14: isTenantDataService

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static boolean isTenantDataService(org.apache.axis2.context.MessageContext messageContext) throws
        AxisFault {
    String url = (String) messageContext.getProperty("TransportInURL");
    if (url != null) {
        if (url.contains(messageContext.getConfigurationContext().getServicePath() + "/t/")) {
            String tenantDomain = TenantAxisUtils.getTenantDomain(url);
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext
                        .getThreadLocalCarbonContext();
                privilegedCarbonContext.setTenantDomain(tenantDomain, true);
                url = url.substring(url.indexOf(tenantDomain));
                AxisService axisService = getTenantAxisService(tenantDomain, url);
                if (axisService != null) {
                    URL file = axisService.getFileName();
                    if (file != null) {
                        String filePath = file.getPath();
                        return filePath.endsWith(".dbs");
                    }
                }
            } finally {
                PrivilegedCarbonContext.endTenantFlow();
            }
        }
    }
    return false;
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:28,代码来源:Utils.java

示例15: invoke

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
@Override
public void invoke(Request request, Response response, CompositeValve compositeValve) {

    if (this.isContextSkipped(request) ||  this.skipAuthentication(request)) {
        this.getNext().invoke(request, response, compositeValve);
        return;
    }

    WebappAuthenticator authenticator = WebappAuthenticatorFactory.getAuthenticator(request);
    if (authenticator == null) {
        String msg = "Failed to load an appropriate authenticator to authenticate the request";
        AuthenticationFrameworkUtil.handleResponse(request, response, HttpServletResponse.SC_UNAUTHORIZED, msg);
        return;
    }
    AuthenticationInfo authenticationInfo = authenticator.authenticate(request, response);
    if (isManagedAPI(request) && (authenticationInfo.getStatus() == WebappAuthenticator.Status.CONTINUE ||
            authenticationInfo.getStatus() == WebappAuthenticator.Status.SUCCESS)) {
        WebappAuthenticator.Status status = WebappTenantAuthorizer.authorize(request, authenticationInfo);
        authenticationInfo.setStatus(status);
    }
    if (authenticationInfo.getTenantId() != -1) {
        try {
            PrivilegedCarbonContext.startTenantFlow();
            PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
            privilegedCarbonContext.setTenantId(authenticationInfo.getTenantId());
            privilegedCarbonContext.setTenantDomain(authenticationInfo.getTenantDomain());
            privilegedCarbonContext.setUsername(authenticationInfo.getUsername());
            this.processRequest(request, response, compositeValve, authenticationInfo);
        } finally {
            PrivilegedCarbonContext.endTenantFlow();
        }
    } else {
        this.processRequest(request, response, compositeValve, authenticationInfo);
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:36,代码来源:WebappAuthenticationValve.java


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