Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Cookie


        Element cookiesElement = doc.createElementNS(null, "cookies");
        root.appendChild(cookiesElement);

        Cookie[] cookies = this.request.getCookies();
        if (cookies != null) {
            Cookie current;
            Element node;
            Element parent;
            for(int i = 0; i < cookies.length; i++) {
                current = cookies[i];
                parent = doc.createElementNS(null, "cookie");
                parent.setAttributeNS(null, "name", current.getName());
                cookiesElement.appendChild(parent);
                node = doc.createElementNS(null, "comment");
                node.appendChild(this.createTextNode(doc, current.getComment()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "domain");
                node.appendChild(this.createTextNode(doc, current.getDomain()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "maxAge");
                node.appendChild(this.createTextNode(doc, ""+current.getMaxAge()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "name");
                node.appendChild(this.createTextNode(doc, current.getName()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "path");
                node.appendChild(this.createTextNode(doc, current.getPath()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "secure");
                node.appendChild(doc.createTextNode(current.getSecure() ? "true" : "false"));
                parent.appendChild(node);
                node = doc.createElementNS(null, "value");
                node.appendChild(this.createTextNode(doc, current.getValue()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "version");
                node.appendChild(this.createTextNode(doc, ""+current.getVersion()));
                parent.appendChild(node);
            }
        }
    }
View Full Code Here


    /**
     * Build the cookie
     */
    private Cookie createCookie(SourceParameters par) {
        Cookie cookie = this.response.createCookie(par.getParameter("name"),
                                   par.getParameter("value"));
        String value;

        value = par.getParameter("comment");
        if (value != null) cookie.setComment(value);
        value = par.getParameter("domain");
        if (value != null) cookie.setDomain(value);
        value = par.getParameter("path");
        if (value != null) cookie.setPath(value);
        if (par.containsParameter("maxAge") == true) {
            cookie.setMaxAge(par.getParameterAsInteger("maxAge", 0));
        }
        if (par.containsParameter("version") == true) {
            cookie.setVersion(par.getParameterAsInteger("version", 0));
        }
        if (par.containsParameter("secure") == true) {
            cookie.setSecure(par.getParameterAsBoolean("secure", true));
        }
        return cookie;
    }
View Full Code Here

            }
        }

        if (this._useCookies) {
            Request request = ObjectModelHelper.getRequest(objectModel);
            Cookie cookies[] = request.getCookies();
            if (cookies != null) {
                for (int i=0; i<cookies.length; i++) {
                    String name = cookies[i].getName();
                    if (isValidXSLTParameterName(name)) {
                        String value = cookies[i].getValue();
View Full Code Here

            return null;
        }

        cookieValue = parameters.getParameter("value", "");

        Cookie cookie = res.createCookie(cookieName, cookieValue);

        try {
            if ((cookieComment = parameters.getParameter("comment")) != null) {
                cookie.setComment(cookieComment);
            }
        } catch (ParameterException ignore) {
        }

        try {
            if ((cookieDomain = parameters.getParameter("domain")) != null) {
                cookie.setDomain(cookieDomain);
            }
        } catch (ParameterException ignore) {
        }

        try {
            if ((cookiePath = parameters.getParameter("path")) != null) {
                cookie.setPath(cookiePath);
            }
        } catch (ParameterException ignore) {
        }

        cookie.setSecure(parameters.getParameterAsBoolean("secure", false));
        cookie.setMaxAge(parameters.getParameterAsInteger("maxage", 0));
        cookie.setVersion(parameters.getParameterAsInteger("version", 0));

        res.addCookie(cookie);

        if (getLogger().isDebugEnabled()) {
            if (cookie.getMaxAge() == 0) {
                getLogger().debug("COOKIECREATOR: '" + cookieName
                         + "' cookie has been removed");
            } else {
                getLogger().debug("COOKIECREATOR: '" + cookieName
                         + "' cookie created with value '"
                         + cookieValue + "' (version " + cookie.getVersion()
                         + "; it will expire in "
                         + cookie.getMaxAge() + " seconds)");
            }
        }
        return null;
    }
View Full Code Here

            }
        }

        if (this._useCookies) {
            Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
            Cookie cookies[] = request.getCookies();
            if (cookies != null) {
                for (int i=0; i<cookies.length; i++) {
                    String name = cookies[i].getName();
                    if (isValidXSLTParameterName(name)) {
                        String value = cookies[i].getValue();
View Full Code Here

        Cookie[] cookies = request.getCookies();
        HashMap result = null;

        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie cookie = cookies[i];
                if (cookie.getName().equals(pattern)) {
                    result = new HashMap();
                    result.put("1", cookie.getValue());
                    break;
                }
            }
        }
View Full Code Here

            }
        }

        if (this._useCookies) {
            Request request = ObjectModelHelper.getRequest(objectModel);
            Cookie cookies[] = request.getCookies();
            if (cookies != null) {
                for (int i=0; i<cookies.length; i++) {
                    String name = cookies[i].getName();
                    if (isValidXSLTParameterName(name)) {
                        String value = cookies[i].getValue();
View Full Code Here

        // 3. First matching cookie parameter 'locale' within each cookie sent
        Cookie[] cookies = request.getCookies();

        if (cookies != null) {
            for (int i = 0; i < cookies.length; ++i) {
                Cookie cookie = cookies[i];
                if (cookie.getName().equals(LOCALE))
                    return cookie.getValue();
            }
        }

        // 4. Locale setting of the requesting object/server
        return request.getLocale().toString();
View Full Code Here

    /**
     * Build the cookie
     */
    private Cookie createCookie(SourceParameters par) {
        Cookie cookie = this.response.createCookie(par.getParameter("name"),
                                   par.getParameter("value"));
        String value;

        value = par.getParameter("comment");
        if (value != null) cookie.setComment(value);
        value = par.getParameter("domain");
        if (value != null) cookie.setDomain(value);
        value = par.getParameter("path");
        if (value != null) cookie.setPath(value);
        if (par.containsParameter("maxAge") == true) {
            cookie.setMaxAge(par.getParameterAsInteger("maxAge", 0));
        }
        if (par.containsParameter("version") == true) {
            cookie.setVersion(par.getParameterAsInteger("version", 0));
        }
        if (par.containsParameter("secure") == true) {
            cookie.setSecure(par.getParameterAsBoolean("secure", true));
        }
        return cookie;
    }
View Full Code Here

        Element cookiesElement = doc.createElementNS(null, "cookies");
        root.appendChild(cookiesElement);

        Cookie[] cookies = this.request.getCookies();
        if (cookies != null) {
            Cookie current;
            Element node;
            Element parent;
            for(int i = 0; i < cookies.length; i++) {
                current = cookies[i];
                parent = doc.createElementNS(null, "cookie");
                parent.setAttributeNS(null, "name", current.getName());
                cookiesElement.appendChild(parent);
                node = doc.createElementNS(null, "comment");
                node.appendChild(this.createTextNode(doc, current.getComment()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "domain");
                node.appendChild(this.createTextNode(doc, current.getDomain()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "maxAge");
                node.appendChild(this.createTextNode(doc, ""+current.getMaxAge()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "name");
                node.appendChild(this.createTextNode(doc, current.getName()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "path");
                node.appendChild(this.createTextNode(doc, current.getPath()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "secure");
                node.appendChild(doc.createTextNode(current.getSecure() ? "true" : "false"));
                parent.appendChild(node);
                node = doc.createElementNS(null, "value");
                node.appendChild(this.createTextNode(doc, current.getValue()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "version");
                node.appendChild(this.createTextNode(doc, ""+current.getVersion()));
                parent.appendChild(node);
            }
        }
    }
View Full Code Here

TOP

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

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.