Examples of SuperTenantCarbonContext


Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

        }
    }


    private String getTenantIdAndDomainString(AxisConfiguration axisConfig) {
        SuperTenantCarbonContext carbonContext = SuperTenantCarbonContext.getCurrentContext(axisConfig);
        int tenantId = carbonContext.getTenantId();
        String tenantDomain = carbonContext.getTenantDomain();
        return (tenantId != -1 && tenantId != MultitenantConstants.SUPER_TENANT_ID) ?
                " {" + tenantDomain + "[" + tenantId + "]}" : " {super-tenant}";
    }
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

    }

    private void onUserLogin(String userName, String tenantDomain, HttpSession httpSess)
                                                                                        throws Exception {
        httpSess.setAttribute(ServerConstants.USER_LOGGED_IN, userName);
        SuperTenantCarbonContext carbonContext =
                                                 SuperTenantCarbonContext.
                                                                          getCurrentContext(httpSess);
        carbonContext.setTenantDomain(tenantDomain);
        int tenantId = IdentityRPServiceComponent.getRealmService().getTenantManager().
                                                  getTenantId(tenantDomain);
        carbonContext.setTenantId(tenantId);
        carbonContext.setRegistry(RegistryType.SYSTEM_CONFIGURATION,
                                  IdentityRPServiceComponent.getRegistryService().
                                                             getConfigSystemRegistry(tenantId));
        carbonContext.setRegistry(RegistryType.USER_CONFIGURATION,
                                  IdentityRPServiceComponent.getRegistryService().
                                                             getConfigUserRegistry(userName,
                                                                                   tenantId));
        carbonContext.setRegistry(RegistryType.USER_GOVERNANCE,
                                  IdentityRPServiceComponent.getRegistryService().
                                                             getGovernanceUserRegistry(userName,
                                                                                       tenantId));
        carbonContext.setRegistry(RegistryType.SYSTEM_GOVERNANCE,
                                  IdentityRPServiceComponent.getRegistryService().
                                                             getGovernanceSystemRegistry(tenantId));
        carbonContext.setUserRealm(IdentityRPServiceComponent.getRegistryService().
                                                              getGovernanceUserRegistry(userName,
                                                                                        tenantId).
                                                              getUserRealm());
    }
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

    private void applySecurityParameters(AxisService service, SecurityScenario secScenario) {
        try {

            String serviceName = service.getName();
            SuperTenantCarbonContext carbonContext = SuperTenantCarbonContext.getCurrentContext(service);
            int tenantID = carbonContext.getTenantId();
            String tenantDomain = carbonContext.getTenantDomain();
            String servicePath = RegistryResources.SERVICE_GROUPS
                    + service.getAxisServiceGroup().getServiceGroupName()
                    + RegistryResources.SERVICES + serviceName;
            UserRealm userRealm = AnonymousSessionUtil.getRealmByTenantDomain(
                    SecurityServiceHolder.getRegistryService(), SecurityServiceHolder.getRealmService(), tenantDomain);
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

   
    public static void onFailedAdminLogin(HttpSession httpSess, String username, int tenantId,
            String tenantDomain, String remoteAddress, String reason) throws Exception {

        if (httpSess != null) {
            SuperTenantCarbonContext carbonContext = SuperTenantCarbonContext.getCurrentContext(httpSess);
            carbonContext.setUsername(username);
            carbonContext.setTenantId(tenantId);
            carbonContext.setTenantDomain(tenantDomain);
        }

        Date currentTime = Calendar.getInstance().getTime();
        SimpleDateFormat date = new SimpleDateFormat("'['yyyy-MM-dd HH:mm:ss,SSSS']'");
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

        if (httpSess != null) {
            httpSess.setAttribute(ServerConstants.USER_LOGGED_IN, username);
            httpSess.setAttribute(RegistryConstants.ROOT_REGISTRY_INSTANCE, registryService
                    .getRegistry(username, tenantId));

            SuperTenantCarbonContext carbonContext = SuperTenantCarbonContext.getCurrentContext(httpSess);
            carbonContext.setUsername(username);
            carbonContext.setTenantDomain(tenantDomain);
            carbonContext.setTenantId(tenantId);
            carbonContext.setRegistry(RegistryType.SYSTEM_CONFIGURATION, systemRegistry);
            carbonContext.setRegistry(RegistryType.SYSTEM_GOVERNANCE, governanceRegistry);
            carbonContext.setRegistry(RegistryType.USER_CONFIGURATION, userRegistry);
            carbonContext.setRegistry(RegistryType.USER_GOVERNANCE, governanceUserRegistry);
            carbonContext.setUserRealm(governanceUserRegistry.getUserRealm());
        }

        Date currentTime = Calendar.getInstance().getTime();
        SimpleDateFormat date = new SimpleDateFormat("'['yyyy-MM-dd HH:mm:ss,SSSS']'");
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

                String name = userRegistry.getUserName();
                if (callerTenantId != MultitenantConstants.SUPER_TENANT_ID &&
                        callerTenantId > -1) {
                    try {
                        SuperTenantCarbonContext.startTenantFlow();
                        SuperTenantCarbonContext currentContext =
                                SuperTenantCarbonContext.getCurrentContext();
                        currentContext.setTenantId(callerTenantId, true);
                        String tenantDomain = currentContext.getTenantDomain();
                        if (tenantDomain != null) {
                            name = name + "@" + tenantDomain;
                        }
                    } finally {
                        SuperTenantCarbonContext.endTenantFlow();
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

    public boolean deploySample(String sampleName, String tenantDomain) throws AxisFault,
                                                                               RegistryException {
        SuperTenantCarbonContext.startTenantFlow();

        try {
            SuperTenantCarbonContext carbonContext =
                    SuperTenantCarbonContext.getCurrentContext();
            SuperTenantCarbonContext carbonContextOnMessageContext =
                    SuperTenantCarbonContext.getCurrentContext(
                            MessageContext.getCurrentMessageContext());
            carbonContextOnMessageContext.setTenantDomain(tenantDomain, true);
            BundleContext bundleContext = Util.getBundleContext();

            if (bundleContext != null) {
                ServiceTracker tracker =
                        new ServiceTracker(bundleContext,
                                           TenantRegistryLoader.class.getName(), null);
                tracker.open();
                Object[] services = tracker.getServices();
                if (services != null) {
                    for (Object service : services) {
                        ((TenantRegistryLoader) service).loadTenantRegistry(
                                carbonContextOnMessageContext.getTenantId());
                    }
                }
                tracker.close();
            }
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

     * @param sampleName The name of the sample file to be uploaded to the registry
     * @return true if the operation successfully completed.
     * @throws RegistryException Thrown if an error occurs while accessing the Registry
     */
    public boolean uploadSample(String sampleName) throws RegistryException {
        SuperTenantCarbonContext carbonContext =
                SuperTenantCarbonContext.getCurrentContext();
        Registry registry = (Registry) carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
        try {
            if (registry.resourceExists(getSamplePath(sampleName))) {
                return true;
            }
        } catch (Exception ignored) {
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

     *
     * @return a record containing information on each sample available on the system.
     */
    public SampleInformation[] getSampleInformation() {
        SampleInformation[] samples = Util.getSampleInformation();
        SuperTenantCarbonContext carbonContext =
                SuperTenantCarbonContext.getCurrentContext();
        String tenantDomain = carbonContext.getTenantDomain(true);
        for (SampleInformation sample : samples) {
            String[] services = sample.getServiceEPRs();
            List<String> serviceList = new LinkedList<String>();
            for (String service : services) {
                serviceList.add(service + "/services/");
View Full Code Here

Examples of org.wso2.carbon.core.multitenancy.SuperTenantCarbonContext

                // Setup the Carbon Context so that downstream logic can make use of it.
                // At present, the Event Component makes use of the information stored on the Carbon
                // Context when publishing events.
                SuperTenantCarbonContext.startTenantFlow();
                try {
                    SuperTenantCarbonContext context =
                            SuperTenantCarbonContext.getCurrentContext();
                    int tenantId = event.getTenantId();
                    if (tenantId > -1) {
                        context.setTenantId(tenantId, true);
                    }
                    RegistryEvent.RegistrySession registrySessionDetails =
                            event.getRegistrySessionDetails();
                    if (registrySessionDetails != null) {
                        String username = registrySessionDetails.getUsername();
                        if (username != null) {
                            context.setUsername(username);
                        }
                    }
                    Utils.getRegistryEventBrokerService().publish(event, event.getTopic());
                } finally {
                    SuperTenantCarbonContext.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.