Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Identity


     * @see RevisionController#reservedCheckIn(String, String, boolean)
     */
    public void reservedCheckIn(FOM_Cocoon cocoon, boolean backup)
    throws FileReservedCheckInException, Exception
    {
        final Identity identity = (Identity) ObjectModelHelper.getRequest(cocoon.getObjectModel()).getSession().getAttribute(Identity.class.getName());
        final PageEnvelope pageEnvelope = getPageEnvelope(cocoon);
        final Publication publication = getPageEnvelope(cocoon).getPublication();
        final String filename = pageEnvelope.getDocument().getFile().getCanonicalPath().substring(publication.getDirectory().getCanonicalPath().length());  
        getRevisionController(cocoon).reservedCheckIn(filename, identity.getUser().getId(), backup);
    }
View Full Code Here


            getLogger().error(".act(): No session object");

            return null;
        }

        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
        getLogger().debug(".act(): Identity: " + identity);

        //FIXME: hack because of the uri for the editor bitflux. The filename cannot be get from the page-envelope

        String documentid = document.getId();
        int bx = documentid.lastIndexOf("-bxeng");

        if (bx > 0) {
            String language = document.getLanguage();

            int l = documentid.length();
            int bxLength = "-bxeng".length();
            int lang = documentid.lastIndexOf("_", bx);
            int langLength = bx - lang;

            if (bx > 0 && bx + bxLength <= l) {
                documentid = documentid.substring(0, bx) + documentid.substring(bx + bxLength, l);

                if (lang > 0 && langLength + lang < l) {
                    language = documentid.substring(lang + 1, lang + langLength);
                    documentid =
                        documentid.substring(0, lang)
                            + documentid.substring(lang + langLength, l - bxLength);
                }
            }

            DocumentBuilder builder = publication.getDocumentBuilder();

            String srcUrl =
                builder.buildCanonicalUrl(publication, document.getArea(), documentid, language);
            Document srcDoc = builder.buildDocument(publication, srcUrl);
            File newFile = srcDoc.getFile();
            filename = newFile.getCanonicalPath();

        } else {
            filename = document.getFile().getCanonicalPath();
        }

        filename = filename.substring(publicationPath.length());
        log.debug("Filename: " + filename);

        username = null;

        if (identity != null) {
            User user = identity.getUser();
            if (user != null) {
                username = user.getId();
            }
        } else {
            getLogger().error(".act(): No identity yet");
View Full Code Here

            String userId = "";
            Request request = ContextHelper.getRequest(this.context);
            Session session = request.getSession(false);
            if (session != null) {
                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        userId = user.getId();
                        objects.put(UsecaseCronJob.USER_ID, userId);
                    }
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        objects.put(UsecaseCronJob.MACHINE_IP, machine.getIp());
                    }
                }
            }
View Full Code Here

        getRcml().delete();
    }

    protected String getUserId() {
        String userId = null;
        Identity identity = getSession().getIdentity();
        if (identity != null) {
            User user = identity.getUser();
            if (user != null) {
                userId = user.getId();
            }
        }
        return userId;
View Full Code Here

        Iterator userit = allSessions.entrySet().iterator();
        while (userit.hasNext()) {
            Map.Entry entry = (Map.Entry) userit.next();
            HttpSession nextsession = (HttpSession) entry.getValue();

            Identity identity = (Identity) nextsession.getAttribute(IDENTITY);
           
            if(identity == null) {
                continue;
            }  
         
            User user = identity.getUser();
            if (user != null) {
                Vector history = (Vector) nextsession.getAttribute(HISTORY);
                String publicationID = getPublicationIDfromHistory(history);
                if (publicationID.equals(getPublicationIDfromURL())) {
                    userList.add(identity.getUser());
                }
            }
        }
        setParameter(USERS, userList);
    }
View Full Code Here

        Iterator userit = allSessions.entrySet().iterator();
        while (userit.hasNext()) {
            Map.Entry entry = (Map.Entry) userit.next();
            HttpSession nextsession = (HttpSession) entry.getValue();

            Identity identity = (Identity) nextsession.getAttribute(IDENTITY);

            if(identity == null) {
                continue;
            }

            User user = identity.getUser();
            Vector history = (Vector) nextsession.getAttribute(HISTORY);
            String publicationID = getPublicationIDfromHistory(history);
            if (publicationID.equals(pubId) && user != null && user.getId().equals(userId)) {
                loggedIn = true;
            }
View Full Code Here

    protected String encodeVersion(Workflow workflow, Version version) {

        StringBuffer stringBuf = new StringBuffer("event:").append(version.getEvent());
        stringBuf.append(" state:").append(version.getState());

        Identity identity = getSession().getIdentity();
        User user = identity.getUser();
        if (user != null) {
            stringBuf.append(" user:").append(identity.getUser().getId());
        }
        stringBuf.append(" machine:").append(identity.getMachine().getIp());

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
        stringBuf.append(" date:").append(format.format(new Date()));

        String names[] = workflow.getVariableNames();
View Full Code Here

        }

        ac.setupIdentity(getRequest());

        org.apache.cocoon.environment.Session cocoonSession = getRequest().getSession();
        Identity identity = (Identity) cocoonSession.getAttribute(Identity.class.getName());

        if (!identity.contains(user)) {
            User oldUser = identity.getUser();
            if (oldUser != null) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Removing user [" + oldUser + "] from identity.");
                }
                identity.removeIdentifiable(oldUser);
            }
            identity.addIdentifiable(user);
        }

        ac.authorize(getRequest());

        Accreditable[] accrs = identity.getAccreditables();
        for (int i = 0; i < accrs.length; i++) {
            getLogger().info("Accreditable: " + accrs[i]);
        }

        session.setIdentity(identity);
View Full Code Here

     */
    public static Session getSession(ServiceManager manager, Request request)
            throws RepositoryException {
        Session session = (Session) request.getAttribute(Session.class.getName());
        if (session == null) {
            Identity identity = getIdentity(request);
            // attach a read-only repository session to the HTTP request
            session = createSession(manager, identity, false);
            request.setAttribute(Session.class.getName(), session);
        } else if (session.getIdentity() == null) {
            Identity identity = getIdentity(request);
            if (identity != null) {
                session.setIdentity(identity);
            }
        }
        return session;
View Full Code Here

        return session;
    }

    protected static Identity getIdentity(Request request) {
        org.apache.cocoon.environment.Session cocoonSession = request.getSession();
        Identity identity = (Identity) cocoonSession.getAttribute(Identity.class.getName());
        return identity;
    }
View Full Code Here

TOP

Related Classes of org.apache.lenya.ac.Identity

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.