本文整理汇总了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);
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}