Package org.wso2.carbon.context

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


    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

    @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

            }
            username = MultitenantUtils.getTenantAwareUsername(username);
            if (userRealm.getUserStoreManager().authenticate(username, password)) {  // if authenticated

                // setting the correct tenant info for downstream code..
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(tenantDomain);
                carbonContext.setTenantId(tenantId);
                carbonContext.setUsername(username);
                //populate the secuirtyContext of authenticated user
                SecurityContext securityContext = new StratosSecurityContext(username);
                message.put(SecurityContext.class, securityContext);

                // set the authenticated flag and let the request to continue
View Full Code Here

       if(httpSession != null && isUserLoggedIn(httpSession)){ // if sesion is avaialble
           String userName = (String)httpSession.getAttribute("userName");
           String tenantDomain = (String)httpSession.getAttribute("tenantDomain");
           int tenantId = (Integer)httpSession.getAttribute("tenantId");
           // the following will get used by the authorization handler..
           PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
           carbonContext.setUsername(userName);
           carbonContext.setTenantDomain(tenantDomain);
           carbonContext.setTenantId(tenantId);

           AuthenticationContext.setAuthenticated(true);
           if (log.isDebugEnabled()) {
               log.debug("authenticated using the " + CookieBasedAuthenticationHandler.class.getName() + "for username  :" +
                       userName + "tenantDomain : " + tenantDomain + " tenantId : " + tenantId);
View Full Code Here

    @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

*/
public class ServiceHolder {
    private static Log log = LogFactory.getLog(ServiceHolder.class);

    public static TenantManager getTenantManager() {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        RealmService realmService = (RealmService)carbonContext.getOSGiService(RealmService.class);
        return realmService.getTenantManager();
    }
View Full Code Here

        RealmService realmService = (RealmService)carbonContext.getOSGiService(RealmService.class);
        return realmService.getTenantManager();
    }

    public static TenantBillingService getBillingService() {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        TenantBillingService tenantBillingService = (TenantBillingService)carbonContext.getOSGiService(TenantBillingService.class);
        return tenantBillingService;
    }
View Full Code Here

        TenantBillingService tenantBillingService = (TenantBillingService)carbonContext.getOSGiService(TenantBillingService.class);
        return tenantBillingService;
    }

    public static RealmService getRealmService(){
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        RealmService realmService = (RealmService)carbonContext.getOSGiService(RealmService.class);
        return realmService;
    }
View Full Code Here

        RealmService realmService = (RealmService)carbonContext.getOSGiService(RealmService.class);
        return realmService;
    }

    public static RegistryService getRegistryService() {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        RegistryService registryService = (RegistryService) carbonContext.getOSGiService(RegistryService.class);
        return registryService;
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.context.PrivilegedCarbonContext

Copyright © 2018 www.massapicom. 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.