Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r168 - trunk/java/ch/idok/qtgui

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r168 - trunk/java/ch/idok/qtgui


Chronological Thread 
  • From: "Apache" <apache AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r168 - trunk/java/ch/idok/qtgui
  • Date: Mon, 11 Aug 2008 12:29:33 +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: Mon Aug 11 12:29:33 2008
New Revision: 168

Log:
Made the reason for an additional login for the Administration clearer and
removed an exception if no user name and password was given.

Modified:
trunk/java/ch/idok/qtgui/AuthorizationController.java
trunk/java/ch/idok/qtgui/Ldap.java

Modified: trunk/java/ch/idok/qtgui/AuthorizationController.java
==============================================================================
--- trunk/java/ch/idok/qtgui/AuthorizationController.java (original)
+++ trunk/java/ch/idok/qtgui/AuthorizationController.java Mon Aug 11
12:29:33 2008
@@ -342,7 +342,7 @@
Ui_PasswordDialog ui = new Ui_PasswordDialog();
ui.setupUi(d);
ui.passwordLineEdit.setEchoMode(QLineEdit.EchoMode.Password);
- ui.headLineLabel.setText("Enter user name and password");
+ ui.headLineLabel.setText("For LDAP assistance please enter user
name and password");
ui.logoLabel.setPixmap(new QPixmap(
"classpath:ch/idok/qtgui/images/folder_documents.png"));
ui.nameLineEdit.setFocus();

Modified: trunk/java/ch/idok/qtgui/Ldap.java
==============================================================================
--- trunk/java/ch/idok/qtgui/Ldap.java (original)
+++ trunk/java/ch/idok/qtgui/Ldap.java Mon Aug 11 12:29:33 2008
@@ -79,6 +79,7 @@
// if (subject != null) {
// list = kerbAuth(subject,env, searchBase, searchFilter,
returningattribute);
// }else{
+
list = simpleAuth(krb5cred,env, searchBase, searchFilter,
returningattribute);
// }
return list;
@@ -88,8 +89,14 @@

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

- String loginDN = cred.getUsername();
- String password = String.valueOf(cred.getPassword());
+ 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 = "dmsadmin";
// String password = getkey();
@@ -140,30 +147,36 @@
String[] returningattribute = {"*"};
ArrayList<String> nameList = new ArrayList<String>();
NamingEnumeration<SearchResult> results =
search(configFile.getProperty("LDAP_GROUP"), "CN="+group,returningattribute);
- try {
- while (results.hasMoreElements()) {
- SearchResult sr = (SearchResult) results.next();
- Attributes attrs = sr.getAttributes();
- if (attrs != null) {
- NamingEnumeration<? extends Attribute> ae =
attrs.getAll();
- while (ae.hasMore()) {
- Attribute attr = (Attribute) ae.nextElement();
- if (attr.getID() != null &&
attr.getID().equals("member")) {
- NamingEnumeration a = attr.getAll();
- while (a.hasMoreElements()) {
+ if (results != null) {
+ try {
+ while (results.hasMoreElements()) {
+ SearchResult sr = (SearchResult) results.next();
+ Attributes attrs = sr.getAttributes();
+ if (attrs != null) {
+ NamingEnumeration<? extends Attribute> ae = attrs
+ .getAll();
+ while (ae.hasMore()) {
+ Attribute attr = (Attribute) ae.nextElement();
+ if (attr.getID() != null
+ && attr.getID().equals("member")) {
+ NamingEnumeration a = attr.getAll();
+ while (a.hasMoreElements()) {
String elem = (String) a.nextElement();
-// System.out.println(elem);
+ //
System.out.println(elem);
if
(elem.split(",")[1].contains("OU=Users")) {
-
nameList.add(elem.split(",")[0].substring(3));
}
+ nameList.add(elem.split(",")[0]
+ .substring(3));
+ }
}
- }
- }
- }
- }
-
- }catch(NamingException e){
- System.out.println("Error: " + e.toString());
- }
+ }
+ }
+ }
+ }
+
+ } catch (NamingException e) {
+ System.out.println("Error: " + e.toString());
+ }
+ }
return nameList;
}

@@ -216,19 +229,22 @@
ArrayList<String> groupList = new ArrayList<String>();
NamingEnumeration<SearchResult> results =
search(configFile.getProperty("LDAP_GROUP"),"CN=*",returningattribute);

- try {
- while (results.hasMore()){
- NameClassPair nextEntry = null;
- nextEntry = (NameClassPair)results.next();
- if (nextEntry.toString().split(":")[1].contains(" null")) {
-
groupList.add(nextEntry.toString().split(":")[0].substring(3));
- }
- }
- }catch(NamingException e){
- System.out.println("Error: " + e.toString());
+ if (results != null) {
+ try {
+ while (results.hasMore()) {
+ NameClassPair nextEntry = null;
+ nextEntry = (NameClassPair) results.next();
+ if (nextEntry.toString().split(":")[1].contains(" null")) {
+ groupList.add(nextEntry.toString().split(":")[0]
+ .substring(3));
+ }
+ }
+ } catch (NamingException e) {
+ System.out.println("Error: " + e.toString());
// Exception is thrown, go for next entry
- }
- return groupList;
+ }
+ }
+ return groupList;
}

public static ArrayList<String> getMembers(String nameStartsWith){
@@ -236,18 +252,21 @@
ArrayList<String> memberList = new ArrayList<String>();
NamingEnumeration<SearchResult> results =
search(configFile.getProperty("LDAP_USER"),
"CN="+nameStartsWith+"*",returningattribute);

- // Go through each item in list
- try {
- while (results.hasMore()){
- NameClassPair nextEntry = null;
- nextEntry = (NameClassPair)results.next();
- if (nextEntry.toString().split(":")[1].contains(" null")) {
-
memberList.add(nextEntry.getName().toString().split(",")[0].substring(3));
+ if (results != null) {
+ // Go through each item in list
+ try {
+ while (results.hasMore()) {
+ NameClassPair nextEntry = null;
+ nextEntry = (NameClassPair) results.next();
+ if (nextEntry.toString().split(":")[1].contains("
null")) {
+ memberList.add(nextEntry.getName().toString()
+ .split(",")[0].substring(3));
+ }
+ // System.out.println(nextEntry);
}
-// System.out.println(nextEntry);
+ } catch (NamingException e) {
+ e.printStackTrace();
}
- } catch (NamingException e) {
- e.printStackTrace();
}
return memberList;
}



  • [idok-commit] idok commit r168 - trunk/java/ch/idok/qtgui, Apache, 08/11/2008

Archive powered by MHonArc 2.6.19.

Top of Page