}
@Override
public void prepare(ResponseBuilder rb) throws IOException
{
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, true) || params.get(ShardParams.SHARDS) != null)
return;
// Log that we got here
//LOG.info("prepare() entry params:\n" + params + "\ncontext: " + rb.req.getContext());
String qry = (String)params.get(CommonParams.Q);
if (qry != null)
{
//Check global allowed searches
for (String ga : globalAllowed)
{
if (qry.equalsIgnoreCase(ga.trim()))
// Allow this query through unchanged
return;
}
}
List<String> userAccessTokens;
// Map from domain to user
Map<String,String> domainMap = new HashMap<String,String>();
// Get the authenticated user name from the parameters
String authenticatedUserName = params.get(AUTHENTICATED_USER_NAME);
if (authenticatedUserName != null)
{
String authenticatedUserDomain = params.get(AUTHENTICATED_USER_DOMAIN);
if (authenticatedUserDomain == null)
authenticatedUserDomain = "";
domainMap.put(authenticatedUserDomain, authenticatedUserName);
}
else
{
// Look for user names/domains using the prefix
int i = 0;
while (true)
{
String userName = params.get(AUTHENTICATED_USER_NAME_PREFIX+i);
String domain = params.get(AUTHENTICATED_USER_DOMAIN+i);
if (userName == null)
break;
if (domain == null)
domain = "";
domainMap.put(domain,userName);
i++;
}
}
// If this parameter is empty or does not exist, we have to presume this is a guest, and treat them accordingly
if (domainMap.size() == 0)
{
// No authenticated user name.
// mod_authz_annotate may be in use upstream, so look for tokens from it.
userAccessTokens = new ArrayList<String>();
String[] passedTokens = params.getParams(USER_TOKENS);
if (passedTokens == null)
{
// Only return 'public' documents (those with no security tokens at all)
LOG.info("Default no-user response (open documents only)");
}