Java Code Examples for org.wso2.carbon.context.PrivilegedCarbonContext#getTenantDomain()
The following examples show how to use
org.wso2.carbon.context.PrivilegedCarbonContext#getTenantDomain() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatisticsAxis2ConfigurationContextObserver.java From carbon-commons with Apache License 2.0 | 6 votes |
public void createdConfigurationContext(ConfigurationContext configurationContext) { AxisConfiguration axisConfig = configurationContext.getAxisConfiguration(); try { if (axisConfig.getModule(StatisticsConstants.STATISTISTICS_MODULE_NAME) != null) { axisConfig.engageModule(StatisticsConstants.STATISTISTICS_MODULE_NAME); } } catch (Throwable e) { PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String msg; if (carbonContext.getTenantDomain() != null) { msg = "Could not globally engage " + StatisticsConstants.STATISTISTICS_MODULE_NAME + " module to tenant " + carbonContext.getTenantDomain() + "[" + carbonContext.getTenantId() + "]"; } else { msg = "Could not globally engage " + StatisticsConstants.STATISTISTICS_MODULE_NAME + " module to super tenant "; } log.error(msg, e); } }
Example 2
Source File: AbstractApi.java From attic-stratos with Apache License 2.0 | 6 votes |
protected ConfigurationContext getConfigContext() { // If a tenant has been set, then try to get the ConfigurationContext of that tenant PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext.getOSGiService(ConfigurationContextService.class); ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext(); String domain = carbonContext.getTenantDomain(); if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) { return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext); } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) { return mainConfigContext; } else { throw new UnsupportedOperationException("Tenant domain unidentified. " + "Upstream code needs to identify & set the tenant domain & tenant ID. " + " The TenantDomain SOAP header could be set by the clients or " + "tenant authentication should be carried out."); } }
Example 3
Source File: ServiceUtils.java From product-private-paas with Apache License 2.0 | 6 votes |
private static ConfigurationContext getConfigContext() { // If a tenant has been set, then try to get the ConfigurationContext of that tenant PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext .getOSGiService(ConfigurationContextService.class); ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext(); String domain = carbonContext.getTenantDomain(); if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) { return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext); } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) { return mainConfigContext; } else { throw new UnsupportedOperationException("Tenant domain unidentified. " + "Upstream code needs to identify & set the tenant domain & tenant ID. " + " The TenantDomain SOAP header could be set by the clients or " + "tenant authentication should be carried out."); } }
Example 4
Source File: AbstractAdmin.java From product-private-paas with Apache License 2.0 | 6 votes |
protected ConfigurationContext getConfigContext() { // If a tenant has been set, then try to get the ConfigurationContext of that tenant PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext .getOSGiService(ConfigurationContextService.class); ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext(); String domain = carbonContext.getTenantDomain(); if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) { return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext); } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) { return mainConfigContext; } else { throw new UnsupportedOperationException("Tenant domain unidentified. " + "Upstream code needs to identify & set the tenant domain & tenant ID. " + " The TenantDomain SOAP header could be set by the clients or " + "tenant authentication should be carried out."); } }
Example 5
Source File: DeviceMgtAPIUtils.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
public static String getAuthenticatedUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); String tenantDomain = threadLocalCarbonContext.getTenantDomain(); if (username != null && username.endsWith(tenantDomain)) { return username.substring(0, username.lastIndexOf("@")); } return username; }
Example 6
Source File: DeviceMgtAPIUtils.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
public static String getAuthenticatedUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); String tenantDomain = threadLocalCarbonContext.getTenantDomain(); if (username != null && username.endsWith(tenantDomain)) { return username.substring(0, username.lastIndexOf("@")); } return username; }
Example 7
Source File: APIUtil.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
public static String getAuthenticatedUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); String tenantDomain = threadLocalCarbonContext.getTenantDomain(); if (username.endsWith(tenantDomain)) { return username.substring(0, username.lastIndexOf("@")); } return username; }
Example 8
Source File: APIUtil.java From product-iots with Apache License 2.0 | 5 votes |
public static String getAuthenticatedUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); String tenantDomain = threadLocalCarbonContext.getTenantDomain(); if (username.endsWith(tenantDomain)) { return username.substring(0, username.lastIndexOf("@")); } return username; }
Example 9
Source File: APIUtil.java From product-iots with Apache License 2.0 | 5 votes |
/** * @return username of the current user */ public static String getAuthenticatedUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); String tenantDomain = threadLocalCarbonContext.getTenantDomain(); if (username.endsWith(tenantDomain)) { return username.substring(0, username.lastIndexOf("@")); } return username; }
Example 10
Source File: APIUtil.java From product-iots with Apache License 2.0 | 5 votes |
public static String getAuthenticatedUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); String tenantDomain = threadLocalCarbonContext.getTenantDomain(); if (username.endsWith(tenantDomain)) { return username.substring(0, username.lastIndexOf("@")); } return username; }
Example 11
Source File: APIUtil.java From carbon-device-mgt with Apache License 2.0 | 4 votes |
public static String getTenantDomainOftheUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); return threadLocalCarbonContext.getTenantDomain(); }
Example 12
Source File: APIUtil.java From product-iots with Apache License 2.0 | 4 votes |
/** * @return tenant domain of the user */ public static String getTenantDomainOftheUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); return threadLocalCarbonContext.getTenantDomain(); }
Example 13
Source File: APIUtil.java From product-iots with Apache License 2.0 | 4 votes |
/** * @return TenantDomain */ public static String getAuthenticatedUserTenantDomain() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); return threadLocalCarbonContext.getTenantDomain(); }
Example 14
Source File: APIUtil.java From product-iots with Apache License 2.0 | 4 votes |
public static String getTenantDomainOftheUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); return threadLocalCarbonContext.getTenantDomain(); }
Example 15
Source File: APIUtil.java From product-iots with Apache License 2.0 | 4 votes |
public static String getAuthenticatedUserTenantDomain() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); return threadLocalCarbonContext.getTenantDomain(); }