Examples of JahiaUser


Examples of org.jahia.services.usermanager.JahiaUser

        }
    }

    public void initAfterAllServicesAreStarted() throws JahiaInitializationException {
        try {
            JahiaUser jahiaUser = JCRSessionFactory.getInstance().getCurrentUser();
            if (getNbSites() == 0) {
                Locale selectedLocale = LanguageCodeConverters.languageCodeToLocale(systemSiteDefaultLanguage);
                JahiaSite site = addSite(jahiaUser, systemSiteTitle, systemSiteServername, SYSTEM_SITE_KEY, "", selectedLocale,
                        systemSiteTemplateSetName, "noImport", null, null, false, false, null);
                site.setMixLanguagesActive(true);
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

        }

        if (type == null || type.equals("sync")) {
            response.setContentType("text/plain");

            final JahiaUser user = (JahiaUser) request.getSession().getAttribute(ParamBean.SESSION_USER);

            final List<String> pathsToUnzip = new ArrayList<String>();
            for (String filename : uploads.keySet()) {
                final FileItem item = uploads.get(filename);
                try {
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

public class JahiaAdminUser {

    public static Map adminUser = new HashMap();

    public static synchronized JahiaUser getAdminUser(int siteId){
        JahiaUser user = (JahiaUser)adminUser.get(new Integer(siteId));
        if ( user == null ){
            JahiaGroup adminGroup = ServicesRegistry.getInstance().getJahiaGroupManagerService()
                    .lookupGroup(siteId, siteId == 0 ? JahiaGroupManagerService.ADMINISTRATORS_GROUPNAME : JahiaGroupManagerService.SITE_ADMINISTRATORS_GROUPNAME);
            Set members = adminGroup.getRecursiveUserMembers();
            if ( members.iterator().hasNext() ){
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

    public static JahiaSite createSite(String name, String serverName, String templateSet,
                                       String prepackedZIPFile, String siteZIPName) throws Exception {

        ProcessingContext ctx = Jahia.getThreadParamBean();
        JahiaUser admin = JahiaAdminUser.getAdminUser(0);

        JahiaSitesService service = ServicesRegistry.getInstance().getJahiaSitesService();
        JahiaSite site = service.getSiteByKey(name);

        if (site != null) {
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

        try {
            ctx.setOperationMode(ParamBean.EDIT);           
//            ctx.setEntryLoadRequest(new EntryLoadRequest(EntryLoadRequest.STAGING_WORKFLOW_STATE, 0, ctx.getLocales()));

            JahiaUser admin = JahiaAdminUser.getAdminUser(0);
            JCRSessionFactory.getInstance().setCurrentUser(admin);
            ctx.setTheUser(admin);
        } catch (JahiaException e) {
            logger.error("Error getting user", e);
        }
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

        }

        try {
            ctx.setOperationMode(ParamBean.EDIT);
//            ctx.setEntryLoadRequest(new EntryLoadRequest(EntryLoadRequest.STAGING_WORKFLOW_STATE, 0, ctx.getLocales()));
            JahiaUser admin = JahiaAdminUser.getAdminUser(0);
            JCRSessionFactory.getInstance().setCurrentUser(admin);
            ctx.setTheUser(admin);
        } catch (JahiaException e) {
            logger.error("Error getting user", e);
            return;
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

        List<User> r = new ArrayList<User>();
        Enumeration<Principal> en = group.members();
        while (en.hasMoreElements()) {
            Principal p = en.nextElement();
            if (p instanceof JahiaUser) {
                JahiaUser user = (JahiaUser)p;
                r.add(new User(user));
            } else {
                JahiaGroup group = (JahiaGroup)p;
            }
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

                    throw new AccessDeniedException("Content can only be accessed in live");
                }
            }
        }
        if (!"studiomode".equals(renderContext.getEditModeConfigName())) {
            JahiaUser aliasedUser = JCRSessionFactory.getInstance().getCurrentAliasedUser();

            if (node.hasProperty("j:requiredPermissions")) {
                chain.pushAttribute(renderContext.getRequest(),"cache.dynamicRolesAcls",Boolean.TRUE);

                final Value[] values = node.getProperty("j:requiredPermissions").getValues();
                final List<String> perms = JCRTemplate.getInstance().doExecuteWithSystemSession(null, new JCRCallback<List<String>>() {
                    public List<String> doInJCR(JCRSessionWrapper session) throws RepositoryException {
                        List<String> permissionNames = new ArrayList<String>();
                        for (Value value : values) {
                            permissionNames.add(session.getNodeByUUID(value.getString()).getName());
                        }
                        return permissionNames;
                    }
                });
                JCRNodeWrapper contextNode = renderContext.getMainResource().getNode();
                try {
                    if (node.hasProperty("j:contextNodePath")) {
                        String contextPath = node.getProperty("j:contextNodePath").getString();
                        if (!StringUtils.isEmpty(contextPath)) {
                            if (contextPath.startsWith("/")) {
                                contextNode = JCRSessionFactory.getInstance().getCurrentUserSession().getNode(contextPath);
                            } else {
                                contextNode = contextNode.getNode(contextPath);
                            }
                        }
                    }
                } catch (PathNotFoundException e) {
                    return "";
                }
                for (String perm : perms) {
                    if (!contextNode.hasPermission(perm)) {
                        return "";
                    }
                }

                if (aliasedUser != null) {
                    if (!JCRTemplate.getInstance().doExecuteWithUserSession(aliasedUser.getUsername(), node.getSession().getWorkspace().getName(),
                            new JCRCallback<Boolean>() {
                                public Boolean doInJCR(JCRSessionWrapper session) throws RepositoryException {
                                    JCRNodeWrapper aliasedNode = session.getNode(resource.getNode().getPath());
                                    for (String perm : perms) {
                                        if (!aliasedNode.hasPermission(perm)) {
                                            return false;
                                        }
                                    }
                                    return true;
                                }
                            }
                    )) {
                        return "";
                    }
                }

            }
            if (node.hasProperty("j:requireLoggedUser") && node.getProperty("j:requireLoggedUser").getBoolean()) {
                if (!renderContext.isLoggedIn()) {
                    return "";
                }
                if (aliasedUser != null) {
                    if (JahiaUserManagerService.isGuest(aliasedUser)) {
                        return "";
                    }
                }
            }
            if (node.hasProperty("j:requirePrivilegedUser") && node.getProperty("j:requirePrivilegedUser").getBoolean()) {
                if (!renderContext.getUser().isMemberOfGroup(0,JahiaGroupManagerService.PRIVILEGED_GROUPNAME)) {
                    return "";
                }
                if (aliasedUser != null) {
                    if (!aliasedUser.isMemberOfGroup(0, JahiaGroupManagerService.PRIVILEGED_GROUPNAME)) {
                        return "";
                    }
                }
            }
        }
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

        info = ctx != null && ctx.getUser() != null ? ctx.getUser()
                .getUsername() : null;

        if (null == info) {
            // try out session user
            JahiaUser user = null;
            try {
                user = (JahiaUser) request.getSession(true).getAttribute(
                        ProcessingContext.SESSION_USER);
                info = user != null ? user.getUsername() : null;
            } catch (IllegalStateException ex) {
                // ignore it
            }
        }
View Full Code Here

Examples of org.jahia.services.usermanager.JahiaUser

        session.save();
    }

    public void testFullpageWrapper() throws Exception {

        JahiaUser admin = JahiaAdminUser.getAdminUser(0);

        RenderContext context = new RenderContext(paramBean.getRequest(), paramBean.getResponse(), admin);
        context.setSite(site);
        Resource resource = new Resource(node, "html", null, Resource.CONFIGURATION_PAGE);
        context.setMainResource(resource);
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.