Examples of UserRegistry


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

            String userName, String resourcePath, HttpServletRequest request)
            throws RegistryException {

        boolean putAllowed = false;

        UserRegistry userRegistry = Utils.getSecureRegistry(request);
        UserRealm userRealm = userRegistry.getUserRealm();

        try {
            if (userRealm.getAuthorizationManager().isUserAuthorized(
                    userName, resourcePath, AccessControlConstants.AUTHORIZE)) {
                putAllowed = true;
View Full Code Here

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

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

        RegistryService registryService = CarbonServicesServiceComponent.getRegistryService();
        UserRegistry userRegistry = registryService.getConfigUserRegistry(username, tenantId);
        UserRegistry governanceUserRegistry =
                registryService.getGovernanceUserRegistry(username, tenantId);
        UserRegistry systemRegistry = registryService.getConfigSystemRegistry(tenantId);
        UserRegistry governanceRegistry = registryService.getGovernanceSystemRegistry(tenantId);
        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']'");

        if(tenantDomain == null){
            log.info("\'" + username + "\' logged in at " +
                    date.format(currentTime) + " from IP address " + remoteAddress);
        } else {
            log.info("\'" + username + "@" + tenantDomain +" [" + tenantId + "]\' logged in at " +
                    date.format(currentTime) + " from IP address " + remoteAddress);
        }

        // trigger the callbacks subscribe to the login event
        LoginSubscriptionManagerServiceImpl loginSubscriptionManagerServiceImpl = CarbonServicesServiceComponent
                .getLoginSubscriptionManagerServiceImpl();
        UserRegistry configRegistry = CarbonServicesServiceComponent.getRegistryService()
                .getConfigSystemRegistry(tenantId);
        loginSubscriptionManagerServiceImpl.triggerEvent(configRegistry, username, tenantId);

        if (log.isDebugEnabled()) {
            log.debug("User Registry instance is set in the session for user " + username);
View Full Code Here

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

                    });

            embeddedRegistryService = registryContext.getEmbeddedRegistryService();

            // create a system registry and put it in the context
            UserRegistry systemRegistry = embeddedRegistryService.getConfigSystemRegistry();

            // add configured handers to the jdbc registry
            // note: no need to do this here. this is done inside the registry context
            //Iterator<HandlerConfiguration> handlers =
            //        registryContext.getHandlerConfigurations().iterator();
            //while (handlers.hasNext()) {
            //    HandlerConfiguration handlerConfiguration = handlers.next();
            //    registryContext.getHandlerManager().addHandler(0,
            //            handlerConfiguration.getFilter(), handlerConfiguration.getHandler());
            //}

            // create system resources

            NodeGroupLock.lock(NodeGroupLock.INITIALIZE_LOCK);

            if (log.isTraceEnabled()) {
                log.trace("Creating system collections used in WSO2 Registry server.");
            }

            if (!systemRegistry.resourceExists("/system")) {

                try {
                    boolean inTransaction = Transaction.isStarted();
                    if (!inTransaction) {
                        systemRegistry.beginTransaction();
                    }
                    Collection systemCollection = systemRegistry.newCollection();
                    String systemDesc = "This collection is used to store system data of the " +
                            "WSO2 Registry server. User nor the admins of the registry are not expected " +
                            "to edit any content of this collection. Changing content of this collection " +
                            "may result in unexpected behaviors.";
                    systemCollection.setDescription(systemDesc);
                    systemRegistry.put("/system", systemCollection);

                    Collection advancedQueryCollection = systemRegistry.newCollection();
                    String advaceDesc = "This collection is used to store auto generated queries " +
                            "to support various combinations of advanced search criteria. " +
                            "This is initialy empty and gets filled as advanced search is " +
                            "executed from the web UI.";
                    advancedQueryCollection.setDescription(advaceDesc);
                    systemRegistry.put("/system/queries/advanced", advancedQueryCollection);
                    if (!inTransaction) {
                        systemRegistry.commitTransaction();
                    }
                } catch (Exception e) {
                    String msg = "Unable to setup system collections used by the Carbon server.";
                    log.error(msg, e);
                    systemRegistry.rollbackTransaction();
                    throw new RegistryException(e.getMessage(), e);
                }
            }

            try {
                AuthorizationManager ac = systemRegistry.getUserRealm().getAuthorizationManager();
                RealmConfiguration realmConfig;
                realmConfig = registryContext.getRealmService().getBootstrapRealmConfiguration();
                String systemUserName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;

View Full Code Here

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

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

    }

    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

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

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

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

        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

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

        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

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

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

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

                                        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
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.