Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r176 - in trunk: java/ch/idok/common/config java/ch/idok/qtgui sites/psi/java/ch/psi/idok/common/config

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r176 - in trunk: java/ch/idok/common/config java/ch/idok/qtgui sites/psi/java/ch/psi/idok/common/config


Chronological Thread 
  • From: "Apache" <apache AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r176 - in trunk: java/ch/idok/common/config java/ch/idok/qtgui sites/psi/java/ch/psi/idok/common/config
  • Date: Thu, 14 Aug 2008 16:27:50 +0200
  • List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
  • List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>

Author: huebner AT PSI.CH
Date: Thu Aug 14 16:27:50 2008
New Revision: 176

Log:
Added LDAP support for the open source client and an example configuration
for the Apache Directory Server

Added:
trunk/java/ch/idok/common/config/idok.conf
trunk/sites/psi/java/ch/psi/idok/common/config/idok.conf
- copied, changed from r167,
/trunk/sites/psi/java/ch/psi/idok/common/config/ldap.conf
Removed:
trunk/sites/psi/java/ch/psi/idok/common/config/ldap.conf
Modified:
trunk/java/ch/idok/common/config/Setup.java
trunk/java/ch/idok/qtgui/Ldap.java
trunk/java/ch/idok/qtgui/RepositoryController.java
trunk/sites/psi/java/ch/psi/idok/common/config/Setup.java

Modified: trunk/java/ch/idok/common/config/Setup.java
==============================================================================
--- trunk/java/ch/idok/common/config/Setup.java (original)
+++ trunk/java/ch/idok/common/config/Setup.java Thu Aug 14 16:27:50 2008
@@ -258,6 +258,7 @@
protected void init() throws DmsException {
try {
setupJAAS();
+ setupLDAP();
} catch (Exception e) {
throw new DmsException(ErrorType.INTERNAL, null,
"Error during setup", "");
@@ -279,6 +280,22 @@
.getAbsolutePath());
}

+
+ /**
+ * Generic LDAP setup
+ *
+ * @throws Exception
+ */
+ protected void setupLDAP() throws Exception {
+ Class<Setup> c = Setup.class;
+ File ldapConfFile;
+ ldapConfFile = copyToTemp(c.getResourceAsStream("idok.conf"));
+ ldapConfFile.deleteOnExit();
+ rootLogger_.finest(ldapConfFile.getAbsolutePath());
+ System.setProperty("idok.config", ldapConfFile
+ .getAbsolutePath());
+ }
+
/**
* Generic logging setup for iDok clients
*

Added: trunk/java/ch/idok/common/config/idok.conf
==============================================================================
--- (empty file)
+++ trunk/java/ch/idok/common/config/idok.conf Thu Aug 14 16:27:50 2008
@@ -0,0 +1,21 @@
+# *** startup configuration: ***
+BASE_PROTOCOL=http
+
+
+# *** LDAP configuration: ***
+#LDAP host
+LDAP_HOST=idokserver:10389
+LDAP_ROOT_CONTEXT=
+LDAP_CONNECTION_TYPE=ldap
+
+#LDAP user
+LDAP_USER_NAME=uid=admin,ou=system
+LDAP_USER_NAME_SUFFIX=
+LDAP_USER_PASSWORD=secret
+LDAP_USER_PASSWORDFILE=
+
+#LDAP Query
+LDAP_GROUP=ou=crews,ou=groups,o=sevenSeas
+LDAP_USER=ou=people,o=sevenSeas
+LDAP_GROUP_MEMBER_DESCRIPTOR=uniquemember
+

Modified: trunk/java/ch/idok/qtgui/Ldap.java
==============================================================================
--- trunk/java/ch/idok/qtgui/Ldap.java (original)
+++ trunk/java/ch/idok/qtgui/Ldap.java Thu Aug 14 16:27:50 2008
@@ -49,7 +49,7 @@

try {
configFile = new Properties();
- String configFileLocation =
System.getProperty("idok.ldap.config");
+ String configFileLocation = System.getProperty("idok.config");
FileInputStream fileStream = new
FileInputStream(configFileLocation);
configFile.load(fileStream);
fileStream.close();
@@ -59,6 +59,30 @@


}
+
+ private static String getkey(){
+ String pass = new String();
+ FileReader keyfile = null;
+ try {
+ String keyLocation =
configFile.getProperty("LDAP_USER_PASSWORDFILE");
+ if (!keyLocation.equals("")) {
+ keyfile = new FileReader(keyLocation);
+ for ( int c; ( c = keyfile.read() ) != -1; )
+ pass += (char)c;
+ }
+ else{
+ return "";
+ }
+
+ }
+ catch (IOException e) {
+ System.err.println( "Error reading file!" );
+ }
+ finally {
+ try {keyfile.close();} catch (Exception e) {}
+ }
+ return pass;
+ }


private static NamingEnumeration<SearchResult> search(String
searchBase,String searchFilter,String[] returningattribute){
@@ -89,18 +113,24 @@

private static NamingEnumeration<SearchResult>
simpleAuth(Krb5DmsCredentials cred, Properties env,String searchBase,String
searchFilter,String[] returningattribute){

- String loginDN = null;
- String password = null;
- if ((cred != null)&& (cred.getUsername() !=
null)&&(cred.getPassword() != null) ) {
- loginDN = cred.getUsername();
- password = String.valueOf(cred.getPassword());
- }else{
- return null;
+ String loginDN = configFile.getProperty("LDAP_USER_NAME");
+ String password = configFile.getProperty("LDAP_USER_PASSWORD");
+
+ if ((loginDN==null) || loginDN.equals("")) {
+ if ((cred != null) && (cred.getUsername() != null)
+ && (cred.getPassword() != null)) {
+ loginDN = cred.getUsername();
+ password = String.valueOf(cred.getPassword());
+ } else {
+ return null;
+ }
+ }else if (password.equals("")) {
+ password = getkey();
+ if (password.equals("")) {
+ return null;
+ }
}

-// String loginDN = "dmsadmin";
-// String password = getkey();
-
env.put( Context.SECURITY_PRINCIPAL, loginDN +
configFile.getProperty("LDAP_USER_NAME_SUFFIX"));
env.put( Context.SECURITY_CREDENTIALS, password );

@@ -158,14 +188,14 @@
while (ae.hasMore()) {
Attribute attr = (Attribute) ae.nextElement();
if (attr.getID() != null
- && attr.getID().equals("member")) {
+ &&
attr.getID().equals(configFile.getProperty("LDAP_GROUP_MEMBER_DESCRIPTOR"))) {
NamingEnumeration a = attr.getAll();
while (a.hasMoreElements()) {
String elem = (String) a.nextElement();
//
System.out.println(elem);
- if
(elem.split(",")[1].contains("OU=Users")) {
- nameList.add(elem.split(",")[0]
- .substring(3));
+ //"OU=Users"
+ if
(elem.split(",")[1].contains(configFile.getProperty("LDAP_USER").split(",")[0]))
{
+
nameList.add(elem.split(",")[0].substring(3));
}
}
}

Modified: trunk/java/ch/idok/qtgui/RepositoryController.java
==============================================================================
--- trunk/java/ch/idok/qtgui/RepositoryController.java (original)
+++ trunk/java/ch/idok/qtgui/RepositoryController.java Thu Aug 14 16:27:50
2008
@@ -19,12 +19,15 @@

package ch.idok.qtgui;

+import java.io.FileInputStream;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;

import ch.idok.common.errorhandling.DmsException;
import ch.idok.common.impl.repository.svn.SvnRepositoryManager;
@@ -273,9 +276,22 @@
}
}
Collections.sort(rList);
+
+ Properties configFile = new Properties();
+ try {
+
+ String configFileLocation =
System.getProperty("idok.config");
+ FileInputStream fileStream = new
FileInputStream(configFileLocation);
+ configFile.load(fileStream);
+ fileStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ String connectionType = configFile.getProperty("BASE_PROTOCOL");
+
for (Iterator iterator = rList.iterator(); iterator.hasNext();) {
String entry = (String) iterator.next();
- ui_.urlComboBox.insertItem(i, "https://"+location+"/"+entry);
+ ui_.urlComboBox.insertItem(i,
connectionType+"://"+location+"/"+entry);
i++;
}


Modified: trunk/sites/psi/java/ch/psi/idok/common/config/Setup.java
==============================================================================
--- trunk/sites/psi/java/ch/psi/idok/common/config/Setup.java (original)
+++ trunk/sites/psi/java/ch/psi/idok/common/config/Setup.java Thu Aug 14
16:27:50 2008
@@ -59,10 +59,10 @@
protected void setupLDAP() throws Exception {
Class<Setup> c = Setup.class;
File ldapConfFile;
- ldapConfFile = copyToTemp(c.getResourceAsStream("ldap.conf"));
+ ldapConfFile = copyToTemp(c.getResourceAsStream("idok.conf"));
ldapConfFile.deleteOnExit();
rootLogger_.finest(ldapConfFile.getAbsolutePath());
- System.setProperty("idok.ldap.config", ldapConfFile
+ System.setProperty("idok.config", ldapConfFile
.getAbsolutePath());
}


Copied: trunk/sites/psi/java/ch/psi/idok/common/config/idok.conf (from r167,
/trunk/sites/psi/java/ch/psi/idok/common/config/ldap.conf)
==============================================================================
--- /trunk/sites/psi/java/ch/psi/idok/common/config/ldap.conf (original)
+++ trunk/sites/psi/java/ch/psi/idok/common/config/idok.conf Thu Aug 14
16:27:50 2008
@@ -1,14 +1,21 @@
-# LDAP configuration file
+# *** startup configuration: ***
+BASE_PROTOCOL=https

+
+# *** LDAP configuration: ***
#LDAP host
LDAP_HOST=d.psi.ch
LDAP_ROOT_CONTEXT=
LDAP_CONNECTION_TYPE=ldaps

#LDAP user
+LDAP_USER_NAME=
LDAP_USER_NAME_SUFFIX= AT D.PSI.CH
+LDAP_USER_PASSWORD=
+LDAP_USER_PASSWORDFILE=

#LDAP Query
LDAP_GROUP=OU=Groups,OU=PSI,DC=d,DC=psi,DC=ch
-LDPA_USER=OU=Users,OU=PSI,DC=d,DC=psi,DC=ch
+LDAP_USER=OU=Users,OU=PSI,DC=d,DC=psi,DC=ch
+LDAP_GROUP_MEMBER_DESCRIPTOR=member




  • [idok-commit] idok commit r176 - in trunk: java/ch/idok/common/config java/ch/idok/qtgui sites/psi/java/ch/psi/idok/common/config, Apache, 08/14/2008

Archive powered by MHonArc 2.6.19.

Top of Page