Examples of PrivilegedCarbonContext


Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        @Override
        public Map<K, ? extends V> call() throws Exception {
            Map<K, ? extends V> value;
            try {
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(tenantDomain);
                carbonContext.setTenantId(tenantId);
                ArrayList<K> keysNotInStore = new ArrayList<K>();
                for (K key : keys) {
                    if (!cache.containsKey(key)) {
                        keysNotInStore.add(key);
                    }
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        // Get all the caches
        // Get the configurations from the caches
        // Check the timeout policy and clear out old values
        try {
            PrivilegedCarbonContext.startTenantFlow();
            PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext();
            cc.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
            cc.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
            for (CacheImpl cache : caches) {
                cache.runCacheExpiry();
            }
        } catch (Throwable e) {
            log.error("Error occurred while running CacheCleanupTask", e);
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

public class ThrottlingJob implements Job {
    private static final Log log = LogFactory.getLog(ThrottlingJob.class);
    public static final String THROTTLING_TASK_CONTEXT_KEY = "throttlingTask";

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        Task task = (Task) jobExecutionContext.getMergedJobDataMap().get(THROTTLING_TASK_CONTEXT_KEY);
        executeTask(task);
    }
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        return PrivilegedCarbonContext.getCurrentContext(messageContext).getTenantDomain();
    }

    private int getTenantId(MessageContext messageContext) {
        //Ideally this should take from thread local carbon context change this temporary
        PrivilegedCarbonContext carbonContext =
                PrivilegedCarbonContext.getCurrentContext(messageContext);
        int tenantId = carbonContext.getTenantId();
        if (tenantId > -1 || tenantId == MultitenantConstants.SUPER_TENANT_ID) {
            return tenantId;
        }
        String domain = carbonContext.getTenantDomain();
        if (domain == null) {
            SOAPBody soapBody = messageContext.getEnvelope().getBody();
            if (soapBody != null && soapBody.getFirstElement() != null) {
                OMElement usernameElem = soapBody.getFirstElement().getFirstChildWithName(
                        new QName(ServerConstants.AUTHENTICATION_SERVICE_NS,
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

     * @param dataObj object to be persisted.
     */
    public synchronized void persist(FasterLookUpDataHolder dataObj) throws RegistryException {
        try {
         
          PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
          ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
          ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
         
            registryService.beginTransaction();

            Resource nodeResource = registryService.newResource();

View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

    }

    public synchronized void persistTopology(Topology topology) throws RegistryException {
        try {
         
          PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
          ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
          ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
         
            registryService.beginTransaction();

            Resource nodeResource = registryService.newResource();
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext


    public synchronized Object retrieve() {

        try {
          PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
          ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
          ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
            Resource resource = registryService.get(
                CloudControllerConstants.CLOUD_CONTROLLER_RESOURCE + CloudControllerConstants.DATA_RESOURCE);

            return resource.getContent();
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

    }

    public synchronized Object retrieveTopology() {

        try {
      PrivilegedCarbonContext ctx = PrivilegedCarbonContext
          .getThreadLocalCarbonContext();
      ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
      ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);

      Resource resource = registryService
          .get(CloudControllerConstants.CLOUD_CONTROLLER_RESOURCE
              + CloudControllerConstants.TOPOLOGY_RESOURCE);
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

    private static Log log = LogFactory.getLog(AbstractAdmin.class);

    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 " +
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

    @Produces("application/json")
    @Consumes("application/json")
    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
    public Response getCookie(){
       HttpSession httpSession = httpServletRequest.getSession(true);//create session if not found
       PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
       httpSession.setAttribute("userName",carbonContext.getUsername());
       httpSession.setAttribute("tenantDomain",carbonContext.getTenantDomain());
       httpSession.setAttribute("tenantId",carbonContext.getTenantId());

       String sessionId = httpSession.getId();
        return Response.ok().header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON).
                entity(Utils.buildAuthenticationSuccessMessage(sessionId)).build();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.