Java Code Examples for java.net.HttpCookie#isHttpOnly()

The following examples show how to use java.net.HttpCookie#isHttpOnly() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpURLConnection.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.isEmpty())
            return value;

        JavaNetHttpCookieAccess access =
                SharedSecrets.getJavaNetHttpCookieAccess();
        StringJoiner retValue = new StringJoiner(",");  // RFC 2965, comma separated
        List<HttpCookie> cookies = access.parse(value);
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (!cookie.isHttpOnly())
                retValue.add(access.header(cookie));
        }
        return retValue.toString();
    }

    return value;
}
 
Example 2
Source File: HttpURLConnection.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 3
Source File: TestHttpCookie.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 4
Source File: HttpURLConnection.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 5
Source File: HttpURLConnection.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 6
Source File: HttpURLConnection.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 7
Source File: TestHttpCookie.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 8
Source File: HttpURLConnection.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 9
Source File: TestHttpCookie.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 10
Source File: HttpURLConnection.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        JavaNetHttpCookieAccess access =
                SharedSecrets.getJavaNetHttpCookieAccess();
        StringJoiner retValue = new StringJoiner(",");  // RFC 2965, comma separated
        List<HttpCookie> cookies = access.parse(value);
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (!cookie.isHttpOnly())
                retValue.add(access.header(cookie));
        }
        return retValue.toString();
    }

    return value;
}
 
Example 11
Source File: TestHttpCookie.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 12
Source File: TestHttpCookie.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 13
Source File: HttpURLConnection.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 14
Source File: TestHttpCookie.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 15
Source File: HttpURLConnection.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 16
Source File: TestHttpCookie.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 17
Source File: HttpURLConnection.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 18
Source File: TestHttpCookie.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}
 
Example 19
Source File: HttpURLConnection.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a filtered version of the given headers value.
 *
 * Note: The implementation currently only filters out HttpOnly cookies
 *       from Set-Cookie and Set-Cookie2 headers.
 */
private String filterHeaderField(String name, String value) {
    if (value == null)
        return null;

    if (SET_COOKIE.equalsIgnoreCase(name) ||
        SET_COOKIE2.equalsIgnoreCase(name)) {

        // Filtering only if there is a cookie handler. [Assumption: the
        // cookie handler will store/retrieve the HttpOnly cookies]
        if (cookieHandler == null || value.length() == 0)
            return value;

        sun.misc.JavaNetHttpCookieAccess access =
                sun.misc.SharedSecrets.getJavaNetHttpCookieAccess();
        StringBuilder retValue = new StringBuilder();
        List<HttpCookie> cookies = access.parse(value);
        boolean multipleCookies = false;
        for (HttpCookie cookie : cookies) {
            // skip HttpOnly cookies
            if (cookie.isHttpOnly())
                continue;
            if (multipleCookies)
                retValue.append(',');  // RFC 2965, comma separated
            retValue.append(access.header(cookie));
            multipleCookies = true;
        }

        return retValue.length() == 0 ? "" : retValue.toString();
    }

    return value;
}
 
Example 20
Source File: TestHttpCookie.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
TestHttpCookie httpOnly(int index, boolean b) {
    HttpCookie cookie = cookies.get(index);
    if (cookie == null || b != cookie.isHttpOnly()) {
        raiseError("HttpOnly", String.valueOf(cookie.isHttpOnly()), String.valueOf(b));
    }
    return this;
}