blob: f640f1c930b419bdbd17ebb716ae2507d51188bc [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Coverage Report</title>
<link title="Style" type="text/css" rel="stylesheet" href="css/main.css"/>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body>
<h5>Coverage Report - com.google.enterprise.adaptor.DocumentHandler</h5>
<div class="separator">&nbsp;</div>
<table class="report">
<thead><tr> <td class="heading">Classes in this File</td> <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Line Coverage</a></td> <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Branch Coverage</a></td> <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Complexity</a></td></tr></thead>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">6</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:97px"><span class="text">216/222</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">4</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:97px"><span class="text">136/140</span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$1</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">1/1</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$AsyncPusher</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$CountByteArrayOutputStream</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">2/2</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$CountingOutputStream</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">6/6</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$DocumentRequest</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">12/12</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">2/2</span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$DocumentResponse</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">9</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:94px"><span class="text">159/168</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">12</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:88px"><span class="text">94/106</span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$DocumentResponse$CantUseOutputStream</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">2/2</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$DocumentResponse$LazyContentOutputStream</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">6/6</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$MaxBufferOutputStream</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">6</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:73px"><span class="text">17/23</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">4</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:66px"><span class="text">8/12</span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$SinkOutputStream</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">1</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:66px"><span class="text">2/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.DocumentHandler.html">DocumentHandler$State</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">7/7</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">4.472727272727273;</span>4.473</td></tr>
</table>
<div class="separator">&nbsp;</div>
<table cellspacing="0" cellpadding="0" class="src">
<tr> <td class="numLine">&nbsp;1</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// Copyright 2011 Google Inc. All Rights Reserved.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;2</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">//</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;3</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;4</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// you may not use this file except in compliance with the License.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;5</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// You may obtain a copy of the License at</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;6</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">//</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;7</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;8</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">//</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;9</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// Unless required by applicable law or agreed to in writing, software</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;10</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;11</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;12</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// See the License for the specific language governing permissions and</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;13</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// limitations under the License.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;14</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;15</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">package</span> com.google.enterprise.adaptor;</pre></td></tr>
<tr> <td class="numLine">&nbsp;16</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;17</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> <span class="keyword">static</span> java.util.Map.Entry;</pre></td></tr>
<tr> <td class="numLine">&nbsp;18</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;19</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.google.common.annotations.VisibleForTesting;</pre></td></tr>
<tr> <td class="numLine">&nbsp;20</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;21</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.sun.net.httpserver.HttpExchange;</pre></td></tr>
<tr> <td class="numLine">&nbsp;22</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.sun.net.httpserver.HttpHandler;</pre></td></tr>
<tr> <td class="numLine">&nbsp;23</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.sun.net.httpserver.HttpsExchange;</pre></td></tr>
<tr> <td class="numLine">&nbsp;24</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;25</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> org.json.simple.JSONObject;</pre></td></tr>
<tr> <td class="numLine">&nbsp;26</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;27</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.ByteArrayOutputStream;</pre></td></tr>
<tr> <td class="numLine">&nbsp;28</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.IOException;</pre></td></tr>
<tr> <td class="numLine">&nbsp;29</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.OutputStream;</pre></td></tr>
<tr> <td class="numLine">&nbsp;30</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.net.*;</pre></td></tr>
<tr> <td class="numLine">&nbsp;31</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.nio.charset.Charset;</pre></td></tr>
<tr> <td class="numLine">&nbsp;32</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.*;</pre></td></tr>
<tr> <td class="numLine">&nbsp;33</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.logging.Level;</pre></td></tr>
<tr> <td class="numLine">&nbsp;34</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.logging.Logger;</pre></td></tr>
<tr> <td class="numLine">&nbsp;35</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;36</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.naming.InvalidNameException;</pre></td></tr>
<tr> <td class="numLine">&nbsp;37</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.naming.ldap.LdapName;</pre></td></tr>
<tr> <td class="numLine">&nbsp;38</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.naming.ldap.Rdn;</pre></td></tr>
<tr> <td class="numLine">&nbsp;39</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.net.ssl.SSLPeerUnverifiedException;</pre></td></tr>
<tr> <td class="numLine">&nbsp;40</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.security.auth.x500.X500Principal;</pre></td></tr>
<tr> <td class="numLine">&nbsp;41</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;42</td> <td class="nbHitsCovered">&nbsp;120</td> <td class="src"><pre class="src">&nbsp;<span class="keyword">class</span> DocumentHandler <span class="keyword">implements</span> HttpHandler {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;43</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Logger log</pre></td></tr>
<tr> <td class="numLine">&nbsp;44</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = Logger.getLogger(DocumentHandler.<span class="keyword">class</span>.getName());</pre></td></tr>
<tr> <td class="numLine">&nbsp;45</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;46</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> DocIdDecoder docIdDecoder;</pre></td></tr>
<tr> <td class="numLine">&nbsp;47</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> DocIdEncoder docIdEncoder;</pre></td></tr>
<tr> <td class="numLine">&nbsp;48</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Journal journal;</pre></td></tr>
<tr> <td class="numLine">&nbsp;49</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Adaptor adaptor;</pre></td></tr>
<tr> <td class="numLine">&nbsp;50</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Watchdog watchdog;</pre></td></tr>
<tr> <td class="numLine">&nbsp;51</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> AsyncPusher pusher;</pre></td></tr>
<tr> <td class="numLine">&nbsp;52</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;53</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * List of Common Names of Subjects that are provided full access when in</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;54</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * secure mode. All entries should be lower case.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;55</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;56</td> <td class="nbHitsCovered">&nbsp;140</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Set&lt;String&gt; fullAccessCommonNames = <span class="keyword">new</span> HashSet&lt;String&gt;();</pre></td></tr>
<tr> <td class="numLine">&nbsp;57</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;58</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * List of IPs that are provided full access when not in secure mode.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;59</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;60</td> <td class="nbHitsCovered">&nbsp;140</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Set&lt;InetAddress&gt; fullAccessAddresses</pre></td></tr>
<tr> <td class="numLine">&nbsp;61</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = <span class="keyword">new</span> HashSet&lt;InetAddress&gt;();</pre></td></tr>
<tr> <td class="numLine">&nbsp;62</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> HttpHandler authnHandler;</pre></td></tr>
<tr> <td class="numLine">&nbsp;63</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> SessionManager&lt;HttpExchange&gt; sessionManager;</pre></td></tr>
<tr> <td class="numLine">&nbsp;64</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> TransformPipeline transform;</pre></td></tr>
<tr> <td class="numLine">&nbsp;65</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">int</span> transformMaxBytes;</pre></td></tr>
<tr> <td class="numLine">&nbsp;66</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">boolean</span> transformRequired;</pre></td></tr>
<tr> <td class="numLine">&nbsp;67</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">boolean</span> useCompression;</pre></td></tr>
<tr> <td class="numLine">&nbsp;68</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">boolean</span> sendDocControls;</pre></td></tr>
<tr> <td class="numLine">&nbsp;69</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;70</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;71</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * {@code authnHandler} and {@code transform} may be {@code null}.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;72</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;73</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> DocumentHandler(DocIdDecoder docIdDecoder, DocIdEncoder docIdEncoder,</pre></td></tr>
<tr> <td class="numLine">&nbsp;74</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Journal journal, Adaptor adaptor,</pre></td></tr>
<tr> <td class="numLine">&nbsp;75</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; String gsaHostname, String[] fullAccessHosts,</pre></td></tr>
<tr> <td class="numLine">&nbsp;76</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; HttpHandler authnHandler,</pre></td></tr>
<tr> <td class="numLine">&nbsp;77</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; SessionManager&lt;HttpExchange&gt; sessionManager,</pre></td></tr>
<tr> <td class="numLine">&nbsp;78</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; TransformPipeline transform, <span class="keyword">int</span> transformMaxBytes,</pre></td></tr>
<tr> <td class="numLine">&nbsp;79</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> transformRequired, <span class="keyword">boolean</span> useCompression,</pre></td></tr>
<tr> <td class="numLine">&nbsp;80</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Watchdog watchdog, AsyncPusher pusher,</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;81</td> <td class="nbHitsCovered">&nbsp;140</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> sendDocControls) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;82</td> <td class="nbHitsUncovered"><a title="Line 82: Conditional coverage 92% (13/14) [each condition: 100%, 100%, 100%, 100%, 100%, 100%, 50%].">&nbsp;140</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 82: Conditional coverage 92% (13/14) [each condition: 100%, 100%, 100%, 100%, 100%, 100%, 50%]."> <span class="keyword">if</span> (docIdDecoder == <span class="keyword">null</span> || docIdEncoder == <span class="keyword">null</span> || journal == <span class="keyword">null</span></a></span></pre></td></tr>
<tr> <td class="numLine">&nbsp;83</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; || adaptor == <span class="keyword">null</span> || sessionManager == <span class="keyword">null</span> || watchdog == <span class="keyword">null</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;84</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; || pusher == <span class="keyword">null</span>) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;85</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> NullPointerException();</pre></td></tr>
<tr> <td class="numLine">&nbsp;86</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;87</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.docIdDecoder = docIdDecoder;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;88</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.docIdEncoder = docIdEncoder;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;89</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.journal = journal;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;90</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.adaptor = adaptor;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;91</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.authnHandler = authnHandler;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;92</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.sessionManager = sessionManager;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;93</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.transform = transform;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;94</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.transformMaxBytes = transformMaxBytes;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;95</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.transformRequired = transformRequired;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;96</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.useCompression = useCompression;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;97</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.watchdog = watchdog;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;98</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.pusher = pusher;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;99</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.sendDocControls = sendDocControls;</pre></td></tr>
<tr> <td class="numLine">&nbsp;100</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;101</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; initFullAccess(gsaHostname, fullAccessHosts);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;102</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;103</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;104</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">void</span> initFullAccess(String gsaHostname, String[] fullAccessHosts) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;105</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; fullAccessCommonNames.add(gsaHostname.toLowerCase(Locale.ENGLISH));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;106</td> <td class="nbHitsCovered"><a title="Line 106: Conditional coverage 100% (2/2).">&nbsp;161</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 106: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (String hostname : fullAccessHosts) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;107</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; hostname = hostname.trim();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;108</td> <td class="nbHitsCovered"><a title="Line 108: Conditional coverage 100% (2/2).">&nbsp;27</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 108: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (<span class="string">""</span>.equals(hostname)) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;109</td> <td class="nbHitsCovered">&nbsp;11</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">continue</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;110</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;111</td> <td class="nbHitsCovered">&nbsp;16</td> <td class="src"><pre class="src">&nbsp; fullAccessCommonNames.add(hostname.toLowerCase(Locale.ENGLISH));</pre></td></tr>
<tr> <td class="numLine">&nbsp;112</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;113</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; log.log(Level.INFO, <span class="string">"When in secure mode, common names that are given full "</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;114</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"access to content: {0}"</span>, <span class="keyword">new</span> Object[] {fullAccessCommonNames});</pre></td></tr>
<tr> <td class="numLine">&nbsp;115</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;116</td> <td class="nbHitsCovered"><a title="Line 116: Conditional coverage 100% (2/2).">&nbsp;134</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 116: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (String hostname : fullAccessCommonNames) {</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;117</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;118</td> <td class="nbHitsCovered">&nbsp;150</td> <td class="src"><pre class="src">&nbsp; InetAddress[] ips = InetAddress.getAllByName(hostname);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;119</td> <td class="nbHitsCovered">&nbsp;147</td> <td class="src"><pre class="src">&nbsp; fullAccessAddresses.addAll(Arrays.asList(ips));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;120</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (UnknownHostException ex) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;121</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; log.log(Level.WARNING, <span class="string">"Could not resolve hostname. Not adding it to "</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;122</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"full access list of IPs: "</span> + hostname, ex);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;123</td> <td class="nbHitsCovered">&nbsp;297</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;124</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;125</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; log.log(Level.INFO, <span class="string">"When not in secure mode, IPs that are given full "</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;126</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"access to content: {0}"</span>, <span class="keyword">new</span> Object[] {fullAccessAddresses});</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;127</td> <td class="nbHitsCovered">&nbsp;134</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;128</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;129</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> requestIsFromFullyTrustedClient(HttpExchange ex) {</pre></td></tr>
<tr> <td class="numLine">&nbsp;130</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> trust;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;131</td> <td class="nbHitsCovered"><a title="Line 131: Conditional coverage 100% (2/2).">&nbsp;80</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 131: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (ex <span class="keyword">instanceof</span> HttpsExchange) {</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;132</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; java.security.Principal principal;</pre></td></tr>
<tr> <td class="numLine">&nbsp;133</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;134</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; principal = ((HttpsExchange) ex).getSSLSession().getPeerPrincipal();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;135</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (SSLPeerUnverifiedException e) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;136</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; log.log(Level.FINE, <span class="string">"Client is not trusted. It does not have a verified"</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;137</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">" client certificate"</span>, e);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;138</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;139</td> <td class="nbHitsCovered">&nbsp;5</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;140</td> <td class="nbHitsCovered"><a title="Line 140: Conditional coverage 100% (2/2).">&nbsp;5</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 140: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!(principal <span class="keyword">instanceof</span> X500Principal)) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;141</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; log.fine(<span class="string">"Client is not trusted. It does not have a X500 principal"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;142</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;143</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;144</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; LdapName dn;</pre></td></tr>
<tr> <td class="numLine">&nbsp;145</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLine">&nbsp;146</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// getName() provides RFC2253-encoded data.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;147</td> <td class="nbHitsCovered">&nbsp;4</td> <td class="src"><pre class="src">&nbsp; dn = <span class="keyword">new</span> LdapName(principal.getName());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;148</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (InvalidNameException e) {</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;149</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Getting here may represent a bug in the standard libraries.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;150</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; log.log(Level.FINE, <span class="string">"Client is not trusted. The X500 principal could "</span></span></pre></td></tr>
<tr> <td class="numLine">&nbsp;151</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"not be parsed"</span>, e);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;152</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;153</td> <td class="nbHitsCovered">&nbsp;4</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;154</td> <td class="nbHitsCovered">&nbsp;4</td> <td class="src"><pre class="src">&nbsp; String commonName = <span class="keyword">null</span>;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;155</td> <td class="nbHitsCovered"><a title="Line 155: Conditional coverage 100% (2/2).">&nbsp;4</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 155: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (Rdn rdn : dn.getRdns()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;156</td> <td class="nbHitsUncovered"><a title="Line 156: Conditional coverage 75% (3/4) [each condition: 100%, 50%].">&nbsp;15</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 156: Conditional coverage 75% (3/4) [each condition: 100%, 50%]."> <span class="keyword">if</span> (<span class="string">"CN"</span>.equalsIgnoreCase(rdn.getType())</a></span></pre></td></tr>
<tr> <td class="numLine">&nbsp;157</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; &amp;&amp; (rdn.getValue() <span class="keyword">instanceof</span> String)) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;158</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; commonName = (String) rdn.getValue();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;159</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">break</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;160</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;161</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;162</td> <td class="nbHitsCovered"><a title="Line 162: Conditional coverage 100% (2/2).">&nbsp;4</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 162: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (commonName == <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;163</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; log.log(Level.FINE, <span class="string">"Client is not trusted. Could not find Common "</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;164</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"Name"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;165</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;166</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;167</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; commonName = commonName.toLowerCase(Locale.ENGLISH);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;168</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; trust = fullAccessCommonNames.contains(commonName);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;169</td> <td class="nbHitsCovered"><a title="Line 169: Conditional coverage 100% (2/2).">&nbsp;3</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 169: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (trust) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;170</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; log.log(Level.FINE, <span class="string">"Client is trusted in secure mode: {0}"</span>,</pre></td></tr>
<tr> <td class="numLine">&nbsp;171</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; commonName);</pre></td></tr>
<tr> <td class="numLine">&nbsp;172</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;173</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; log.log(Level.FINE, <span class="string">"Client is not trusted in secure mode: {0}"</span>,</pre></td></tr>
<tr> <td class="numLine">&nbsp;174</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; commonName);</pre></td></tr>
<tr> <td class="numLine">&nbsp;175</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;176</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;177</td> <td class="nbHitsCovered">&nbsp;74</td> <td class="src"><pre class="src">&nbsp; InetAddress addr = ex.getRemoteAddress().getAddress();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;178</td> <td class="nbHitsCovered">&nbsp;74</td> <td class="src"><pre class="src">&nbsp; trust = fullAccessAddresses.contains(addr);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;179</td> <td class="nbHitsCovered"><a title="Line 179: Conditional coverage 100% (2/2).">&nbsp;74</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 179: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (trust) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;180</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; log.log(Level.FINE, <span class="string">"Client is trusted in non-secure mode: {0}"</span>, addr);</pre></td></tr>
<tr> <td class="numLine">&nbsp;181</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;182</td> <td class="nbHitsCovered">&nbsp;47</td> <td class="src"><pre class="src">&nbsp; log.log(Level.FINE, <span class="string">"Client is not trusted in non-secure mode: {0}"</span>,</pre></td></tr>
<tr> <td class="numLine">&nbsp;183</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; addr);</pre></td></tr>
<tr> <td class="numLine">&nbsp;184</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;185</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;186</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;187</td> <td class="nbHitsCovered">&nbsp;77</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> trust;</pre></td></tr>
<tr> <td class="numLine">&nbsp;188</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;189</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;190</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;191</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">void</span> handle(HttpExchange ex) <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;192</td> <td class="nbHitsCovered">&nbsp;59</td> <td class="src"><pre class="src">&nbsp; String requestMethod = ex.getRequestMethod();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;193</td> <td class="nbHitsCovered"><a title="Line 193: Conditional coverage 100% (4/4) [each condition: 100%, 100%].">&nbsp;59</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 193: Conditional coverage 100% (4/4) [each condition: 100%, 100%]."> <span class="keyword">if</span> (<span class="string">"GET"</span>.equals(requestMethod) || <span class="string">"HEAD"</span>.equals(requestMethod)) {</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;194</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/* Call into adaptor developer code to get document bytes. */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;195</td> <td class="nbHitsCovered">&nbsp;58</td> <td class="src"><pre class="src">&nbsp; DocId docId = docIdDecoder.decodeDocId(HttpExchanges.getRequestUri(ex));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;196</td> <td class="nbHitsCovered">&nbsp;58</td> <td class="src"><pre class="src">&nbsp; log.fine(<span class="string">"id: "</span> + docId.getUniqueId());</pre></td></tr>
<tr> <td class="numLine">&nbsp;197</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;198</td> <td class="nbHitsCovered"><a title="Line 198: Conditional coverage 100% (2/2).">&nbsp;58</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 198: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!authzed(ex, docId)) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;199</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;200</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;201</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;202</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; DocumentRequest request = <span class="keyword">new</span> DocumentRequest(ex, docId);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;203</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; DocumentResponse response = <span class="keyword">new</span> DocumentResponse(ex, docId);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;204</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; journal.recordRequestProcessingStart();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;205</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; watchdog.processingStarting();</pre></td></tr>
<tr> <td class="numLine">&nbsp;206</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;207</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; adaptor.getDocContent(request, response);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;208</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (InterruptedException e) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;209</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; journal.recordRequestProcessingFailure();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;210</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"Retriever interrupted: "</span> + docId, e);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;211</td> <td class="nbHitsCovered">&nbsp;15</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (RuntimeException e) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;212</td> <td class="nbHitsCovered">&nbsp;15</td> <td class="src"><pre class="src">&nbsp; journal.recordRequestProcessingFailure();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;213</td> <td class="nbHitsCovered">&nbsp;15</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"Exception in retriever: "</span> + docId, e);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;214</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (IOException e) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;215</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; journal.recordRequestProcessingFailure();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;216</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> IOException(<span class="string">"Exception in retriever: "</span> + docId, e);</pre></td></tr>
<tr> <td class="numLine">&nbsp;217</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">finally</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;218</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; watchdog.processingCompleted();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;219</td> <td class="nbHitsCovered">&nbsp;28</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;220</td> <td class="nbHitsCovered">&nbsp;28</td> <td class="src"><pre class="src">&nbsp; journal.recordRequestProcessingEnd(response.getWrittenContentSize());</pre></td></tr>
<tr> <td class="numLine">&nbsp;221</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;222</td> <td class="nbHitsCovered">&nbsp;28</td> <td class="src"><pre class="src">&nbsp; response.complete();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;223</td> <td class="nbHitsCovered">&nbsp;26</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;224</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; HttpExchanges.cannedRespond(ex, HttpURLConnection.HTTP_BAD_METHOD,</pre></td></tr>
<tr> <td class="numLine">&nbsp;225</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Translation.HTTP_BAD_METHOD);</pre></td></tr>
<tr> <td class="numLine">&nbsp;226</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;227</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;228</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;229</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;230</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Check authz of user to access document. If the user is not authzed, the</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;231</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * method handles responding to the HttpExchange.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;232</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;233</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * @return {@code true} if user authzed</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;234</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;235</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> authzed(HttpExchange ex, DocId docId) <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;236</td> <td class="nbHitsCovered"><a title="Line 236: Conditional coverage 100% (2/2).">&nbsp;58</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 236: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (<span class="string">"SecMgr"</span>.equals(ex.getRequestHeaders().getFirst(<span class="string">"User-Agent"</span>))) {</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;237</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Assume that the SecMgr is performing a "HEAD" request to check authz.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;238</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// We don't support this, so we always issue deny.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;239</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; HttpExchanges.cannedRespond(ex, HttpURLConnection.HTTP_FORBIDDEN,</pre></td></tr>
<tr> <td class="numLine">&nbsp;240</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Translation.HTTP_FORBIDDEN_SECMGR);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;241</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;242</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;243</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;244</td> <td class="nbHitsCovered"><a title="Line 244: Conditional coverage 100% (2/2).">&nbsp;57</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 244: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (requestIsFromFullyTrustedClient(ex)) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;245</td> <td class="nbHitsCovered">&nbsp;15</td> <td class="src"><pre class="src">&nbsp; journal.recordGsaContentRequest(docId);</pre></td></tr>
<tr> <td class="numLine">&nbsp;246</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;247</td> <td class="nbHitsCovered">&nbsp;42</td> <td class="src"><pre class="src">&nbsp; journal.recordNonGsaContentRequest(docId);</pre></td></tr>
<tr> <td class="numLine">&nbsp;248</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Default to anonymous.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;249</td> <td class="nbHitsCovered">&nbsp;42</td> <td class="src"><pre class="src">&nbsp; AuthnIdentity identity = <span class="keyword">null</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;250</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;251</td> <td class="nbHitsCovered">&nbsp;42</td> <td class="src"><pre class="src">&nbsp; Session session = sessionManager.getSession(ex, <span class="keyword">false</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;252</td> <td class="nbHitsCovered"><a title="Line 252: Conditional coverage 100% (2/2).">&nbsp;42</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 252: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (session != <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;253</td> <td class="nbHitsCovered">&nbsp;4</td> <td class="src"><pre class="src">&nbsp; AuthnState authnState</pre></td></tr>
<tr> <td class="numLine">&nbsp;254</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = (AuthnState) session.getAttribute(AuthnState.SESSION_ATTR_NAME);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;255</td> <td class="nbHitsCovered"><a title="Line 255: Conditional coverage 100% (4/4) [each condition: 100%, 100%].">&nbsp;4</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 255: Conditional coverage 100% (4/4) [each condition: 100%, 100%]."> <span class="keyword">if</span> (authnState != <span class="keyword">null</span> &amp;&amp; authnState.isAuthenticated()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;256</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; identity = authnState.getIdentity();</pre></td></tr>
<tr> <td class="numLine">&nbsp;257</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;258</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;259</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;260</td> <td class="nbHitsCovered">&nbsp;42</td> <td class="src"><pre class="src">&nbsp; Map&lt;DocId, AuthzStatus&gt; authzMap = adaptor.isUserAuthorized(identity,</pre></td></tr>
<tr> <td class="numLine">&nbsp;261</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Collections.singletonList(docId));</pre></td></tr>
<tr> <td class="numLine">&nbsp;262</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;263</td> <td class="nbHitsCovered"><a title="Line 263: Conditional coverage 100% (2/2).">&nbsp;42</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 263: Conditional coverage 100% (2/2)."> AuthzStatus status = authzMap != <span class="keyword">null</span> ? authzMap.get(docId) : <span class="keyword">null</span>;</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;264</td> <td class="nbHitsCovered"><a title="Line 264: Conditional coverage 100% (2/2).">&nbsp;42</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 264: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (status == <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;265</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; status = AuthzStatus.DENY;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;266</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; log.log(Level.WARNING, <span class="string">"Adaptor did not provide an authorization "</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;267</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"result for the requested DocId ''{0}''. Instead provided: "</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;268</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"{1}"</span>, <span class="keyword">new</span> Object[] {docId, authzMap});</pre></td></tr>
<tr> <td class="numLine">&nbsp;269</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;270</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;271</td> <td class="nbHitsCovered"><a title="Line 271: Conditional coverage 100% (2/2).">&nbsp;42</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 271: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (status == AuthzStatus.INDETERMINATE) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;272</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; HttpExchanges.cannedRespond(ex, HttpURLConnection.HTTP_NOT_FOUND,</pre></td></tr>
<tr> <td class="numLine">&nbsp;273</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Translation.HTTP_NOT_FOUND);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;274</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;275</td> <td class="nbHitsCovered"><a title="Line 275: Conditional coverage 100% (2/2).">&nbsp;41</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 275: Conditional coverage 100% (2/2)."> } <span class="keyword">else</span> <span class="keyword">if</span> (status == AuthzStatus.DENY) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;276</td> <td class="nbHitsCovered"><a title="Line 276: Conditional coverage 100% (4/4) [each condition: 100%, 100%].">&nbsp;10</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 276: Conditional coverage 100% (4/4) [each condition: 100%, 100%]."> <span class="keyword">if</span> (identity == <span class="keyword">null</span> &amp;&amp; authnHandler != <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;277</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// User was anonymous and document is not public, so try to authn</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;278</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// user.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;279</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; authnHandler.handle(ex);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;280</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;281</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;282</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; HttpExchanges.cannedRespond(ex, HttpURLConnection.HTTP_FORBIDDEN,</pre></td></tr>
<tr> <td class="numLine">&nbsp;283</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Translation.HTTP_FORBIDDEN);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;284</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;285</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;286</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;287</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;288</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">true</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;289</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;290</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;291</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;292</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Format the GSA-specific metadata header value for crawl-time metadata.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;293</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;294</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> String formMetadataHeader(Metadata metadata) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;295</td> <td class="nbHitsCovered">&nbsp;16</td> <td class="src"><pre class="src">&nbsp; StringBuilder sb = <span class="keyword">new</span> StringBuilder();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;296</td> <td class="nbHitsCovered"><a title="Line 296: Conditional coverage 100% (2/2).">&nbsp;16</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 296: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (Entry&lt;String, String&gt; item : metadata) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;297</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, item.getKey(), item.getValue());</pre></td></tr>
<tr> <td class="numLine">&nbsp;298</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;299</td> <td class="nbHitsCovered"><a title="Line 299: Conditional coverage 100% (2/2).">&nbsp;16</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 299: Conditional coverage 100% (2/2)."> <span class="keyword">return</span> (sb.length() == 0) ? <span class="string">""</span> : sb.substring(0, sb.length() - 1);</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;300</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;301</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;302</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @VisibleForTesting</pre></td></tr>
<tr> <td class="numLine">&nbsp;303</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> String formUnqualifiedAclHeader(Acl acl, DocIdEncoder docIdEncoder) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;304</td> <td class="nbHitsCovered"><a title="Line 304: Conditional coverage 100% (2/2).">&nbsp;15</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 304: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (acl == <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;305</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="string">""</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;306</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;307</td> <td class="nbHitsCovered"><a title="Line 307: Conditional coverage 100% (2/2).">&nbsp;8</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 307: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (Acl.EMPTY.equals(acl)) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;308</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; acl = Acl.FAKE_EMPTY;</pre></td></tr>
<tr> <td class="numLine">&nbsp;309</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;310</td> <td class="nbHitsCovered">&nbsp;8</td> <td class="src"><pre class="src">&nbsp; StringBuilder sb = <span class="keyword">new</span> StringBuilder();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;311</td> <td class="nbHitsCovered"><a title="Line 311: Conditional coverage 100% (2/2).">&nbsp;8</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 311: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (UserPrincipal permitUser : acl.getPermitUsers()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;312</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; String name = permitUser.getName();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;313</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, <span class="string">"google:aclusers"</span>, name);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;314</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;315</td> <td class="nbHitsCovered"><a title="Line 315: Conditional coverage 100% (2/2).">&nbsp;8</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 315: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (GroupPrincipal permitGroup : acl.getPermitGroups()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;316</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; String name = permitGroup.getName();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;317</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, <span class="string">"google:aclgroups"</span>, name);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;318</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;319</td> <td class="nbHitsCovered"><a title="Line 319: Conditional coverage 100% (2/2).">&nbsp;8</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 319: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (UserPrincipal denyUser : acl.getDenyUsers()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;320</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; String name = denyUser.getName();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;321</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, <span class="string">"google:acldenyusers"</span>, name);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;322</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;323</td> <td class="nbHitsCovered"><a title="Line 323: Conditional coverage 100% (2/2).">&nbsp;8</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 323: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (GroupPrincipal denyGroup : acl.getDenyGroups()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;324</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; String name = denyGroup.getName();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;325</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, <span class="string">"google:acldenygroups"</span>, name);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;326</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;327</td> <td class="nbHitsCovered"><a title="Line 327: Conditional coverage 100% (2/2).">&nbsp;8</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 327: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (acl.getInheritFrom() != <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;328</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; URI uri = docIdEncoder.encodeDocId(acl.getInheritFrom());</pre></td></tr>
<tr> <td class="numLine">&nbsp;329</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;330</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; uri = <span class="keyword">new</span> URI(uri.getScheme(), uri.getSchemeSpecificPart(),</pre></td></tr>
<tr> <td class="numLine">&nbsp;331</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; acl.getInheritFromFragment());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;332</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (URISyntaxException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;333</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> AssertionError(ex);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;334</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;335</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, <span class="string">"google:aclinheritfrom"</span>, uri.toString());</pre></td></tr>
<tr> <td class="numLine">&nbsp;336</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;337</td> <td class="nbHitsCovered"><a title="Line 337: Conditional coverage 100% (2/2).">&nbsp;8</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 337: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (acl.getInheritanceType() != Acl.InheritanceType.LEAF_NODE) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;338</td> <td class="nbHitsCovered">&nbsp;4</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, <span class="string">"google:aclinheritancetype"</span>,</pre></td></tr>
<tr> <td class="numLine">&nbsp;339</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; acl.getInheritanceType().getCommonForm());</pre></td></tr>
<tr> <td class="numLine">&nbsp;340</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;341</td> <td class="nbHitsCovered">&nbsp;8</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> sb.substring(0, sb.length() - 1);</pre></td></tr>
<tr> <td class="numLine">&nbsp;342</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;343</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;344</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @VisibleForTesting</pre></td></tr>
<tr> <td class="numLine">&nbsp;345</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> String formNamespacedAclHeader(Acl acl, DocIdEncoder enc) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;346</td> <td class="nbHitsCovered"><a title="Line 346: Conditional coverage 100% (2/2).">&nbsp;4</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 346: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (<span class="keyword">null</span> == acl) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;347</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="string">""</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;348</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;349</td> <td class="nbHitsCovered"><a title="Line 349: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 349: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (Acl.EMPTY.equals(acl)) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;350</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; acl = Acl.FAKE_EMPTY;</pre></td></tr>
<tr> <td class="numLine">&nbsp;351</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;352</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; Map&lt;String, Object&gt; gsaAcl = <span class="keyword">new</span> TreeMap&lt;String, Object&gt;();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;353</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; List&lt;Map&lt;String, String&gt;&gt; gsaAclEntries = makeGsaAclEntries(acl); </pre></td></tr>
<tr> <td class="numLineCover">&nbsp;354</td> <td class="nbHitsUncovered"><a title="Line 354: Conditional coverage 50% (1/2).">&nbsp;2</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 354: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (!gsaAclEntries.isEmpty()) {</a></span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;355</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; gsaAcl.put(<span class="string">"entries"</span>, gsaAclEntries);</pre></td></tr>
<tr> <td class="numLine">&nbsp;356</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;357</td> <td class="nbHitsCovered"><a title="Line 357: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 357: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (<span class="keyword">null</span> != acl.getInheritFrom()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;358</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; URI from = enc.encodeDocId(acl.getInheritFrom());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;359</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; gsaAcl.put(<span class="string">"inherit_from"</span>, <span class="string">""</span> + from);</pre></td></tr>
<tr> <td class="numLine">&nbsp;360</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;361</td> <td class="nbHitsCovered"><a title="Line 361: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 361: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (acl.getInheritanceType() != Acl.InheritanceType.LEAF_NODE) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;362</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; String type = <span class="string">""</span> + acl.getInheritanceType();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;363</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; gsaAcl.put(<span class="string">"inheritance_type"</span>, <span class="string">""</span> + type);</pre></td></tr>
<tr> <td class="numLine">&nbsp;364</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;365</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> JSONObject.toJSONString(gsaAcl);</pre></td></tr>
<tr> <td class="numLine">&nbsp;366</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;367</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;368</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> List&lt;Map&lt;String, String&gt;&gt; makeGsaAclEntries(Acl acl) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;369</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; List&lt;Map&lt;String, String&gt;&gt; princ = <span class="keyword">new</span> ArrayList&lt;Map&lt;String, String&gt;&gt;();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;370</td> <td class="nbHitsCovered"><a title="Line 370: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 370: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (Principal p : acl.getPermitGroups()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;371</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; princ.add(makeGsaAclEntry(<span class="string">"permit"</span>, acl, p));</pre></td></tr>
<tr> <td class="numLine">&nbsp;372</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;373</td> <td class="nbHitsCovered"><a title="Line 373: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 373: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (Principal p : acl.getDenyGroups()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;374</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; princ.add(makeGsaAclEntry(<span class="string">"deny"</span>, acl, p));</pre></td></tr>
<tr> <td class="numLine">&nbsp;375</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;376</td> <td class="nbHitsCovered"><a title="Line 376: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 376: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (Principal p : acl.getPermitUsers()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;377</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; princ.add(makeGsaAclEntry(<span class="string">"permit"</span>, acl, p));</pre></td></tr>
<tr> <td class="numLine">&nbsp;378</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;379</td> <td class="nbHitsCovered"><a title="Line 379: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 379: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (Principal p : acl.getDenyUsers()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;380</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; princ.add(makeGsaAclEntry(<span class="string">"deny"</span>, acl, p));</pre></td></tr>
<tr> <td class="numLine">&nbsp;381</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;382</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> princ;</pre></td></tr>
<tr> <td class="numLine">&nbsp;383</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;384</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;385</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> Map&lt;String, String&gt; makeGsaAclEntry(String access,</pre></td></tr>
<tr> <td class="numLine">&nbsp;386</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; Acl acl, Principal p) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;387</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; Map&lt;String, String&gt; gsaEntry = <span class="keyword">new</span> TreeMap&lt;String, String&gt;();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;388</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; gsaEntry.put(<span class="string">"access"</span>, access);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;389</td> <td class="nbHitsCovered"><a title="Line 389: Conditional coverage 100% (2/2).">&nbsp;9</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 389: Conditional coverage 100% (2/2)."> gsaEntry.put(<span class="string">"scope"</span>, p.isUser() ? <span class="string">"user"</span> : <span class="string">"group"</span>);</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;390</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; gsaEntry.put(<span class="string">"name"</span>, p.getName());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;391</td> <td class="nbHitsCovered"><a title="Line 391: Conditional coverage 100% (2/2).">&nbsp;9</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 391: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!Principal.DEFAULT_NAMESPACE.equals(p.getNamespace())) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;392</td> <td class="nbHitsCovered">&nbsp;4</td> <td class="src"><pre class="src">&nbsp; gsaEntry.put(<span class="string">"namespace"</span>, p.getNamespace());</pre></td></tr>
<tr> <td class="numLine">&nbsp;393</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;394</td> <td class="nbHitsCovered"><a title="Line 394: Conditional coverage 100% (2/2).">&nbsp;9</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 394: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!acl.isEverythingCaseSensitive()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;395</td> <td class="nbHitsCovered">&nbsp;8</td> <td class="src"><pre class="src">&nbsp; gsaEntry.put(<span class="string">"case_sensitivity_type"</span>, <span class="string">"everything_case_insensitive"</span>);</pre></td></tr>
<tr> <td class="numLine">&nbsp;396</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;397</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> gsaEntry;</pre></td></tr>
<tr> <td class="numLine">&nbsp;398</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;399</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;400</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;401</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Format the GSA-specific anchor header value for extra crawl-time anchors.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;402</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;403</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> String formAnchorHeader(List&lt;URI&gt; uris, List&lt;String&gt; texts) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;404</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; StringBuilder sb = <span class="keyword">new</span> StringBuilder();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;405</td> <td class="nbHitsCovered"><a title="Line 405: Conditional coverage 100% (2/2).">&nbsp;4</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 405: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (<span class="keyword">int</span> i = 0; i &lt; uris.size(); i++) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;406</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; URI uri = uris.get(i);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;407</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; String text = texts.get(i);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;408</td> <td class="nbHitsCovered"><a title="Line 408: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 408: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (text == <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;409</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; sb.append(percentEncode(uri.toString()));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;410</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; sb.append(<span class="string">","</span>);</pre></td></tr>
<tr> <td class="numLine">&nbsp;411</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;412</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; percentEncodeMapEntryPair(sb, text, uri.toString());</pre></td></tr>
<tr> <td class="numLine">&nbsp;413</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;414</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;415</td> <td class="nbHitsCovered"><a title="Line 415: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 415: Conditional coverage 100% (2/2)."> <span class="keyword">return</span> (sb.length() == 0) ? <span class="string">""</span> : sb.substring(0, sb.length() - 1);</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;416</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;417</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;418</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> percentEncodeMapEntryPair(StringBuilder sb, String key,</pre></td></tr>
<tr> <td class="numLine">&nbsp;419</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; String value) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;420</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; sb.append(percentEncode(key));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;421</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; sb.append(<span class="string">"="</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;422</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; sb.append(percentEncode(value));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;423</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; sb.append(<span class="string">","</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;424</td> <td class="nbHitsCovered">&nbsp;27</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;425</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;426</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;427</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Percent-encode {@code value} as described in</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;428</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;a href="http://tools.ietf.org/html/rfc3986#section-2"&gt;RFC 3986&lt;/a&gt; and</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;429</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * using UTF-8. This is the most common form of percent encoding. The</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;430</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * characters A-Z, a-z, 0-9, '-', '_', '.', and '~' are left as-is; the rest</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;431</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * are percent encoded.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;432</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;433</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> String percentEncode(String value) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;434</td> <td class="nbHitsCovered">&nbsp;314</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">final</span> Charset encoding = Charset.forName(<span class="string">"UTF-8"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;435</td> <td class="nbHitsCovered">&nbsp;314</td> <td class="src"><pre class="src">&nbsp; StringBuilder sb = <span class="keyword">new</span> StringBuilder();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;436</td> <td class="nbHitsCovered">&nbsp;314</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">byte</span>[] bytes = value.getBytes(encoding);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;437</td> <td class="nbHitsCovered"><a title="Line 437: Conditional coverage 100% (2/2).">&nbsp;1675</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 437: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (<span class="keyword">byte</span> b : bytes) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;438</td> <td class="nbHitsCovered"><a title="Line 438: Conditional coverage 100% (20/20) [each condition: 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%].">&nbsp;1361</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 438: Conditional coverage 100% (20/20) [each condition: 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%, 100%]."> <span class="keyword">if</span> ((b &gt;= <span class="string">'a'</span> &amp;&amp; b &lt;= <span class="string">'z'</span>)</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;439</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; || (b &gt;= <span class="string">'A'</span> &amp;&amp; b &lt;= <span class="string">'Z'</span>)</pre></td></tr>
<tr> <td class="numLine">&nbsp;440</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; || (b &gt;= <span class="string">'0'</span> &amp;&amp; b &lt;= <span class="string">'9'</span>)</pre></td></tr>
<tr> <td class="numLine">&nbsp;441</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; || b == <span class="string">'-'</span> || b == <span class="string">'_'</span> || b == <span class="string">'.'</span> || b == <span class="string">'~'</span>) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;442</td> <td class="nbHitsCovered">&nbsp;924</td> <td class="src"><pre class="src">&nbsp; sb.append((<span class="keyword">char</span>) b);</pre></td></tr>
<tr> <td class="numLine">&nbsp;443</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLine">&nbsp;444</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Make sure it is positive</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;445</td> <td class="nbHitsCovered">&nbsp;437</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">int</span> i = b &amp; 0xff;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;446</td> <td class="nbHitsCovered">&nbsp;437</td> <td class="src"><pre class="src">&nbsp; String hex = Integer.toHexString(i).toUpperCase();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;447</td> <td class="nbHitsUncovered"><a title="Line 447: Conditional coverage 50% (1/2).">&nbsp;437</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 447: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (hex.length() &gt; 2) {</a></span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;448</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> AssertionError();</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;449</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;450</td> <td class="nbHitsCovered"><a title="Line 450: Conditional coverage 100% (2/2).">&nbsp;454</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 450: Conditional coverage 100% (2/2)."> <span class="keyword">while</span> (hex.length() != 2) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;451</td> <td class="nbHitsCovered">&nbsp;17</td> <td class="src"><pre class="src">&nbsp; hex = <span class="string">"0"</span> + hex;</pre></td></tr>
<tr> <td class="numLine">&nbsp;452</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;453</td> <td class="nbHitsCovered">&nbsp;437</td> <td class="src"><pre class="src">&nbsp; sb.append(<span class="string">'%'</span>).append(hex);</pre></td></tr>
<tr> <td class="numLine">&nbsp;454</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;455</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;456</td> <td class="nbHitsCovered">&nbsp;314</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> sb.toString();</pre></td></tr>
<tr> <td class="numLine">&nbsp;457</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;458</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;459</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> DocumentRequest <span class="keyword">implements</span> Request {</pre></td></tr>
<tr> <td class="numLine">&nbsp;460</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> HttpExchange ex;</pre></td></tr>
<tr> <td class="numLine">&nbsp;461</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> DocId docId;</pre></td></tr>
<tr> <td class="numLine">&nbsp;462</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;463</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> DocumentRequest(HttpExchange ex, DocId docId) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;464</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.ex = ex;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;465</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.docId = docId;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;466</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;467</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;468</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;469</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">boolean</span> hasChangedSinceLastAccess(Date lastModified) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;470</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; Date date = getLastAccessTime();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;471</td> <td class="nbHitsCovered"><a title="Line 471: Conditional coverage 100% (2/2).">&nbsp;3</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 471: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (date == <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;472</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">true</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;473</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;474</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> date.before(lastModified);</pre></td></tr>
<tr> <td class="numLine">&nbsp;475</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;476</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;477</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;478</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> Date getLastAccessTime() {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;479</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> HttpExchanges.getIfModifiedSince(ex);</pre></td></tr>
<tr> <td class="numLine">&nbsp;480</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;481</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;482</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;483</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> DocId getDocId() {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;484</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> docId;</pre></td></tr>
<tr> <td class="numLine">&nbsp;485</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;486</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;487</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;488</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> String toString() {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;489</td> <td class="nbHitsCovered">&nbsp;3</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="string">"Request(docId="</span> + docId</pre></td></tr>
<tr> <td class="numLine">&nbsp;490</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">",lastAccessTime="</span> + getLastAccessTime() + <span class="string">")"</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;491</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;492</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;493</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;494</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;495</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * The state of the response. The state begins in SETUP mode, after which it</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;496</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * should transition to another state and become fixed at that state.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;497</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;498</td> <td class="nbHitsCovered">&nbsp;8</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> enum State {</pre></td></tr>
<tr> <td class="numLine">&nbsp;499</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;500</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * The class has not been informed how to respond, so we can still make</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;501</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * changes to what will be provided in headers.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;502</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;503</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; SETUP,</pre></td></tr>
<tr> <td class="numLine">&nbsp;504</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/** No content to send, but we do need a different response code. */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;505</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; NOT_MODIFIED,</pre></td></tr>
<tr> <td class="numLine">&nbsp;506</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/** No content to send, but we do need a different response code. */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;507</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; NOT_FOUND,</pre></td></tr>
<tr> <td class="numLine">&nbsp;508</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/** Must not respond with content, but otherwise act like normal. */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;509</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; HEAD,</pre></td></tr>
<tr> <td class="numLine">&nbsp;510</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/** No need to buffer contents before sending. */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;511</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; NO_TRANSFORM,</pre></td></tr>
<tr> <td class="numLine">&nbsp;512</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;513</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Buffer "small" contents. Large file contents will be written without</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;514</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * transformation or cause an exception (depending on transformRequired).</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;515</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;516</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; TRANSFORM,</pre></td></tr>
<tr> <td class="numLine">&nbsp;517</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;518</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;519</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;520</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Handles incoming data from adaptor and sending it to the client. There are</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;521</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * unfortunately many possible response cases. In short they are: document is</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;522</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Not Modified, document contents are ignored because we are responding to a</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;523</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * HEAD request, transform pipeline is in use and document is small, transform</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;524</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * pipeline is in use and document is large, and transform pipeline is not in</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;525</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * use.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;526</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;527</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;{@link #getOutputStream} and {@link #complete} are the main methods that</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;528</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * need to be very aware of all the different possibilities.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;529</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;530</td> <td class="nbHitsCovered">&nbsp;113</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">class</span> DocumentResponse <span class="keyword">implements</span> Response {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;531</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> State state = State.SETUP;</pre></td></tr>
<tr> <td class="numLine">&nbsp;532</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> HttpExchange ex;</pre></td></tr>
<tr> <td class="numLine">&nbsp;533</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Whether ex.getResponseBody().close() has been called while we are in the</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;534</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// NO_TRANSFORM state. This isn't used for much internal code that calls</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;535</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// close on the stream since it is obvious in those states that we won't</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;536</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// ever attempt to flush or close the stream a second time.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;537</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> responseBodyClosed;</pre></td></tr>
<tr> <td class="numLine">&nbsp;538</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> OutputStream os;</pre></td></tr>
<tr> <td class="numLine">&nbsp;539</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> CountingOutputStream countingOs;</pre></td></tr>
<tr> <td class="numLine">&nbsp;540</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> String contentType;</pre></td></tr>
<tr> <td class="numLine">&nbsp;541</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> Date lastModified;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;542</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> Metadata metadata = <span class="keyword">new</span> Metadata();</pre></td></tr>
<tr> <td class="numLine">&nbsp;543</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> Acl acl;</pre></td></tr>
<tr> <td class="numLine">&nbsp;544</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> secure;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;545</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> List&lt;URI&gt; anchorUris = <span class="keyword">new</span> ArrayList&lt;URI&gt;();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;546</td> <td class="nbHitsCovered">&nbsp;46</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> List&lt;String&gt; anchorTexts = <span class="keyword">new</span> ArrayList&lt;String&gt;();</pre></td></tr>
<tr> <td class="numLine">&nbsp;547</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> DocId docId;</pre></td></tr>
<tr> <td class="numLine">&nbsp;548</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> noIndex;</pre></td></tr>
<tr> <td class="numLine">&nbsp;549</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> noFollow;</pre></td></tr>
<tr> <td class="numLine">&nbsp;550</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> noArchive;</pre></td></tr>
<tr> <td class="numLine">&nbsp;551</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> URI displayUrl;</pre></td></tr>
<tr> <td class="numLine">&nbsp;552</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">boolean</span> crawlOnce;</pre></td></tr>
<tr> <td class="numLine">&nbsp;553</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre