marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [2/2] git commit: added optional authentication for LdapFoafProvider
Date Fri, 08 Mar 2013 09:42:22 GMT
Updated Branches:
  refs/heads/master 757161830 -> 0cd03ecff


added optional authentication for LdapFoafProvider


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/0cd03ecf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/0cd03ecf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/0cd03ecf

Branch: refs/heads/master
Commit: 0cd03ecff11d5dc9adc35d2e73c73caaf71ad824
Parents: 0c32969
Author: Sergio Fernández <wikier@apache.org>
Authored: Fri Mar 8 10:41:44 2013 +0100
Committer: Sergio Fernández <wikier@apache.org>
Committed: Fri Mar 8 10:41:44 2013 +0100

----------------------------------------------------------------------
 .../ldclient/provider/ldap/LdapFoafProvider.java   |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/0cd03ecf/libraries/ldclient/ldclient-provider-ldap/src/main/java/org/apache/marmotta/ldclient/provider/ldap/LdapFoafProvider.java
----------------------------------------------------------------------
diff --git a/libraries/ldclient/ldclient-provider-ldap/src/main/java/org/apache/marmotta/ldclient/provider/ldap/LdapFoafProvider.java
b/libraries/ldclient/ldclient-provider-ldap/src/main/java/org/apache/marmotta/ldclient/provider/ldap/LdapFoafProvider.java
index 6e7cd0e..e0ade1b 100644
--- a/libraries/ldclient/ldclient-provider-ldap/src/main/java/org/apache/marmotta/ldclient/provider/ldap/LdapFoafProvider.java
+++ b/libraries/ldclient/ldclient-provider-ldap/src/main/java/org/apache/marmotta/ldclient/provider/ldap/LdapFoafProvider.java
@@ -35,6 +35,7 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.marmotta.commons.constants.Namespace;
 import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
@@ -120,16 +121,22 @@ public class LdapFoafProvider implements DataProvider {
      * @throws DataRetrievalException
      */
     private LdapConnection openLdapConnection(Endpoint endpoint) throws DataRetrievalException
{
-    	//TODO
-        String loginDN = endpoint.getProperty("loginDN");
-        String loginPW = endpoint.getProperty("loginPW");
         java.net.URI u;
 		try {
 			u = new java.net.URI(endpoint.getEndpointUrl());
 		} catch (URISyntaxException e) {
 			throw new DataRetrievalException("Invalid enpooint URI", e);
 		}
-        LdapNetworkConnection connection = new LdapNetworkConnection(u.getHost(), u.getPort()
> 0 ? u.getPort() : 389);
+		LdapConnectionConfig config = new LdapConnectionConfig();
+		config.setLdapHost(u.getHost());
+		config.setLdapPort(u.getPort() > 0 ? u.getPort() : 389);
+		if (endpoint.hasProperty("loginDN")) {
+			config.setName(endpoint.getProperty("loginDN"));
+		}
+		if (endpoint.hasProperty("loginPW")) {
+			config.setName(endpoint.getProperty("loginPW"));
+		}
+        LdapNetworkConnection connection = new LdapNetworkConnection(config);
         try {
 			connection.bind();
 		} catch (Exception e) {


Mime
View raw message