Author: shinichiro
Date: Thu Feb 20 02:38:41 2014
New Revision: 1570056
URL: http://svn.apache.org/r1570056
Log:
Fix for CONNECTORS-886
Modified:
manifoldcf/integration/solr-3.x/trunk/CHANGES.txt
manifoldcf/integration/solr-3.x/trunk/mcf/CHANGES.txt
manifoldcf/integration/solr-3.x/trunk/mcf/README.txt
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/schema-auth.xml
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-load.xml
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-qparser.xml
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth.xml
Modified: manifoldcf/integration/solr-3.x/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/CHANGES.txt?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
--- manifoldcf/integration/solr-3.x/trunk/CHANGES.txt (original)
+++ manifoldcf/integration/solr-3.x/trunk/CHANGES.txt Thu Feb 20 02:38:41 2014
@@ -3,6 +3,11 @@ $Id$
======================= 1.2-dev =====================
+CONNECTORS-886: Provide [allow|deny]_token_directory_N fields.
+With mcf.auth.directoryCount param, we can control
+token_directory fields filtering.
+(Shinichiro Abe)
+
======================= Release 1.1 =====================
CONNECTORS-825: Fix infinite loop in new code.
Modified: manifoldcf/integration/solr-3.x/trunk/mcf/CHANGES.txt
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/CHANGES.txt?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
--- manifoldcf/integration/solr-3.x/trunk/mcf/CHANGES.txt (original)
+++ manifoldcf/integration/solr-3.x/trunk/mcf/CHANGES.txt Thu Feb 20 02:38:41
2014
@@ -13,9 +13,9 @@ require the argument "AuthorityServiceBa
the ManifoldCF Authority Service. Other optional parameters are:
AllowAttributePrefix - the first part of the 'allow' family of fields, e.g.
"allow_token_document" or
- "allow_token_share", defaulting to "allow_token_".
+ "allow_token_share" or "allow_token_directory_0", defaulting to
"allow_token_".
DenyAttributePrefix - the first part of the 'deny' family of fields, e.g.
"deny_token_document" or
- "deny_token_share", defaulting to "deny_token_".
+ "deny_token_share" or "deny_token_directory_0", defaulting to
"deny_token_".
ConnectionPoolSize - the size of the connection pool (default is 50).
$Id$
Modified: manifoldcf/integration/solr-3.x/trunk/mcf/README.txt
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/README.txt?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
--- manifoldcf/integration/solr-3.x/trunk/mcf/README.txt (original)
+++ manifoldcf/integration/solr-3.x/trunk/mcf/README.txt Thu Feb 20 02:38:41
2014
@@ -34,6 +34,14 @@ documents and shares, and a 'deny' field
<field name="deny_token_document" type="string" indexed="true"
stored="false" multiValued="true" required="false" default="__nosecurity__"/>
<field name="deny_token_share" type="string" indexed="true" stored="false"
multiValued="true" required="false" default="__nosecurity__"/>
+If needed, there will need to plus two of these fields for directory.
+[allow|deny]_token_directory_N. N is the number that is greater than or equal
to zero.
+Currently directory_0 is supported in Jcifs connector.
+
+ <field name="allow_token_directory_0" type="string" indexed="true"
stored="false" multiValued="true" required="false" default="__nosecurity__"/>
+ <field name="deny_token_directory_0" type="string" indexed="true"
stored="false" multiValued="true" required="false" default="__nosecurity__"/>
+
+
Using the Query Parser Plugin
----------------------------
@@ -77,6 +85,22 @@ Hook up the search component in the solr
...
</requestHandler>
+
+Supplying token_directory for filtering
+----------------------------------------------
+
+This component looks for the following parameter in the Solr request object:
+
+mcf.auth.directoryCount
+
+If you do not use [allow|deny]_token_directory_N fields in your schema.xml,
+you may specify 0. Default to 0.
+You can specify the count of directory_N pairs. When using directory_0, set to
1.
+Using this parameter value, this component will filter documents.
+If null or 0, then the filtering by share, document.
+If 1, then the filtering by share, direcory_0, document.
+If 2, then the filtering by share, direcory_0, direcory_1, document.
+
Supplying authenticated usernames and domains
----------------------------------------------
Modified:
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
---
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
(original)
+++
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
Thu Feb 20 02:38:41 2014
@@ -61,7 +61,10 @@ public class ManifoldCFQParserPlugin ext
static final public String AUTHENTICATED_USER_NAME_PREFIX =
"AuthenticatedUserName_";
/** If there are more than one user/domain, this prefix will allow us to get
the authorization domains... */
static final public String AUTHENTICATED_USER_DOMAIN_PREFIX =
"AuthenticatedUserDomain_";
-
+
+ /** The parameter that is supposed to contain token_directory for filtering
*/
+ static final public String AUTH_DIRECTORYCOUNT =
COMPONENT_NAME+".auth.directoryCount";
+
/** This parameter is an array of strings, which contain the tokens to use
if there is no authenticated user name.
* It's meant to work with mod_authz_annotate,
* running under Apache */
@@ -82,6 +85,8 @@ public class ManifoldCFQParserPlugin ext
String fieldDenyDocument = null;
String fieldAllowShare = null;
String fieldDenyShare = null;
+ String fieldAllowDirectory = null;
+ String fieldDenyDirectory = null;
int socketTimeOut;
Integer connectionManagerSynchronizer = new Integer(0);
MultiThreadedHttpConnectionManager httpConnectionManager = null;
@@ -110,6 +115,8 @@ public class ManifoldCFQParserPlugin ext
fieldDenyDocument = denyAttributePrefix+"document";
fieldAllowShare = allowAttributePrefix+"share";
fieldDenyShare = denyAttributePrefix+"share";
+ fieldAllowDirectory = allowAttributePrefix+"directory_";
+ fieldDenyDirectory = denyAttributePrefix+"directory_";
Integer connectionPoolSize = (Integer)args.get("ConnectionPoolSize");
poolSize = (connectionPoolSize==null)?50:connectionPoolSize.intValue();
}
@@ -240,11 +247,25 @@ public class ManifoldCFQParserPlugin ext
}
}
+ // Get the auth directory field count from the parameter
+ int directoryCount = params.getInt(AUTH_DIRECTORYCOUNT, 0);
+
BooleanQuery bq = new BooleanQuery();
//bf.setMaxClauseCount(100000);
Query allowShareOpen = new TermQuery(new
Term(fieldAllowShare,NOSECURITY_TOKEN));
Query denyShareOpen = new TermQuery(new
Term(fieldDenyShare,NOSECURITY_TOKEN));
+ Map<Integer,Query> allowDirectoryOpenMap = new HashMap<Integer,Query>();
+ Map<Integer,Query> denyDirectoryOpenMap = new HashMap<Integer,Query>();
+ int q = 0;
+ while (q < directoryCount)
+ {
+ Query allowDirectoryOpen = new TermQuery(new
Term(fieldAllowDirectory+q,NOSECURITY_TOKEN));
+ Query denyDirectoryOpen = new TermQuery(new
Term(fieldDenyDirectory+q,NOSECURITY_TOKEN));
+ allowDirectoryOpenMap.put(Integer.valueOf(q), allowDirectoryOpen);
+ denyDirectoryOpenMap.put(Integer.valueOf(q), denyDirectoryOpen);
+ q++;
+ }
Query allowDocumentOpen = new TermQuery(new
Term(fieldAllowDocument,NOSECURITY_TOKEN));
Query denyDocumentOpen = new TermQuery(new
Term(fieldDenyDocument,NOSECURITY_TOKEN));
@@ -257,6 +278,16 @@ public class ManifoldCFQParserPlugin ext
// have the SolrConnector inject a special token into these fields
when they otherwise would be empty, and we can trivially match on that token.
bq.add(allowShareOpen,BooleanClause.Occur.MUST);
bq.add(denyShareOpen,BooleanClause.Occur.MUST);
+ int r = 0;
+ while (r < directoryCount)
+ {
+ Integer index = Integer.valueOf(r);
+ Query allowDirectoryOpen = allowDirectoryOpenMap.get(index);
+ Query denyDirectoryOpen = denyDirectoryOpenMap.get(index);
+ bq.add(allowDirectoryOpen,BooleanClause.Occur.MUST);
+ bq.add(denyDirectoryOpen,BooleanClause.Occur.MUST);
+ r++;
+ }
bq.add(allowDocumentOpen,BooleanClause.Occur.MUST);
bq.add(denyDocumentOpen,BooleanClause.Occur.MUST);
}
@@ -265,6 +296,16 @@ public class ManifoldCFQParserPlugin ext
// Extend the query appropriately for each user access token.
bq.add(calculateCompleteSubquery(fieldAllowShare,fieldDenyShare,allowShareOpen,denyShareOpen,userAccessTokens),
BooleanClause.Occur.MUST);
+ int r = 0;
+ while (r < directoryCount)
+ {
+ Integer index = Integer.valueOf(r);
+ Query allowDirectoryOpen = allowDirectoryOpenMap.get(index);
+ Query denyDirectoryOpen = denyDirectoryOpenMap.get(index);
+
bq.add(calculateCompleteSubquery(fieldAllowDirectory+r,fieldDenyDirectory+r,allowDirectoryOpen,denyDirectoryOpen,userAccessTokens),
+ BooleanClause.Occur.MUST);
+ r++;
+ }
bq.add(calculateCompleteSubquery(fieldAllowDocument,fieldDenyDocument,allowDocumentOpen,denyDocumentOpen,userAccessTokens),
BooleanClause.Occur.MUST);
}
Modified:
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
---
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
(original)
+++
manifoldcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
Thu Feb 20 02:38:41 2014
@@ -53,7 +53,10 @@ public class ManifoldCFSearchComponent e
static final public String AUTHENTICATED_USER_NAME_PREFIX =
"AuthenticatedUserName_";
/** If there are more than one user/domain, this prefix will allow us to get
the authorization domains... */
static final public String AUTHENTICATED_USER_DOMAIN_PREFIX =
"AuthenticatedUserDomain_";
-
+
+ /** The parameter that is supposed to contain token_directory for filtering
*/
+ static final public String AUTH_DIRECTORYCOUNT =
COMPONENT_NAME+".auth.directoryCount";
+
/** This parameter is an array of strings, which contain the tokens to use
if there is no authenticated user name.
* It's meant to work with mod_authz_annotate,
* running under Apache */
@@ -74,6 +77,8 @@ public class ManifoldCFSearchComponent e
String fieldDenyDocument = null;
String fieldAllowShare = null;
String fieldDenyShare = null;
+ String fieldAllowDirectory = null;
+ String fieldDenyDirectory = null;
int socketTimeOut;
MultiThreadedHttpConnectionManager httpConnectionManager = null;
HttpClient client = null;
@@ -111,6 +116,8 @@ public class ManifoldCFSearchComponent e
fieldDenyDocument = denyAttributePrefix+"document";
fieldAllowShare = allowAttributePrefix+"share";
fieldDenyShare = denyAttributePrefix+"share";
+ fieldAllowDirectory = allowAttributePrefix+"directory_";
+ fieldDenyDirectory = denyAttributePrefix+"directory_";
Integer connectionPoolSize = (Integer)args.get("ConnectionPoolSize");
poolSize = (connectionPoolSize==null)?50:connectionPoolSize.intValue();
@@ -223,11 +230,25 @@ public class ManifoldCFSearchComponent e
userAccessTokens = getAccessTokens(domainMap);
}
+ // Get the auth directory field count from the parameter
+ int directoryCount = params.getInt(AUTH_DIRECTORYCOUNT, 0);
+
BooleanQuery bq = new BooleanQuery();
//bf.setMaxClauseCount(100000);
Query allowShareOpen = new TermQuery(new
Term(fieldAllowShare,NOSECURITY_TOKEN));
Query denyShareOpen = new TermQuery(new
Term(fieldDenyShare,NOSECURITY_TOKEN));
+ Map<Integer,Query> allowDirectoryOpenMap = new HashMap<Integer,Query>();
+ Map<Integer,Query> denyDirectoryOpenMap = new HashMap<Integer,Query>();
+ int q = 0;
+ while (q < directoryCount)
+ {
+ Query allowDirectoryOpen = new TermQuery(new
Term(fieldAllowDirectory+q,NOSECURITY_TOKEN));
+ Query denyDirectoryOpen = new TermQuery(new
Term(fieldDenyDirectory+q,NOSECURITY_TOKEN));
+ allowDirectoryOpenMap.put(Integer.valueOf(q), allowDirectoryOpen);
+ denyDirectoryOpenMap.put(Integer.valueOf(q), denyDirectoryOpen);
+ q++;
+ }
Query allowDocumentOpen = new TermQuery(new
Term(fieldAllowDocument,NOSECURITY_TOKEN));
Query denyDocumentOpen = new TermQuery(new
Term(fieldDenyDocument,NOSECURITY_TOKEN));
@@ -240,6 +261,16 @@ public class ManifoldCFSearchComponent e
// have the SolrConnector inject a special token into these fields when
they otherwise would be empty, and we can trivially match on that token.
bq.add(allowShareOpen,BooleanClause.Occur.MUST);
bq.add(denyShareOpen,BooleanClause.Occur.MUST);
+ int r = 0;
+ while (r < directoryCount)
+ {
+ Integer index = Integer.valueOf(r);
+ Query allowDirectoryOpen = allowDirectoryOpenMap.get(index);
+ Query denyDirectoryOpen = denyDirectoryOpenMap.get(index);
+ bq.add(allowDirectoryOpen,BooleanClause.Occur.MUST);
+ bq.add(denyDirectoryOpen,BooleanClause.Occur.MUST);
+ r++;
+ }
bq.add(allowDocumentOpen,BooleanClause.Occur.MUST);
bq.add(denyDocumentOpen,BooleanClause.Occur.MUST);
}
@@ -248,6 +279,16 @@ public class ManifoldCFSearchComponent e
// Extend the query appropriately for each user access token.
bq.add(calculateCompleteSubquery(fieldAllowShare,fieldDenyShare,allowShareOpen,denyShareOpen,userAccessTokens),
BooleanClause.Occur.MUST);
+ int r = 0;
+ while (r < directoryCount)
+ {
+ Integer index = Integer.valueOf(r);
+ Query allowDirectoryOpen = allowDirectoryOpenMap.get(index);
+ Query denyDirectoryOpen = denyDirectoryOpenMap.get(index);
+
bq.add(calculateCompleteSubquery(fieldAllowDirectory+r,fieldDenyDirectory+r,allowDirectoryOpen,denyDirectoryOpen,userAccessTokens),
+ BooleanClause.Occur.MUST);
+ r++;
+ }
bq.add(calculateCompleteSubquery(fieldAllowDocument,fieldDenyDocument,allowDocumentOpen,denyDocumentOpen,userAccessTokens),
BooleanClause.Occur.MUST);
}
Modified:
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/schema-auth.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/schema-auth.xml?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
---
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/schema-auth.xml
(original)
+++
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/schema-auth.xml
Thu Feb 20 02:38:41 2014
@@ -26,6 +26,8 @@
<field name="deny_token_document" type="string" indexed="true"
stored="false" multiValued="true" default="__nosecurity__"/>
<field name="allow_token_share" type="string" indexed="true" stored="false"
multiValued="true" default="__nosecurity__"/>
<field name="deny_token_share" type="string" indexed="true" stored="false"
multiValued="true" default="__nosecurity__"/>
+ <field name="allow_token_directory_0" type="string" indexed="true"
stored="false" multiValued="true" default="__nosecurity__"/>
+ <field name="deny_token_directory_0" type="string" indexed="true"
stored="false" multiValued="true" default="__nosecurity__"/>
</fields>
<defaultSearchField>id</defaultSearchField>
<uniqueKey>id</uniqueKey>
Modified:
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-load.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-load.xml?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
---
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-load.xml
(original)
+++
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-load.xml
Thu Feb 20 02:38:41 2014
@@ -51,6 +51,7 @@
<requestHandler name="/mcf" class="solr.SearchHandler" startup="lazy">
<lst name="invariants">
<bool name="mcf">true</bool>
+ <int name="mcf.auth.directoryCount">1</int>
</lst>
<lst name="defaults">
<str name="echoParams">all</str>
Modified:
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-qparser.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-qparser.xml?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
---
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-qparser.xml
(original)
+++
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth-qparser.xml
Thu Feb 20 02:38:41 2014
@@ -51,6 +51,7 @@
<requestHandler name="/mcf" class="solr.SearchHandler" startup="lazy">
<lst name="invariants">
<bool name="mcf">true</bool>
+ <int name="mcf.auth.derectoryCount">1</int>
</lst>
<lst name="defaults">
<str name="echoParams">all</str>
Modified:
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth.xml?rev=1570056&r1=1570055&r2=1570056&view=diff
==============================================================================
---
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth.xml
(original)
+++
manifoldcf/integration/solr-3.x/trunk/mcf/src/test-files/solr/conf/solrconfig-auth.xml
Thu Feb 20 02:38:41 2014
@@ -50,6 +50,7 @@
<requestHandler name="/mcf" class="solr.SearchHandler" startup="lazy">
<lst name="invariants">
<bool name="mcf">true</bool>
+ <int name="mcf.auth.derectoryCount">1</int>
</lst>
<lst name="defaults">
<str name="echoParams">all</str>