Examples of PrivilegedCarbonContext


Examples of org.wso2.carbon.context.PrivilegedCarbonContext

            }
            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

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

       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

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

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

*/
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

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        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

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        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

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        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

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        TenantPersistor tenantPersistor = new TenantPersistor();
        return tenantPersistor;
    }

    public static ConfigurationContextService getConfigurationContext() {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext.
                getOSGiService(ConfigurationContextService.class);
        return configurationContextService;
    }
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

                persistSubscription(cartridgeSubscription);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
View Full Code Here

Examples of org.wso2.carbon.context.PrivilegedCarbonContext

        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

                removeSubscription(tenantId, type, alias);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
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.