Author: kwright
Date: Sun Sep 2 12:58:44 2012
New Revision: 1379961
URL: http://svn.apache.org/viewvc?rev=1379961&view=rev
Log:
Check in patches provided by Maciej Lizewski. Fixed the UI component of the
cifs connector patch, as well as the logic for calling getFileSecurity().
Added:
manifoldcf/branches/CONNECTORS-515/connectors/ldap/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/build.xml (with props)
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/LDAPAuthority.java
(with props)
Modified:
manifoldcf/branches/CONNECTORS-515/build.xml
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveParameters.java
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_en_US.properties
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_ja_JP.properties
Modified: manifoldcf/branches/CONNECTORS-515/build.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-515/build.xml?rev=1379961&r1=1379960&r2=1379961&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-515/build.xml (original)
+++ manifoldcf/branches/CONNECTORS-515/build.xml Sun Sep 2 12:58:44 2012
@@ -59,6 +59,7 @@
<ant dir="connectors/alfresco" target="clean"/>
<ant dir="connectors/cmis" target="clean"/>
<ant dir="connectors/activedirectory" target="clean"/>
+ <ant dir="connectors/ldap" target="clean"/>
<ant dir="connectors/documentum" target="clean"/>
<ant dir="connectors/filenet" target="clean"/>
<ant dir="connectors/filesystem" target="clean"/>
@@ -108,6 +109,7 @@
<ant dir="connectors/alfresco" target="clean"/>
<ant dir="connectors/cmis" target="clean"/>
<ant dir="connectors/activedirectory" target="clean"/>
+ <ant dir="connectors/ldap" target="clean"/>
<ant dir="connectors/documentum" target="clean"/>
<ant dir="connectors/filenet" target="clean"/>
<ant dir="connectors/filesystem" target="clean"/>
@@ -235,7 +237,43 @@
<target name="run-tests-HSQLDB-activedirectory-connector"
depends="setup-activedirectory-connector,setup-activedirectory-connector-tests"
if="downloaded">
<ant dir="connectors/activedirectory" target="run-tests-HSQLDB"/>
</target>
+
+ <target name="setup-ldap-connector" depends="build-framework"
if="downloaded"/>
+
+ <target name="setup-ldap-connector-tests" depends="build-tests-framework"
if="downloaded"/>
+
+ <target name="build-ldap-connector" depends="setup-ldap-connector"
if="downloaded">
+ <ant dir="connectors/ldap" target="build"/>
+ </target>
+
+ <target name="doc-ldap-connector" depends="setup-ldap-connector"
if="downloaded">
+ <ant dir="connectors/ldap" target="doc"/>
+ </target>
+ <target name="build-tests-ldap-connector"
depends="setup-ldap-connector,setup-ldap-connector-tests" if="downloaded">
+ <ant dir="connectors/ldap" target="build-tests"/>
+ </target>
+
+ <target name="run-tests-ldap-connector"
depends="setup-ldap-connector,setup-ldap-connector-tests" if="downloaded">
+ <ant dir="connectors/ldap" target="run-tests"/>
+ </target>
+
+ <target name="run-tests-derby-ldap-connector"
depends="setup-ldap-connector,setup-ldap-connector-tests" if="downloaded">
+ <ant dir="connectors/ldap" target="run-tests-derby"/>
+ </target>
+
+ <target name="run-tests-postgresql-ldap-connector"
depends="setup-ldap-connector,setup-ldap-connector-tests" if="downloaded">
+ <ant dir="connectors/ldap" target="run-tests-postgresql"/>
+ </target>
+
+ <target name="run-tests-mysql-ldap-connector"
depends="setup-ldap-connector,setup-ldap-connector-tests" if="downloaded">
+ <ant dir="connectors/ldap" target="run-tests-mysql"/>
+ </target>
+
+ <target name="run-tests-HSQLDB-ldap-connector"
depends="setup-ldap-connector,setup-ldap-connector-tests" if="downloaded">
+ <ant dir="connectors/ldap" target="run-tests-HSQLDB"/>
+ </target>
+
<target name="setup-alfresco-connector" depends="build-framework"
if="downloaded"/>
<target name="setup-cmis-connector" depends="build-framework"
if="downloaded"/>
@@ -1228,7 +1266,44 @@
<param name="connector-name" value="activedirectory"/>
</antcall>
</target>
-
+
+ <target name="calculate-ldap-condition" depends="build-ldap-connector">
+ <available file="connectors/ldap/dist/lib" type="dir"
property="ldap.exists"/>
+ <condition property="ldap.include">
+ <and>
+ <isset property="ldap.exists"/>
+ <isset property="downloaded"/>
+ </and>
+ </condition>
+ </target>
+
+ <target name="calculate-ldap-doc-condition" depends="doc-ldap-connector">
+ <available file="connectors/ldap/dist/doc" type="dir"
property="ldap-doc.exists"/>
+ <condition property="ldap-doc.include">
+ <and>
+ <isset property="ldap-doc.exists"/>
+ <isset property="downloaded"/>
+ </and>
+ </condition>
+ </target>
+
+ <target name="deliver-ldap-connector" depends="calculate-ldap-condition"
if="ldap.include">
+ <antcall target="general-connector-delivery">
+ <param name="connector-name" value="ldap"/>
+ </antcall>
+ <antcall target="general-add-authority-connector">
+ <param name="connector-name" value="ldap"/>
+ <param name="connector-label" value="LDAP"/>
+ <param name="connector-class"
value="org.apache.manifoldcf.authorities.authorities.ldap.LDAPAuthority"/>
+ </antcall>
+ </target>
+
+ <target name="deliver-ldap-connector-doc"
depends="calculate-ldap-doc-condition" if="ldap-doc.include">
+ <antcall target="general-connector-doc-delivery">
+ <param name="connector-name" value="ldap"/>
+ </antcall>
+ </target>
+
<target name="calculate-alfresco-condition"
depends="build-alfresco-connector">
<available file="connectors/alfresco/dist/lib" type="dir"
property="alfresco.exists"/>
<condition property="alfresco.include">
@@ -2058,6 +2133,14 @@
</condition>
</target>
+ <target name="calculate-ldap-tests-condition"
depends="calculate-ldap-condition">
+ <condition property="ldap-tests.include">
+ <and>
+ <isset property="ldap.include"/>
+ </and>
+ </condition>
+ </target>
+
<target name="calculate-solr-tests-condition"
depends="calculate-filesystem-condition,calculate-solr-condition">
<condition property="solr-tests.include">
<and>
@@ -2143,6 +2226,10 @@
<ant dir="tests/activedirectory" target="run-UI-derby"/>
</target>
+ <target name="run-ldap-UI-tests-derby"
depends="build-tests-framework,build-tests-ldap-connector,calculate-ldap-tests-condition"
if="ldap-tests.include">
+ <ant dir="tests/ldap" target="run-UI-derby"/>
+ </target>
+
<target name="run-filesystem-tests-derby"
depends="build-tests-framework,build-tests-filesystem-connector,build-tests-nulloutput-connector,calculate-filesystem-tests-condition"
if="filesystem-tests.include">
<ant dir="tests/filesystem" target="run-derby"/>
</target>
@@ -2379,29 +2466,29 @@
<ant dir="tests/sharepoint" target="run-load-HSQLDB"/>
</target>
- <target name="run-tests-open-connectors"
depends="run-tests-activedirectory-connector,run-tests-alfresco-connector,run-tests-cmis-connector,run-tests-filesystem-connector,run-tests-nullauthority-connector,run-tests-nulloutput-connector,run-tests-rss-connector,run-tests-solr-connector,run-tests-webcrawler-connector,run-tests-wiki-connector,run-tests-jdbc-connector"/>
+ <target name="run-tests-open-connectors"
depends="run-tests-activedirectory-connector,run-tests-ldap-connector,run-tests-alfresco-connector,run-tests-cmis-connector,run-tests-filesystem-connector,run-tests-nullauthority-connector,run-tests-nulloutput-connector,run-tests-rss-connector,run-tests-solr-connector,run-tests-webcrawler-connector,run-tests-wiki-connector,run-tests-jdbc-connector"/>
<target name="run-tests-lgpl-connectors"
depends="run-tests-jcifs-connector"/>
<target name="run-tests-proprietary-connectors"
depends="run-tests-documentum-connector,run-tests-filenet-connector,run-tests-livelink-connector,run-tests-memex-connector,run-tests-meridio-connector,run-tests-sharepoint-connector"/>
- <target name="run-tests-derby-open-connectors"
depends="run-tests-derby-activedirectory-connector,run-tests-derby-alfresco-connector,run-tests-derby-cmis-connector,run-tests-derby-filesystem-connector,run-tests-derby-nullauthority-connector,run-tests-derby-nulloutput-connector,run-tests-derby-rss-connector,run-tests-derby-solr-connector,run-tests-derby-webcrawler-connector,run-tests-derby-wiki-connector,run-tests-derby-jdbc-connector"/>
+ <target name="run-tests-derby-open-connectors"
depends="run-tests-derby-activedirectory-connector,run-tests-derby-ldap-connector,run-tests-derby-alfresco-connector,run-tests-derby-cmis-connector,run-tests-derby-filesystem-connector,run-tests-derby-nullauthority-connector,run-tests-derby-nulloutput-connector,run-tests-derby-rss-connector,run-tests-derby-solr-connector,run-tests-derby-webcrawler-connector,run-tests-derby-wiki-connector,run-tests-derby-jdbc-connector"/>
<target name="run-tests-derby-lgpl-connectors"
depends="run-tests-derby-jcifs-connector"/>
<target name="run-tests-derby-proprietary-connectors"
depends="run-tests-derby-documentum-connector,run-tests-derby-filenet-connector,run-tests-derby-livelink-connector,run-tests-derby-memex-connector,run-tests-derby-meridio-connector,run-tests-derby-sharepoint-connector"/>
<target name="end-to-end-tests-derby"
depends="run-filesystem-tests-derby,run-wiki-tests-derby,run-alfresco-tests-derby,run-cmis-tests-derby,run-sharepoint-tests-derby"/>
- <target name="run-tests-postgresql-open-connectors"
depends="run-tests-postgresql-activedirectory-connector,run-tests-postgresql-alfresco-connector,run-tests-postgresql-cmis-connector,run-tests-postgresql-filesystem-connector,run-tests-postgresql-nullauthority-connector,run-tests-postgresql-nulloutput-connector,run-tests-postgresql-rss-connector,run-tests-postgresql-solr-connector,run-tests-postgresql-webcrawler-connector,run-tests-postgresql-wiki-connector,run-tests-postgresql-jdbc-connector,run-tests-postgresql-opensearchserver-connector,run-tests-postgresql-elasticsearch-connector"/>
+ <target name="run-tests-postgresql-open-connectors"
depends="run-tests-postgresql-activedirectory-connector,run-tests-postgresql-ldap-connector,run-tests-postgresql-alfresco-connector,run-tests-postgresql-cmis-connector,run-tests-postgresql-filesystem-connector,run-tests-postgresql-nullauthority-connector,run-tests-postgresql-nulloutput-connector,run-tests-postgresql-rss-connector,run-tests-postgresql-solr-connector,run-tests-postgresql-webcrawler-connector,run-tests-postgresql-wiki-connector,run-tests-postgresql-jdbc-connector,run-tests-postgresql-opensearchserver-connector,run-tests-postgresql-elasticsearch-connector"/>
<target name="run-tests-postgresql-lgpl-connectors"
depends="run-tests-postgresql-jcifs-connector"/>
<target name="run-tests-postgresql-proprietary-connectors"
depends="run-tests-postgresql-documentum-connector,run-tests-postgresql-filenet-connector,run-tests-postgresql-livelink-connector,run-tests-postgresql-memex-connector,run-tests-postgresql-meridio-connector,run-tests-postgresql-sharepoint-connector"/>
<target name="end-to-end-tests-postgresql"
depends="run-filesystem-tests-postgresql,run-wiki-tests-postgresql,run-alfresco-tests-postgresql,run-cmis-tests-postgresql,run-sharepoint-tests-postgresql"/>
- <target name="run-tests-mysql-open-connectors"
depends="run-tests-mysql-activedirectory-connector,run-tests-mysql-alfresco-connector,run-tests-mysql-cmis-connector,run-tests-mysql-filesystem-connector,run-tests-mysql-nullauthority-connector,run-tests-mysql-nulloutput-connector,run-tests-mysql-rss-connector,run-tests-mysql-solr-connector,run-tests-mysql-webcrawler-connector,run-tests-mysql-wiki-connector,run-tests-mysql-jdbc-connector,run-tests-mysql-opensearchserver-connector,run-tests-mysql-elasticsearch-connector"/>
+ <target name="run-tests-mysql-open-connectors"
depends="run-tests-mysql-activedirectory-connector,run-tests-mysql-ldap-connector,run-tests-mysql-alfresco-connector,run-tests-mysql-cmis-connector,run-tests-mysql-filesystem-connector,run-tests-mysql-nullauthority-connector,run-tests-mysql-nulloutput-connector,run-tests-mysql-rss-connector,run-tests-mysql-solr-connector,run-tests-mysql-webcrawler-connector,run-tests-mysql-wiki-connector,run-tests-mysql-jdbc-connector,run-tests-mysql-opensearchserver-connector,run-tests-mysql-elasticsearch-connector"/>
<target name="run-tests-mysql-lgpl-connectors"
depends="run-tests-mysql-jcifs-connector"/>
<target name="run-tests-mysql-proprietary-connectors"
depends="run-tests-mysql-documentum-connector,run-tests-mysql-filenet-connector,run-tests-mysql-livelink-connector,run-tests-mysql-memex-connector,run-tests-mysql-meridio-connector,run-tests-mysql-sharepoint-connector"/>
<target name="end-to-end-tests-mysql"
depends="run-filesystem-tests-mysql,run-wiki-tests-mysql,run-alfresco-tests-mysql,run-cmis-tests-mysql,run-sharepoint-tests-mysql"/>
- <target name="run-tests-HSQLDB-open-connectors"
depends="run-tests-HSQLDB-activedirectory-connector,run-tests-HSQLDB-alfresco-connector,run-tests-HSQLDB-cmis-connector,run-tests-HSQLDB-filesystem-connector,run-tests-HSQLDB-nullauthority-connector,run-tests-HSQLDB-nulloutput-connector,run-tests-HSQLDB-rss-connector,run-tests-HSQLDB-solr-connector,run-tests-HSQLDB-webcrawler-connector,run-tests-HSQLDB-wiki-connector,run-tests-HSQLDB-jdbc-connector,run-tests-HSQLDB-opensearchserver-connector,run-tests-HSQLDB-elasticsearch-connector"/>
+ <target name="run-tests-HSQLDB-open-connectors"
depends="run-tests-HSQLDB-activedirectory-connector,run-tests-HSQLDB-ldap-connector,run-tests-HSQLDB-alfresco-connector,run-tests-HSQLDB-cmis-connector,run-tests-HSQLDB-filesystem-connector,run-tests-HSQLDB-nullauthority-connector,run-tests-HSQLDB-nulloutput-connector,run-tests-HSQLDB-rss-connector,run-tests-HSQLDB-solr-connector,run-tests-HSQLDB-webcrawler-connector,run-tests-HSQLDB-wiki-connector,run-tests-HSQLDB-jdbc-connector,run-tests-HSQLDB-opensearchserver-connector,run-tests-HSQLDB-elasticsearch-connector"/>
<target name="run-tests-HSQLDB-lgpl-connectors"
depends="run-tests-HSQLDB-jcifs-connector"/>
<target name="run-tests-HSQLDB-proprietary-connectors"
depends="run-tests-HSQLDB-documentum-connector,run-tests-HSQLDB-filenet-connector,run-tests-HSQLDB-livelink-connector,run-tests-HSQLDB-memex-connector,run-tests-HSQLDB-meridio-connector,run-tests-HSQLDB-sharepoint-connector"/>
@@ -2416,8 +2503,8 @@
<target name="end-to-end-loadtests-HSQLDB"
depends="run-filesystem-loadtests-HSQLDB,run-rss-loadtests-HSQLDB,run-wiki-loadtests-HSQLDB,run-alfresco-loadtests-HSQLDB,run-cmis-loadtests-HSQLDB,run-sharepoint-loadtests-HSQLDB"/>
- <target name="deliver-open-connectors"
depends="deliver-nullauthority-connector,deliver-activedirectory-connector,deliver-alfresco-connector,deliver-cmis-connector,deliver-filesystem-connector,deliver-rss-connector,deliver-webcrawler-connector,deliver-wiki-connector,deliver-jdbc-connector"/>
- <target name="deliver-open-connectors-doc"
depends="deliver-nullauthority-connector-doc,deliver-activedirectory-connector-doc,deliver-alfresco-connector-doc,deliver-cmis-connector-doc,deliver-filesystem-connector-doc,deliver-rss-connector-doc,deliver-webcrawler-connector-doc,deliver-wiki-connector-doc,deliver-jdbc-connector-doc"/>
+ <target name="deliver-open-connectors"
depends="deliver-nullauthority-connector,deliver-activedirectory-connector,deliver-ldap-connector,deliver-alfresco-connector,deliver-cmis-connector,deliver-filesystem-connector,deliver-rss-connector,deliver-webcrawler-connector,deliver-wiki-connector,deliver-jdbc-connector"/>
+ <target name="deliver-open-connectors-doc"
depends="deliver-nullauthority-connector-doc,deliver-activedirectory-connector-doc,deliver-ldap-connector-doc,deliver-alfresco-connector-doc,deliver-cmis-connector-doc,deliver-filesystem-connector-doc,deliver-rss-connector-doc,deliver-webcrawler-connector-doc,deliver-wiki-connector-doc,deliver-jdbc-connector-doc"/>
<target name="deliver-output-connectors"
depends="deliver-gts-connector,deliver-solr-connector,deliver-nulloutput-connector,deliver-opensearchserver-connector,deliver-elasticsearch-connector"/>
<target name="deliver-output-connectors-doc"
depends="deliver-gts-connector-doc,deliver-solr-connector-doc,deliver-nulloutput-connector-doc,deliver-opensearchserver-connector-doc,deliver-elasticsearch-connector-doc"/>
@@ -2564,7 +2651,7 @@
<target name="ldtest" depends="load-dr,load-hs"/>
- <target name="uitest"
depends="run-filesystem-UI-tests-derby,run-jcifs-UI-tests-derby,run-jdbc-UI-tests-derby,run-activedirectory-UI-tests-derby,run-rss-UI-tests-derby,run-webcrawler-UI-tests-derby,run-wiki-UI-tests-derby,run-solr-UI-tests-derby,run-cmis-UI-tests-derby,run-gts-UI-tests-derby,run-opensearchserver-UI-tests-derby"/>
+ <target name="uitest"
depends="run-filesystem-UI-tests-derby,run-jcifs-UI-tests-derby,run-jdbc-UI-tests-derby,run-activedirectory-UI-tests-derby,run-ldap-UI-tests-derby,run-rss-UI-tests-derby,run-webcrawler-UI-tests-derby,run-wiki-UI-tests-derby,run-solr-UI-tests-derby,run-cmis-UI-tests-derby,run-gts-UI-tests-derby,run-opensearchserver-UI-tests-derby"/>
<target name="all" depends="build,javadoc,doc,image,test-dr,test-hs"/>
@@ -3482,6 +3569,7 @@ Use Apache Forrest version forrest-0.9-d
<ant dir="connectors/alfresco" target="download-dependencies"/>
<ant dir="connectors/cmis" target="download-dependencies"/>
<ant dir="connectors/activedirectory" target="download-dependencies"/>
+ <ant dir="connectors/ldap" target="download-dependencies"/>
<ant dir="connectors/documentum" target="download-dependencies"/>
<ant dir="connectors/filenet" target="download-dependencies"/>
<ant dir="connectors/filesystem" target="download-dependencies"/>
@@ -3517,6 +3605,7 @@ Use Apache Forrest version forrest-0.9-d
<ant dir="connectors/alfresco" target="download-cleanup"/>
<ant dir="connectors/cmis" target="download-cleanup"/>
<ant dir="connectors/activedirectory" target="download-cleanup"/>
+ <ant dir="connectors/ldap" target="download-cleanup"/>
<ant dir="connectors/documentum" target="download-cleanup"/>
<ant dir="connectors/filenet" target="download-cleanup"/>
<ant dir="connectors/filesystem" target="download-cleanup"/>
Modified:
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java?rev=1379961&r1=1379960&r2=1379961&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
(original)
+++
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java
Sun Sep 2 12:58:44 2012
@@ -114,6 +114,7 @@ public class SharedDriveConnector extend
private String domain = null;
private String username = null;
private String password = null;
+ private boolean resolveSIDs = false;
private NtlmPasswordAuthentication pa;
@@ -213,6 +214,10 @@ public class SharedDriveConnector extend
password =
configParameters.getObfuscatedParameter(SharedDriveParameters.password);
if (password == null)
password = "";
+ String resolveSIDsString =
configParameters.getParameter(SharedDriveParameters.resolveSIDs);
+ if (resolveSIDsString == null)
+ resolveSIDsString = "true";
+ resolveSIDs = "true".equals(resolveSIDsString);
// Rejigger the username/domain to be sure we PASS in a domain and we do
not include the domain attached to the user!
// (This became essential at jcifs 1.3.0)
@@ -1002,7 +1007,7 @@ public class SharedDriveConnector extend
// Grab the share permissions.
- aces = getFileShareSecurity(file);
+ aces = getFileShareSecurity(file, resolveSIDs);
if (aces == null)
{
@@ -1047,9 +1052,9 @@ public class SharedDriveConnector extend
if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
{
if (ace.isAllow())
- shareAllowAcls[allowCount++] = ace.getSID().toString();
+ shareAllowAcls[allowCount++] = resolveSIDs ?
ace.getSID().getAccountName() : ace.getSID().toString();
else
- shareDenyAcls[denyCount++] = ace.getSID().toString();
+ shareDenyAcls[denyCount++] = resolveSIDs ?
ace.getSID().getAccountName() : ace.getSID().toString();
}
}
}
@@ -1077,7 +1082,7 @@ public class SharedDriveConnector extend
if (forcedacls.length==0)
{
- aces = getFileSecurity(file);
+ aces = getFileSecurity(file, resolveSIDs);
if (aces == null)
{
if (Logging.connectors.isDebugEnabled())
@@ -1121,9 +1126,9 @@ public class SharedDriveConnector extend
if ((ace.getAccessMask() & ACE.FILE_READ_DATA) != 0)
{
if (ace.isAllow())
- allowAcls[allowCount++] = ace.getSID().toString();
+ allowAcls[allowCount++] = resolveSIDs ?
ace.getSID().getAccountName() : ace.getSID().toString();
else
- denyAcls[denyCount++] = ace.getSID().toString();
+ denyAcls[denyCount++] = resolveSIDs ?
ace.getSID().getAccountName() : ace.getSID().toString();
}
}
}
@@ -2298,7 +2303,7 @@ public class SharedDriveConnector extend
}
/** Get file security */
- protected static ACE[] getFileSecurity(SmbFile file)
+ protected static ACE[] getFileSecurity(SmbFile file, boolean resolveSIDs)
throws IOException
{
int totalTries = 0;
@@ -2310,7 +2315,7 @@ public class SharedDriveConnector extend
totalTries++;
try
{
- return file.getSecurity(false);
+ return file.getSecurity(!resolveSIDs);
}
catch (java.net.SocketTimeoutException e)
{
@@ -2336,7 +2341,7 @@ public class SharedDriveConnector extend
}
/** Get share security */
- protected static ACE[] getFileShareSecurity(SmbFile file)
+ protected static ACE[] getFileShareSecurity(SmbFile file, boolean
resolveSIDs)
throws IOException
{
int totalTries = 0;
@@ -2348,7 +2353,7 @@ public class SharedDriveConnector extend
totalTries++;
try
{
- return file.getShareSecurity(false);
+ return file.getShareSecurity(resolveSIDs);
}
catch (java.net.SocketTimeoutException e)
{
@@ -2601,6 +2606,8 @@ public class SharedDriveConnector extend
if (username==null) username = "";
String password =
parameters.getObfuscatedParameter(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveParameters.password);
if (password==null) password = "";
+ String resolvesids =
parameters.getParameter(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveParameters.resolveSIDs);
+ if (resolvesids==null) resolvesids = "true";
// "Server" tab
if
(tabName.equals(Messages.getString(locale,"SharedDriveConnector.Server")))
@@ -2624,6 +2631,11 @@ public class SharedDriveConnector extend
" <td class=\"description\"><nobr>" +
Messages.getBodyString(locale,"SharedDriveConnector.Password") +
"</nobr></td>\n"+
" <td class=\"value\"><input type=\"password\" size=\"32\"
name=\"password\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(password)+"\"/></td>\n"+
" </tr>\n"+
+" <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>" +
Messages.getBodyString(locale,"SharedDriveConnector.UseSIDSForSecurity") +
"</nobr></td>\n"+
+" <td class=\"value\"><input type=\"hidden\" name=\"resolvesidspresent\"
value=\"true\"/><input type=\"checkbox\" value=\"true\" name=\"resolvesids\"
"+("true".equals(resolvesids)?"checked=\"true\"":"")+"/></td>\n"+
+" </tr>\n"+
"</table>\n"
);
}
@@ -2633,7 +2645,9 @@ public class SharedDriveConnector extend
"<input type=\"hidden\" name=\"server\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(server)+"\"/>\n"+
"<input type=\"hidden\" name=\"domain\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(domain)+"\"/>\n"+
"<input type=\"hidden\" name=\"username\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(username)+"\"/>\n"+
-"<input type=\"hidden\" name=\"password\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(password)+"\"/>\n"
+"<input type=\"hidden\" name=\"password\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(password)+"\"/>\n"+
+"<input type=\"hidden\" name=\"resolvesidspresent\" value=\"true\"/>\n"+
+"<input type=\"hidden\" name=\"resolvesids\"
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(resolvesids)+"\"/>\n"
);
}
}
@@ -2667,6 +2681,15 @@ public class SharedDriveConnector extend
String password = variableContext.getParameter("password");
if (password != null)
parameters.setObfuscatedParameter(org.apache.manifoldcf.crawler.connectors.sharedrive.SharedDriveParameters.password,password);
+
+ String resolvesidspresent =
variableContext.getParameter("resolvesidspresent");
+ if (resolvesidspresent != null)
+ {
+ parameters.setParameter(SharedDriveParameters.resolveSIDs,"false");
+ String resolvesids = variableContext.getParameter("resolvesids");
+ if (resolvesids != null)
+ parameters.setParameter(SharedDriveParameters.resolveSIDs,
resolvesids);
+ }
return null;
}
Modified:
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveParameters.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveParameters.java?rev=1379961&r1=1379960&r2=1379961&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveParameters.java
(original)
+++
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveParameters.java
Sun Sep 2 12:58:44 2012
@@ -34,4 +34,8 @@ public class SharedDriveParameters
/* password for the above server */
public final static String password = "Password";
+
+ /* SIDs handling */
+ public final static String resolveSIDs = "Resolve SIDs";
+
}
Modified:
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_en_US.properties
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_en_US.properties?rev=1379961&r1=1379960&r2=1379961&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_en_US.properties
(original)
+++
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_en_US.properties
Sun Sep 2 12:58:44 2012
@@ -22,6 +22,7 @@ SharedDriveConnector.URLMapping=URL Mapp
SharedDriveConnector.NeedAServerName=Need a server name
SharedDriveConnector.Server=Server
+SharedDriveConnector.UseSIDSForSecurity=Use SIDS for security:
SharedDriveConnector.Server2=Server
SharedDriveConnector.ServerNameCannotIncludePathInformation=Server name cannot
include path information
SharedDriveConnector.NeedAUserName=Need a user name
Modified:
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_ja_JP.properties
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_ja_JP.properties?rev=1379961&r1=1379960&r2=1379961&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_ja_JP.properties
(original)
+++
manifoldcf/branches/CONNECTORS-515/connectors/jcifs/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/sharedrive/common_ja_JP.properties
Sun Sep 2 12:58:44 2012
@@ -20,6 +20,7 @@ SharedDriveConnector.ContentLength=ã�
SharedDriveConnector.FileMapping=ãã¡ã¤ã«ãããã³ã°
SharedDriveConnector.URLMapping=URLãããã³ã°
SharedDriveConnector.NeedAServerName=ãµã¼ãåãå
¥åãã¦ãã ãã
+SharedDriveConnector.UseSIDSForSecurity=Use SIDS for security:
SharedDriveConnector.Server=ãµã¼ã
SharedDriveConnector.Server2=ãµã¼ã
SharedDriveConnector.ServerNameCannotIncludePathInformation=ãµã¼ãåã«ãã¹æ
å ±ãå«ããªãã§ãã ãã
Added: manifoldcf/branches/CONNECTORS-515/connectors/ldap/build.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-515/connectors/ldap/build.xml?rev=1379961&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-515/connectors/ldap/build.xml (added)
+++ manifoldcf/branches/CONNECTORS-515/connectors/ldap/build.xml Sun Sep 2
12:58:44 2012
@@ -0,0 +1,23 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="ldap" default="all">
+
+ <import file="../connector-build.xml"/>
+
+
+</project>
Propchange: manifoldcf/branches/CONNECTORS-515/connectors/ldap/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-515/connectors/ldap/build.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added:
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/LDAPAuthority.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/LDAPAuthority.java?rev=1379961&view=auto
==============================================================================
---
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/LDAPAuthority.java
(added)
+++
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/LDAPAuthority.java
Sun Sep 2 12:58:44 2012
@@ -0,0 +1,494 @@
+/* $Id$ */
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+* http://www.apache.org/licenses/LICENSE-2.0
+ *
+* Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.manifoldcf.authorities.authorities.ldap;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.authorities.interfaces.*;
+import org.apache.manifoldcf.authorities.system.Logging;
+import org.apache.manifoldcf.authorities.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import javax.naming.*;
+import javax.naming.ldap.*;
+import javax.naming.directory.*;
+import org.apache.manifoldcf.ui.util.Encoder;
+
+/**
+ * This is the Active Directory implementation of the IAuthorityConnector
+ * interface. Access tokens for this connector are simple SIDs, except for the
+ * "global deny" token, which is designed to allow the authority to shut off
+ * access to all authorized documents when the user is unrecognized or the
+ * domain controller does not respond.
+ */
+public class LDAPAuthority extends
org.apache.manifoldcf.authorities.authorities.BaseAuthorityConnector {
+
+ public static final String _rcsid = "@(#)$Id$";
+ /**
+ * Session information for all DC's we talk with.
+ */
+ private LdapContext session = null;
+ /**
+ * This is the active directory global deny token. This should be ingested
+ * with all documents.
+ */
+ private static final String globalDenyToken = "DEAD_AUTHORITY";
+ private static final AuthorizationResponse unreachableResponse = new
AuthorizationResponse(new String[]{globalDenyToken},
+ AuthorizationResponse.RESPONSE_UNREACHABLE);
+ private static final AuthorizationResponse userNotFoundResponse = new
AuthorizationResponse(new String[]{globalDenyToken},
+ AuthorizationResponse.RESPONSE_USERNOTFOUND);
+
+
+ private String serverURL;
+ private String userBase;
+ private String userSearch;
+ private String groupBase;
+ private String groupSearch;
+ private String groupNameAttr;
+
+ /**
+ * Constructor.
+ */
+ public LDAPAuthority() {
+ }
+
+ /**
+ * Set thread context.
+ */
+ @Override
+ public void setThreadContext(IThreadContext tc)
+ throws ManifoldCFException {
+ super.setThreadContext(tc);
+ }
+
+ /**
+ * Clear thread context.
+ */
+ @Override
+ public void clearThreadContext() {
+ super.clearThreadContext();
+ }
+
+ /**
+ * Connect. The configuration parameters are included.
+ *
+ * @param configParams are the configuration parameters for this
connection.
+ */
+ @Override
+ public void connect(ConfigParams configParams) {
+ super.connect(configParams);
+
+ serverURL = getParam( configParams, "ldapServerUrl",
"ldap://ldap.office.com:389/dc=office,dc=com");
+ userBase = getParam( configParams, "ldapUserBase", "ou=People" );
+ userSearch = getParam( configParams, "ldapUserSearch",
"(&(objectClass=inetOrgPerson)(uid={0}))" );
+ groupBase = getParam( configParams, "ldapGroupBase", "ou=Groups" );
+ groupSearch = getParam( configParams, "ldapGroupSearch",
"(&(objectClass=groupOfNames)(member={0}))" );
+ groupNameAttr = getParam( configParams, "ldapGroupNameAttr", "cn" );
+
+ Hashtable env = new Hashtable();
+ env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
+ env.put(Context.PROVIDER_URL, serverURL);
+
+ String em = "";
+ try {
+ if (session == null) {
+ session = new InitialLdapContext(env, null);
+ } else {
+ session.reconnect(null);
+ }
+ } catch (AuthenticationException e) {
+ } catch (CommunicationException e) {
+ } catch (NamingException e) {
+ em = e.toString();
+ }
+ em = em + "";
+ }
+
+ // All methods below this line will ONLY be called if a connect() call
succeeded
+ // on this instance!
+ /**
+ * Check connection for sanity.
+ */
+ @Override
+ public String check()
+ throws ManifoldCFException {
+ return super.check();
+ }
+
+ /**
+ * Poll. The connection should be closed if it has been idle for too long.
+ */
+ @Override
+ public void poll()
+ throws ManifoldCFException {
+ super.poll();
+ }
+
+ /**
+ * Close the connection. Call this before discarding the repository
+ * connector.
+ */
+ @Override
+ public void disconnect()
+ throws ManifoldCFException {
+ if (session != null) {
+ try {
+ session.close();
+ } catch (NamingException e) {
+ // Eat this error
+ }
+ session = null;
+ }
+ super.disconnect();
+ }
+
+ /**
+ * Obtain the access tokens for a given user name.
+ *
+ * @param userName is the user name or identifier.
+ * @return the response tokens (according to the current authority).
(Should
+ * throws an exception only when a condition cannot be properly described
+ * within the authorization response object.)
+ */
+ @Override
+ public AuthorizationResponse getAuthorizationResponse(String userName)
+ throws ManifoldCFException {
+ try {
+ //Get DistinguishedName (for this method we are using DomainPart
as a searchBase ie: DC=qa-ad-76,DC=metacarta,DC=com")
+ String usrDN = getDistinguishedName(session, userName);
+ if (usrDN == null) {
+ return userNotFoundResponse;
+ }
+
+ //specify the LDAP search filter
+ String searchFilter = groupSearch.replaceAll( "\\{0\\}",
ldapEscape(usrDN));
+ SearchControls searchCtls = new SearchControls();
+ searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ String returnedAtts[] = {groupNameAttr};
+ searchCtls.setReturningAttributes(returnedAtts);
+
+ //Search for tokens. Since every user *must* have a SID, the "no
user" detection should be safe.
+ NamingEnumeration answer = session.search(groupBase, searchFilter,
searchCtls);
+
+ ArrayList theGroups = new ArrayList();
+
+ while (answer.hasMoreElements()) {
+ SearchResult sr = (SearchResult) answer.next();
+ Attributes attrs = sr.getAttributes();
+ if (attrs != null) {
+ theGroups.add(attrs.get(groupNameAttr).get().toString());
+ }
+ }
+
+ String[] tokens = new String[theGroups.size()];
+ int k = 0;
+ while (k < tokens.length) {
+ tokens[k] = (String) theGroups.get(k);
+ k++;
+ }
+
+ return new AuthorizationResponse(tokens,
AuthorizationResponse.RESPONSE_OK);
+
+ } catch (NameNotFoundException e) {
+ // This means that the user doesn't exist
+ return userNotFoundResponse;
+ } catch (NamingException e) {
+ // Unreachable
+ return unreachableResponse;
+ }
+ }
+
+ /**
+ * Obtain the default access tokens for a given user name.
+ *
+ * @param userName is the user name or identifier.
+ * @return the default response tokens, presuming that the connect method
+ * fails.
+ */
+ @Override
+ public AuthorizationResponse getDefaultAuthorizationResponse(String
userName) {
+ // The default response if the getConnection method fails
+ return unreachableResponse;
+ }
+
+ // UI support methods.
+ //
+ // These support methods are involved in setting up authority connection
configuration information. The configuration methods cannot assume that the
+ // current authority object is connected. That is why they receive a
thread context argument.
+ /**
+ * Output the configuration header section. This method is called in the
+ * head section of the connector's configuration page. Its purpose is to
add
+ * the required tabs to the list, and to output any javascript methods that
+ * might be needed by the configuration editing HTML.
+ *
+ * @param threadContext is the local thread context.
+ * @param out is the output to which any HTML should be sent.
+ * @param parameters are the configuration parameters, as they currently
+ * exist, for this connection being configured.
+ * @param tabsArray is an array of tab names. Add to this array any tab
+ * names that are specific to the connector.
+ */
+ @Override
+ public void outputConfigurationHeader(IThreadContext threadContext,
IHTTPOutput out, Locale locale, ConfigParams parameters, List<String> tabsArray)
+ throws ManifoldCFException, IOException {
+ tabsArray.add("LDAP");
+/* out.print( "<script type=\"text/javascript\">\n"+
+"<!--\n"+
+"function checkConfig() {\n"+
+" return true;\n"+
+"}\n"+
+"\n"+
+"function checkConfigForSave() {\n"+
+" return true;\n"+
+"}\n"+
+"//-->\n"+
+"</script>\n"
+);*/
+ }
+
+ /**
+ * Output the configuration body section. This method is called in the body
+ * section of the authority connector's configuration page. Its purpose is
+ * to present the required form elements for editing. The coder can presume
+ * that the HTML that is output from this configuration will be within
+ * appropriate <html>, <body>, and <form> tags. The name of the form is
+ * "editconnection".
+ *
+ * @param threadContext is the local thread context.
+ * @param out is the output to which any HTML should be sent.
+ * @param parameters are the configuration parameters, as they currently
+ * exist, for this connection being configured.
+ * @param tabName is the current tab name.
+ */
+ @Override
+ public void outputConfigurationBody(IThreadContext threadContext,
IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
+ throws ManifoldCFException, IOException {
+ String serverURL = getParam( parameters, "ldapServerUrl",
"ldap://ldap.office.com:389/dc=office,dc=com");
+ String userBase = getParam( parameters, "ldapUserBase", "ou=People" );
+ String userSearch = getParam( parameters, "ldapUserSearch",
"(&(objectClass=inetOrgPerson)(uid={0}))" );
+ String groupBase = getParam( parameters, "ldapGroupBase", "ou=Groups"
);
+ String groupSearch = getParam( parameters, "ldapGroupSearch",
"(&(objectClass=groupOfNames)(member={0}))" );
+ String groupNameAttr = getParam( parameters, "ldapGroupNameAttr", "cn"
);
+
+ if (tabName.equals("LDAP")) {
+ out.print(
+ "<table class=\"displaytable\">\n"+
+ " <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>LDAP server
URL:</nobr></td>\n"+
+ " <td class=\"value\"><input type=\"text\" size=\"64\"
name=\"ldapServerUrl\"
value=\""+Encoder.attributeEscape(serverURL)+"\"/></td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>User search
base:</nobr></td>\n"+
+ " <td class=\"value\"><input type=\"text\" size=\"64\"
name=\"ldapUserBase\" value=\""+Encoder.attributeEscape(userBase)+"\"/></td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>User search
filter:</nobr></td>\n"+
+ " <td class=\"value\"><input type=\"text\" size=\"64\"
name=\"ldapUserSearch\"
value=\""+Encoder.attributeEscape(userSearch)+"\"/></td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>Group search
base:</nobr></td>\n"+
+ " <td class=\"value\"><input type=\"text\" size=\"64\"
name=\"ldapGroupBase\"
value=\""+Encoder.attributeEscape(groupBase)+"\"/></td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>Group search
filter:</nobr></td>\n"+
+ " <td class=\"value\"><input type=\"text\" size=\"64\"
name=\"ldapGroupSearch\"
value=\""+Encoder.attributeEscape(groupSearch)+"\"/></td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>Group name
attribute:</nobr></td>\n"+
+ " <td class=\"value\"><input type=\"text\" size=\"64\"
name=\"ldapGroupNameAttr\"
value=\""+Encoder.attributeEscape(groupNameAttr)+"\"/></td>\n"+
+ " </tr>\n"+
+
+ "</table>\n"
+ );
+ } else {
+ out.print( "<input type=\"hidden\" name=\"ldapServerUrl\"
value=\""+Encoder.attributeEscape(serverURL)+"\"/>\n");
+ out.print( "<input type=\"hidden\" name=\"ldapUserBase\"
value=\""+Encoder.attributeEscape(userBase)+"\"/>\n");
+ out.print( "<input type=\"hidden\" name=\"ldapUserSearch\"
value=\""+Encoder.attributeEscape(userSearch)+"\"/>\n");
+ out.print( "<input type=\"hidden\" name=\"ldapGroupBase\"
value=\""+Encoder.attributeEscape(groupBase)+"\"/>\n");
+ out.print( "<input type=\"hidden\" name=\"ldapGroupSearch\"
value=\""+Encoder.attributeEscape(groupSearch)+"\"/>\n");
+ out.print( "<input type=\"hidden\" name=\"ldapGroupNameAttr\"
value=\""+Encoder.attributeEscape(groupNameAttr)+"\"/>\n");
+ }
+ }
+
+ private String getParam( ConfigParams parameters, String name, String def)
{
+ return parameters.getParameter(name) != null ?
parameters.getParameter(name) : def;
+ }
+
+ private boolean copyParam( IPostParameters variableContext, ConfigParams
parameters, String name) {
+ String val = variableContext.getParameter( name );
+ if( val == null ){
+ return false;
+ }
+ if( val.isEmpty() ) {
+ return false;
+ }
+ parameters.setParameter( name, val );
+ return true;
+ }
+
+ /**
+ * Process a configuration post. This method is called at the start of the
+ * authority connector's configuration page, whenever there is a
possibility
+ * that form data for a connection has been posted. Its purpose is to
gather
+ * form information and modify the configuration parameters accordingly.
The
+ * name of the posted form is "editconnection".
+ *
+ * @param threadContext is the local thread context.
+ * @param variableContext is the set of variables available from the post,
+ * including binary file post information.
+ * @param parameters are the configuration parameters, as they currently
+ * exist, for this connection being configured.
+ * @return null if all is well, or a string error message if there is an
+ * error that should prevent saving of the connection (and cause a
+ * redirection to an error page).
+ */
+ @Override
+ public String processConfigurationPost(IThreadContext threadContext,
IPostParameters variableContext, Locale locale, ConfigParams parameters)
+ throws ManifoldCFException {
+ boolean ok = true;
+
+ ok = ok & copyParam(variableContext, parameters, "ldapServerUrl" );
+ ok = ok & copyParam(variableContext, parameters, "ldapUserBase" );
+ ok = ok & copyParam(variableContext, parameters, "ldapUserSearch" );
+ ok = ok & copyParam(variableContext, parameters, "ldapGroupBase" );
+ ok = ok & copyParam(variableContext, parameters, "ldapGroupSearch" );
+ ok = ok & copyParam(variableContext, parameters, "ldapGroupNameAttr" );
+ /*if( !ok ) {
+ return "All LDAP parameters are required!";
+ }*/
+ return null;
+ }
+
+ /**
+ * View configuration. This method is called in the body section of the
+ * authority connector's view configuration page. Its purpose is to present
+ * the connection information to the user. The coder can presume that the
+ * HTML that is output from this configuration will be within appropriate
+ * <html> and <body> tags.
+ *
+ * @param threadContext is the local thread context.
+ * @param out is the output to which any HTML should be sent.
+ * @param parameters are the configuration parameters, as they currently
+ * exist, for this connection being configured.
+ */
+ @Override
+ public void viewConfiguration(IThreadContext threadContext, IHTTPOutput
out, Locale locale, ConfigParams parameters)
+ throws ManifoldCFException, IOException {
+ String serverURL = getParam( parameters, "ldapServerUrl",
"ldap://ldap.office.com:389/dc=office,dc=com");
+ String userBase = getParam( parameters, "ldapUserBase", "ou=People" );
+ String userSearch = getParam( parameters, "ldapUserSearch",
"(&(objectClass=inetOrgPerson)(uid={0}))" );
+ String groupBase = getParam( parameters, "ldapGroupBase", "ou=Groups"
);
+ String groupSearch = getParam( parameters, "ldapGroupSearch",
"(&(objectClass=groupOfNames)(member={0}))" );
+ String groupNameAttr = getParam( parameters, "ldapGroupNameAttr", "cn"
);
+ out.print(
+ "<table class=\"displaytable\">\n"+
+ " <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>LDAP server
URL:</nobr></td>\n"+
+ " <td
class=\"value\">"+Encoder.attributeEscape(serverURL)+"</td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>User search
base:</nobr></td>\n"+
+ " <td
class=\"value\">"+Encoder.attributeEscape(userBase)+"</td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>User search
filter:</nobr></td>\n"+
+ " <td
class=\"value\">"+Encoder.attributeEscape(userSearch)+"</td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>Group search
base:</nobr></td>\n"+
+ " <td
class=\"value\">"+Encoder.attributeEscape(groupBase)+"</td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>Group search
filter:</nobr></td>\n"+
+ " <td
class=\"value\">"+Encoder.attributeEscape(groupSearch)+"</td>\n"+
+ " </tr>\n"+
+
+ " <tr>\n"+
+ " <td class=\"description\"><nobr>Group name
attribute:</nobr></td>\n"+
+ " <td
class=\"value\">"+Encoder.attributeEscape(groupNameAttr)+"</td>\n"+
+ " </tr>\n"+
+
+ "</table>\n"
+ );
+ }
+
+ // Protected methods
+ /**
+ * Obtain the DistinguishedName for a given user logon name.
+ *
+ * @param ctx is the ldap context to use.
+ * @param userName (Domain Logon Name) is the user name or identifier.
+ * @param searchBase (Full Domain Name for the search ie:
+ * DC=qa-ad-76,DC=metacarta,DC=com)
+ * @return DistinguishedName for given domain user logon name. (Should
+ * throws an exception if user is not found.)
+ */
+ protected String getDistinguishedName(LdapContext ctx, String userName)
+ throws ManifoldCFException {
+ String returnedAtts[] = {"dn"};
+ String searchFilter = userSearch.replaceAll( "\\{0\\}",
ldapEscape(userName));
+ SearchControls searchCtls = new SearchControls();
+ searchCtls.setReturningAttributes(returnedAtts);
+ searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+ try {
+ NamingEnumeration answer = ctx.search(userBase, searchFilter,
searchCtls);
+ while (answer.hasMoreElements()) {
+ SearchResult sr = (SearchResult) answer.next();
+ return sr.getNameInNamespace();
+ }
+ return null;
+ } catch (Exception e) {
+ throw new ManifoldCFException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * LDAP escape a string.
+ */
+ protected static String ldapEscape(String input) {
+ //Add escape sequence to all commas
+ StringBuilder sb = new StringBuilder();
+ int index = 0;
+ while (true) {
+ int oldIndex = index;
+ index = input.indexOf(",", oldIndex);
+ if (index == -1) {
+ sb.append(input.substring(oldIndex));
+ break;
+ }
+ sb.append(input.substring(oldIndex, index)).append("\\,");
+ index++;
+ }
+ return sb.toString();
+ }
+}
Propchange:
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/LDAPAuthority.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
manifoldcf/branches/CONNECTORS-515/connectors/ldap/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/ldap/LDAPAuthority.java
------------------------------------------------------------------------------
svn:keywords = Id