/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 7095980 8007315
* @summary Ensure HttpURLConnection (and supporting APIs) don't expose
* HttpOnly cookies
*/
/*
* 1) start the HTTP server
* 2) populate cookie store with HttpOnly cookies
* 3) make HTTP request that should contain HttpOnly cookies
* 4) check HttpOnly cookies received by server
* 5) server reply with Set-Cookie containing HttpOnly cookie
* 6) check HttpOnly cookies are not accessible from Http client
* 7) check that non-null (empty string) values are returned for
scenario where all values are stripped from original key values
*/
public class HttpOnly {
try {
} finally {
}
}
throws IOException {
+ URI_PATH +"; HttpOnly");
}
"Unexpected response code. Expected 200, got " + resp);
// TEST 1: check getRequestProperty doesn't return the HttpOnly cookie
// In fact, that it doesn't return any automatically set cookies.
"Cookie header returned from getRequestProperty, value " + cookie);
// TEST 2: check getRequestProperties doesn't return the HttpOnly cookie.
// In fact, that it doesn't return any automatically set cookies.
"Cookie header returned from getRequestProperties, value " +
}
// TEST 3: check getHeaderField doesn't return Set-Cookie with HttpOnly
"getHeaderField returned Set-Cookie header with HttpOnly, " +
"value = " + setCookie);
}
// TEST 3.5: check getHeaderField doesn't return Set-Cookie2 with HttpOnly
if (setCookie2 != null) {
"getHeaderField returned Set-Cookie2 header with HttpOnly, " +
"value = " + setCookie2);
}
// TEST 4: check getHeaderFields doesn't return Set-Cookie
// or Set-Cookie2 headers with HttpOnly
"getHeaderFields returned Set-Cookie header with HttpOnly, "
+ "value = " + value);
}
"getHeaderFields returned Set-Cookie2 header with HttpOnly, "
+ "value = " + value);
}
}
// Now add some user set cookies into the mix.
"Unexpected response code. Expected 200, got " + resp);
// TEST 5: check getRequestProperty doesn't return the HttpOnly cookie
"HttpOnly cookie returned from getRequestProperty, value " + cookie);
// TEST 6: check getRequestProperties doesn't return the HttpOnly cookie.
"HttpOnly cookie returned from getRequestProperties," +
" value " + val);
}
}
// TEST 7 : check that header keys containing empty key values don't return null
int i = 1;
while (true) {
break;
"Encountered a null value for key value : " + key);
}
// TEST 7.5 similar test but use getHeaderFields
"getHeaderFields returned null values for header:, "
+ header);
}
}
}
// HTTP Server
httpServer.start();
return httpServer;
}
// some small sanity check
}
// return some cookies so we can check getHeaderField(s)
+ URI_PATH +"; HttpOnly");
+ URI_PATH);
t.close();
}
}
boolean debug = false;
}