Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Identity


        }

        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


        // Replace title
        du.setElementValue(doc, "/echo:entry/echo:title", (String)parameters.get("title"));

        // Replace author
        Identity identity = (Identity)parameters.get("org.apache.lenya.ac.Identity");
        du.setElementValue(doc, "/echo:entry/echo:author/echo:name", identity.getUser().getId());

        // Replace date created (and issued and modified, FIXME: issued should be set during first time publishing, modified should be set during re-publishing)
        DateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        DateFormat ofsfmt = new SimpleDateFormat("Z");
View Full Code Here

        element = (Element) XPathAPI.selectSingleNode(parent,
                "/*[local-name() = 'entry']/*[local-name() = 'summary']");
        DocumentHelper.setSimpleElementText(element, "Summary");

        // Replace author
        Identity identity = (Identity) parameters.get(Identity.class.getName());

        element = (Element) XPathAPI.selectSingleNode(parent,
                "/*[local-name() = 'entry']/*[local-name() = 'author']/*[local-name() = 'name']");

        if (element == null) {
            throw new RuntimeException("Element entry/author/name not found.");
        }

        DocumentHelper.setSimpleElementText(element, identity.getUser().getId());

        // Replace date created (and issued and modified, FIXME: issued should be set during first
        // time publishing, modified should be set during re-publishing)
        DateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        DateFormat ofsfmt = new SimpleDateFormat("Z");
View Full Code Here

    protected Identity getIdentity() throws AccessControlException {
        DefaultAccessController controller = getAccessController();
        User user = controller.getAccreditableManager().getUserManager().getUser(USERNAME);
        assertNotNull(user);

        Identity identity = new Identity();
        identity.enableLogging(getLogger());
        identity.addIdentifiable(user);

        return identity;
    }
View Full Code Here

        setParameter(USERS, userList);
       
        Request request = ContextHelper.getRequest(getContext());
        Session session = request.getSession(false);
        if (session != null) {
            Identity identity = (Identity) session.getAttribute(Identity.class.getName());
            if (identity != null) {
                setParameter(CURRENT_USER, identity.getUser());
            }
        }
       
        UserType[] types = getUserManager().getUserTypes();
        setParameter(USER_TYPES, Arrays.asList(types));
View Full Code Here

            for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
                assertNotNull(instance);

                System.out.println("Current state: " + instance.getCurrentState());

                Identity identity = new Identity();
                User user = getAccreditableManager().getUserManager().getUser(
                        situations[situationIndex].getUser());
                identity.addIdentifiable(user);

                Role[] roles = policy.getRoles(identity);
                System.out.print("Roles:");

                for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                    System.out.print(" " + roles[roleIndex]);
                }

                System.out.println();
               
                String[] roleIds = new String[roles.length];
                for (int i = 0; i < roles.length; i++) {
                    roleIds[i] = roles[i].getId();
                }

                situation = new CMSSituation(roleIds, identity.getUser().getId(), "");

                String[] events = instance.getExecutableEvents(situation);

                String event = null;
                System.out.print("Events:");
View Full Code Here

     * Tests the identity.
     *
     * @throws AccessControlException if an error occurs
     */
    public void testIdentity() throws AccessControlException {
        Identity identity = new Identity();
        User user = getAccessController().getAccreditableManager().getUserManager().getUser(USER_ID);
        System.out.println("Adding user to identity: [" + user + "]");
        identity.addIdentifiable(user);
       
        assertSame(user, identity.getUser());
    }
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("-bxe");

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

            int l = documentid.length();
            int bxLength = "-bxe".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);
                }
            }

            Document srcDoc = map.get(publication, document.getArea(), documentid, language);
            File newFile = srcDoc.getFile();
            this.filename = newFile.getCanonicalPath();

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

        this.filename = this.filename.substring(publicationPath.length());

        this.username = null;

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

        if (eventName != null) {
            Session session = request.getSession(false);
            if (session == null) {
                log.debug("No session found - not enabling workflow handling.");
            } else {
                Identity identity = Identity.getIdentity(session);
                if (identity == null) {
                    log.debug("No identity found - not enabling workflow handling.");
                } else {
                    log.debug("Identity found - enabling workflow handling.");
                    Role[] roles;
View Full Code Here

        if (notificationMap.getMap().isEmpty()) {
            log.debug("    No notification parameters found.");
        } else {
            log.debug("    Initializing notification");

            Identity identity = Identity.getIdentity(request.getSession());
            User user = identity.getUser();
            String eMail = user.getEmail();
            notificationMap.put(Notifier.PARAMETER_FROM, eMail);
            log.debug("    Setting from address [" + Notifier.PARAMETER_FROM + "] = [" + eMail
                    + "]");
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.