Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Session


        this.hasRedirected = true;

        // check if session mode shall be activated
        if (sessionmode) {
            // The session
            Session session = null;
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("redirect: entering session mode");
            }
            String s = request.getRequestedSessionId();
            if (s != null) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Old session ID found in request, id = " + s);
                    if ( request.isRequestedSessionIdValid() ) {
                        getLogger().debug("And this old session ID is valid");
                    }
                }
            }
            // get session from request, or create new session
            session = request.getSession(true);
            if (session == null) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("redirect session mode: unable to get session object!");
                }
            }
            if (getLogger().isDebugEnabled()) {
                getLogger().debug ("redirect: session mode completed, id = " + session.getId() );
            }
        }
        // redirect
        String redirect = this.response.encodeRedirectURL(newURL);
View Full Code Here


        rs = this.Authenticate( conf, req );

        if (rs != null )
        {
          getLogger ().debug ("DBXMLAUTH: authorized successfully");
          Session session = null;

          if (cs) {
            session = req.getSession (false);
            if (session != null)
                session.invalidate ();
            session = req.getSession (true);
            if (session == null)
                return null;
            getLogger ().debug ("DBXMLAUTH: session created");
          } else {
View Full Code Here

    /**
     * @see org.apache.lenya.ac.AccessController#setupIdentity(org.apache.cocoon.environment.Request)
     */
    public void setupIdentity(Request request) throws AccessControlException {
        Session session = request.getSession(true);
        if (!hasValidIdentity(session)) {
            Identity identity = new Identity();
            String remoteAddress = request.getRemoteAddr();
            String clientAddress = request.getHeader("x-forwarded-for");

            if (clientAddress != null) {
                Pattern p = Pattern.compile(REGEX);
                Matcher m = p.matcher(clientAddress);

                if (m.find()) {
                    remoteAddress = m.group();
                }
            }

            getLogger().info("Remote Address to use: [" + remoteAddress + "]");

            Machine machine = new Machine(remoteAddress);
            IPRange[] ranges = accreditableManager.getIPRangeManager().getIPRanges();
            for (int i = 0; i < ranges.length; i++) {
                if (ranges[i].contains(machine)) {
                    machine.addIPRange(ranges[i]);
                }
            }

            identity.addIdentifiable(machine);
            session.setAttribute(Identity.class.getName(), identity);
        }
    }
View Full Code Here

        // Get the parameters in order to check some preconditions (e.g.
        // is the document relly checked out).
        String step = parameters.getParameter("step");
               
        Session session = request.getSession(false);
        RCML rcml = getRc().getRCML(getFilename());
        Identity identity = (Identity) session.getAttribute(Identity.class
                .getName());

        if (step.equals("checkit")) {
            if (rcml.getLatestEntry().getType() != RCML.ci) {
                CheckOutEntry coe = rcml.getLatestCheckOutEntry();
View Full Code Here

     */
    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
        throws ConfigurationException {

        Request request = ObjectModelHelper.getRequest(objectModel);
        Session session = request.getSession();
        Object value = null;

        if (!Arrays.asList(PARAMETER_NAMES).contains(name)) {
            throw new ConfigurationException("The attribute [" + name + "] is not supported!");
        }

        if (session != null) {
            Identity identity = (Identity) session.getAttribute(Identity.class.getName());
            if (identity != null) {
                if (name.equals(USER_ID)) {
                    User user = identity.getUser();
                    if (user != null) {
                        value = user.getId();
View Full Code Here

     * @see org.apache.lenya.ac.Authorizer#authorize(org.apache.cocoon.environment.Request)
     */
    public boolean authorize(Request request)
        throws AccessControlException {

        Session session = request.getSession(true);
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Trying to authorize identity: " + identity);
        }

View Full Code Here

            return null;
        }

        // Get session
        Session session = request.getSession(true);

        if (session == null) {
            getLogger().error("No session object");

            return null;
        }

        // Get creator
        ParentChildCreatorInterface creator = null;
        String absoluteDoctypesPath = sitemapParentPath + doctypesPath;
        Document doctypesDoc = new SAXReader().read("file:" + absoluteDoctypesPath +
                "doctypes.xconf");
        Attribute creator_src = (Attribute) doctypesDoc.selectSingleNode("/doctypes/doc[@type='" +
                doctype + "']/creator/@src");

        if (creator_src != null) {
            getLogger().info(".act(): Creator found for \"" + doctype + "\": " +
                creator_src.getName() + " " + creator_src.getPath() + " " + creator_src.getValue());

            // now get the constructor that accepts the configuration
            Class creatorClass = Class.forName(creator_src.getValue());
            creator = (ParentChildCreatorInterface) creatorClass.newInstance();
        } else {
            getLogger().warn("No creator found for \"" + doctype +
                "\". DefaultBranchCreator will be taken.");
            creator = new org.apache.lenya.cms.authoring.DefaultBranchCreator();
        }

        getLogger().debug(".act(): Creator : " + creator.getClass().getName());

        // Init creator
        // "Read" the configuration from the DOM node
        DefaultConfigurationBuilder defaultConfigBuilder = new DefaultConfigurationBuilder();
        Configuration[] docTypeConfigs = defaultConfigBuilder.buildFromFile(absoluteDoctypesPath +
                "doctypes.xconf").getChildren();

        Configuration doctypeConf = null;

        for (int i = 0; i < docTypeConfigs.length; i++) {
            String typeName = docTypeConfigs[i].getAttribute("type");

            if (typeName.equals(doctype)) {
                doctypeConf = docTypeConfigs[i].getChild("creator", false);
            }
        }

        creator.init(doctypeConf);

        // Transaction should actually be started here!
        String treefilename = sitemapParentPath + treeAuthoringPath;
        getLogger().debug(".act(): Filename of tree: " + treefilename);

        if (!new File(treefilename).exists()) {
            getLogger().warn("No sitetree or topic map: " + treefilename);
        } else {
            if (!updateTree(childtype, childType, childid, childname, parentid, doctype, creator, treefilename)) return null;
        }
        // Transaction should actually be finished here!


        // Create actual document
        // grab all the parameters from session, request params and
        // sitemap params
        HashMap allParameters = new HashMap();
        String[] names = parameters.getNames();

        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            String value = null;

            try {
                value = parameters.getParameter(name);
            } catch (ParameterException pe) {
                value = null;
            }

            allParameters.put(name, value);
        }

        Enumeration requestParameters = request.getParameterNames();

        while (requestParameters.hasMoreElements()) {
            String requestParameterName = (String) requestParameters.nextElement();

            if (allParameters.containsKey(requestParameterName)) {
                // we do not allow name clashes
                throw new ProcessingException("Name clash in request parameter " +
                    "and sitemap parameter: " + requestParameterName);
            }

            allParameters.put(requestParameterName, request.getParameter(requestParameterName));
        }

        Enumeration sessionAttributeNames = session.getAttributeNames();

        while (sessionAttributeNames.hasMoreElements()) {
            String sessionAttributeName = (String) sessionAttributeNames.nextElement();

            if (allParameters.containsKey(sessionAttributeName)) {
                // we do not allow name clashes
                throw new ProcessingException("Name clash in session attribute " +
                    "and request parameter or sitemap parameter: " + sessionAttributeName);
            }

            allParameters.put(sessionAttributeName, session.getAttribute(sessionAttributeName));
        }

        try {
            Publication publication = PublicationFactory.getPublication(objectModel);
            creator.create(publication, new File(absoluteDoctypesPath + "samples"),
                new File(sitemapParentPath + docsPath + parentid), parentid, childid, childType, childname, language,
                allParameters);
        } catch (Exception e) {
            getLogger().error("Creator threw exception: " + e);
        }

        // Redirect to referer
        String parent_uri = (String) session.getAttribute(
                "org.apache.lenya.cms.cocoon.acting.ParentChildCreatorAction.parent_uri");
        getLogger().info(".act(): Child added");

        HashMap actionMap = new HashMap();
        actionMap.put("parent_uri", parent_uri);
        session.removeAttribute(
            "org.apache.lenya.cms.cocoon.acting.ParentChildCreatorAction.parent_uri");

        return actionMap;
    }
View Full Code Here

        try {
            roles = PolicyAuthorizer.getRoles(request);
        } catch (AccessControlException e) {
            throw new WorkflowException(e);
        }
        Session session = request.getSession(false);
        if (session == null) {
            throw new WorkflowException("Session not initialized!");
        }
        Identity identity = Identity.getIdentity(session);
       
View Full Code Here

     * @return A situation.
     * @throws AccessControlException when something went wrong.
     */
    public Situation getSituation(FOM_Cocoon cocoon) throws AccessControlException {
        Request request = ObjectModelHelper.getRequest(cocoon.getObjectModel());
        Session session = request.getSession();
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());

        String userId = "";
        String ipAddress = "";

        User user = identity.getUser();
View Full Code Here

        String eventName = request.getParameter(WorkflowInvoker.EVENT_REQUEST_PARAMETER);
        if (eventName == null) {
          eventName = request.getParameter(WorkflowInvoker.LENYA_EVENT_REQUEST_PARAMETER);
        }
        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) {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.environment.Session

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.