Package org.wso2.carbon.registry.core.session

Examples of org.wso2.carbon.registry.core.session.UserRegistry


    public static void beginFileTansfer(File rootDirectory, int tenantId) throws RegistryException {

        // Storing the root path for future reference
        String rootPath = rootDirectory.getAbsolutePath();

        UserRegistry registry = getRegistry(tenantId);

        // Creating the default gadget collection resource
        Collection defaultGadgetCollection = registry.newCollection();
        try {
            registry.beginTransaction();
            registry.put(REGISTRY_GADGET_STORAGE_PATH, defaultGadgetCollection);

            transferDirectoryContentToRegistry(rootDirectory, registry, rootPath, tenantId);
            registry.commitTransaction();
        } catch (Exception e) {
            registry.rollbackTransaction();
            log.error(e.getMessage(), e);
        }

    }
View Full Code Here


                        registry.put(directoryRegistryPath, newCollection);
                    }

                    // Set permission for anonymous read. We do it here because it should happen always in order
                    // to support mounting a remote registry.
                    UserRegistry userRegistry = getRegistry(tenantId);
                    AuthorizationManager accessControlAdmin =
                            userRegistry.getUserRealm().getAuthorizationManager();

                    if (!accessControlAdmin.isRoleAuthorized(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                            REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET)) {
                        accessControlAdmin.authorizeRole(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                                REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET);
View Full Code Here

     * Getting the service either from the Registry service or other means.
     *
     * @return UserRegistry - The registry instance.
     */
    private static UserRegistry getRegistry(int tenantId) {
        UserRegistry registry = null;
        try {
            registry = (UserRegistry) GadgetRepoPopulatorContext.getRegistry(tenantId);
        } catch (Exception e) {
            // During startup, we can't get a registry instance from declarative services.
            // But the deployer gets called. Using instance stored in CarbonContext in that case.
View Full Code Here

    private Log log = LogFactory.getLog(ThrottlingAxis2ConfigurationContextObserver.class);

    public void createdConfigurationContext(ConfigurationContext configurationContext) {
        int tenantId = TenantUtils.getTenantId(configurationContext);
        try {
            UserRegistry registry =
                    ThrottleServiceComponent.getRegistryService().getConfigSystemRegistry(tenantId);
            ThrottlingUtils.saveTemplatePoliciesToRegistry(registry);
        } catch (Exception e) {
            log.error("Could not persist throttling templat policies for tenant " + tenantId);
        }
View Full Code Here

    private boolean isKeyStoreExisting(String keyStorePath) throws ServerException {
        String keyStoreName = new File(keyStorePath).getName();
        String keyStoreLocation = SecurityConstants.KEY_STORES + "/" + keyStoreName;
        boolean isKeyStoreExisting = false;
        try {
            UserRegistry govRegistry = IdentityProviderServiceComponent.getRegistryService().
                    getGovernanceSystemRegistry();
            if(govRegistry.resourceExists(keyStoreLocation)){
                isKeyStoreExisting = true;
            }
        } catch (RegistryException e) {
            String errorMsg = "Error when checking the existence of " + keyStorePath + " in the Governance" +
                              "Registry.";
View Full Code Here

//                tenantId = MultitenantUtils.getTenantId(DashboardContext.getConfigContext());
//            } catch (Exception e) {
//                throw new DeploymentException(e);
//            }

            UserRegistry registry = getRegistry(tenantID);

            // Extracting archive
            String extractedArchiveDir = extractGarArchive(deploymentFileData.getAbsolutePath());

            // Set permission for anonymous read. We do it here because it should happen always in order
            // to support mounting a remote registry.

            if (registry != null) {
                AuthorizationManager accessControlAdmin =
                        registry.getUserRealm().getAuthorizationManager();

                if (!accessControlAdmin.isRoleAuthorized(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                        REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET)) {
                    accessControlAdmin.authorizeRole(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                            REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET);
View Full Code Here

    public static void beginFileTansfer(File rootDirectory, int tenantId) throws RegistryException {

        // Storing the root path for future reference
        String rootPath = rootDirectory.getAbsolutePath();

        UserRegistry registry = getRegistry(tenantId);

        // Creating the default gadget collection resource
        Collection defaultGadgetCollection = registry.newCollection();
        try {
            registry.beginTransaction();
            registry.put(REGISTRY_GADGET_STORAGE_PATH, defaultGadgetCollection);

            transferDirectoryContentToRegistry(rootDirectory, registry, rootPath, tenantId);
            registry.commitTransaction();
        } catch (Exception e) {
            registry.rollbackTransaction();
            log.error(e.getMessage(), e);
        }

    }
View Full Code Here

                        registry.put(directoryRegistryPath, newCollection);
                    }

                    // Set permission for anonymous read. We do it here because it should happen always in order
                    // to support mounting a remote registry.
                    UserRegistry userRegistry = getRegistry(tenantId);
                    AuthorizationManager accessControlAdmin =
                            userRegistry.getUserRealm().getAuthorizationManager();

                    if (!accessControlAdmin.isRoleAuthorized(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                            REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET)) {
                        accessControlAdmin.authorizeRole(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                                REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET);
View Full Code Here

     * Getting the service either from the Registry service or other means.
     *
     * @return UserRegistry - The registry instance.
     */
    private static UserRegistry getRegistry(int tenantId) {
        UserRegistry registry = null;
        try {
            // registry = (UserRegistry) DashboardContext.getRegistry(tenantId);
            // int tID = SuperTenantCarbonContext.getCurrentContext().getTenantId();
            registry = (UserRegistry) DashboardContext.getRegistry(tenantId);

View Full Code Here

        try {
            int tenantId =
                           SuperTenantCarbonContext.getCurrentContext(axisConfiguration)
                                                   .getTenantId();
            Collection<SecurityScenario> scenarios = SecurityScenarioDatabase.getAllScenarios();
            UserRegistry tenantUserRegistry =
                                              IdentitySTSMgtServiceComponent.getRegistryService()
                                                                            .getConfigSystemRegistry(tenantId);
            for (Iterator<SecurityScenario> ite = scenarios.iterator(); ite.hasNext();) {
                SecurityScenario scenario = ite.next();
                String scenarioId = scenario.getScenarioId();
                if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
                        !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                    String resourceUri = SecurityConstants.SECURITY_POLICY + "/" + scenarioId;
                    if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
                            !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                        Resource scenarioResource = tenantUserRegistry.newResource();
                        URL resource =
                                       IdentitySTSMgtServiceComponent.getBundleContext().
                                                                      getBundle().
                                                                      getResource(scenarioId +
                                                                                  "-policy.xml");
                        if (resource != null) {
                            scenarioResource.setContentStream(resource.openStream());
                            tenantUserRegistry.put(resourceUri, scenarioResource);
                        } else {
                            log.error("Could not load policy scenario " + scenarioId +
                                      " for tenant " + tenantId);
                        }
                    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.session.UserRegistry

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.