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

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


    }

    public static Resource getResource(HttpServletRequest request, String path)
            throws RegistryException {

        UserRegistry userRegistry = getUserRegistry(request);
        return userRegistry.get(path);
    }
View Full Code Here


    }

    public static UserRegistry getUserRegistry(HttpServletRequest request)
            throws RegistryException {

        UserRegistry userRegistry =
                (UserRegistry) request.getSession()
                        .getAttribute(RegistryConstants.ROOT_REGISTRY_INSTANCE);

        if (userRegistry == null) {
View Full Code Here

     * @throws org.wso2.carbon.registry.core.exceptions.RegistryException
     *          : if something went wrong
     */
    public static synchronized UserRegistry getSecureRegistry(HttpServletRequest request)
            throws RegistryException {
        UserRegistry registry;
        Object o = request.getSession().getAttribute(RegistryConstants.ROOT_REGISTRY_INSTANCE);
        if (o != null) {
            registry = (UserRegistry) o;
        } else {
            EmbeddedRegistryService embeddedRegistryService = (EmbeddedRegistryService) request.
View Full Code Here

        return registry;
    }

    public static boolean isLoggedIn(HttpServletRequest request) {

        UserRegistry userRegistry =
                (UserRegistry) request.getSession()
                        .getAttribute(RegistryConstants.ROOT_REGISTRY_INSTANCE);

        String anonymousUser;
        RegistryContext registryContext = RegistryContext.getBaseInstance();
        if (registryContext != null) {
            anonymousUser = CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME;
        } else {
            return false;
        }
        return userRegistry != null &&
                !userRegistry.getUserName().equals(anonymousUser);
    }
View Full Code Here

        ServletContext context = request.getSession().getServletContext();
        EmbeddedRegistryService embeddedRegistryService =
                (EmbeddedRegistryService) context.getAttribute(RegistryConstants.REGISTRY);

        UserRegistry userRegistry =
                embeddedRegistryService.getConfigUserRegistry(userName, password);

        request.getSession().setAttribute(RegistryConstants.ROOT_REGISTRY_INSTANCE, userRegistry);
    }
View Full Code Here

     * @throws RegistryException if the operation failed.
     */
    public static UserRegistry getRegistry(HttpServletRequest request) throws RegistryException {
        String username = null;
        String password = null;
        UserRegistry registry =
                (UserRegistry) request.getSession().getAttribute(
                        RegistryConstants.ROOT_REGISTRY_INSTANCE);
        String tenantDomain = (String) request.getAttribute(MultitenantConstants.TENANT_DOMAIN);
        int calledTenantId = 0;
        if (tenantDomain != null) {
            try {
                if (RegistryContext.getBaseInstance().getRealmService() == null) {
                    String msg = "Error in getting the tenant manager. " +
                            "The realm service is not available.";
                    log.error(msg);
                    throw new RegistryException(msg);
                }
                calledTenantId = RegistryContext.getBaseInstance().getRealmService().
                        getTenantManager().getTenantId(tenantDomain);

                if (!RegistryContext.getBaseInstance().getRealmService().getTenantManager()
                        .isTenantActive(calledTenantId)) {
                    // the tenant is not active.
                    String msg = "The tenant is not active. Domain: " + tenantDomain + ".";
                    log.error(msg);
                    throw new RegistryException(msg);
                }
            } catch (org.wso2.carbon.user.api.UserStoreException e) {
                String msg = "Error in converting tenant domain to the id for tenant domain: "
                        + tenantDomain + ".";
                log.error(msg);
                throw new RegistryException(msg);
            }
        }
        boolean registryInvalidated = false;
        if (registry != null && registry.getTenantId() != calledTenantId) {
            // invalidate the registry.
            registry = null;
            registryInvalidated = true;
        }
        if (registry == null) {
View Full Code Here

                                        String chroot)
            throws RegistryException {
        try {

            RemoteRegistry userRemote = new RemoteRegistry(url, username, password);
            return new UserRegistry(username, tenantId, userRemote, realmService,
                    RegistryUtils.concatenateChroot(this.chroot, chroot));

        } catch (MalformedURLException e) {
            log.fatal("Registry URL is malformed, Registry configuration must be invalid", e);
            throw new RegistryException("URL is malformed");
View Full Code Here

        return getUserRegistry(userName, tenantId, null);
    }

    public UserRegistry getUserRegistry(String userName, int tenantId, String chroot)
            throws RegistryException {
        return new UserRegistry(userName, tenantId, registry, realmService,
                RegistryUtils.concatenateChroot(this.chroot, chroot));
    }
View Full Code Here

            log.error(msg);
            throw new RegistryException(msg);
        }
        // first we will get an anonymous user registry associated with the tenant
        realmService.getBootstrapRealmConfiguration();
        UserRegistry anonymousUserRegistry = new UserRegistry(
                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME,
                tenantId,
                registry,
                realmService,
                null);
        return anonymousUserRegistry.getUserRealm();
    }
View Full Code Here

    // Test each registry has different virtual roots
    public void testVirtualRoots() throws Exception {

        RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
        UserRegistry registry1 =
                embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 0);
        Resource r = registry1.newResource();
        registry1.put("/test", r);

        r = registry1.get("/");
        r.addProperty("name", "value");
        registry1.put("/", r);

        UserRegistry registry2 =
                embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 1);
        r = registry2.get("/");
        Properties p = r.getProperties();
        assertEquals("The properties in the second registry should be 0", p.size(), 0);

        boolean notExist = false;
        try {
            registry2.get("/test");
        } catch (ResourceNotFoundException e) {
            notExist = true;
        }
        assertTrue("The /test should be null in the second registry", notExist);
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.