Revision 1494
Added by Jing Tao almost 22 years ago
src/edu/ucsb/nceas/metacat/AuthLdap.java | ||
---|---|---|
117 | 117 |
if (identifier.startsWith("ldap")) { |
118 | 118 |
refUrl = identifier.substring(0, |
119 | 119 |
identifier.lastIndexOf("/")+1); |
120 |
MetaCatUtil.debugMessage("Ref ldapUrl: " + refUrl); |
|
120 |
MetaCatUtil.debugMessage("Ref ldapUrl: " + refUrl, 35);
|
|
121 | 121 |
int position = identifier.indexOf(","); |
122 | 122 |
int position2 = identifier.indexOf(",", position+1); |
123 | 123 |
refBase = identifier.substring(position2+1); |
124 |
MetaCatUtil.debugMessage("Ref ldapBase: " + refBase); |
|
124 |
MetaCatUtil.debugMessage("Ref ldapBase: " + refBase, 35);
|
|
125 | 125 |
identifier = identifier.substring( |
126 | 126 |
identifier.lastIndexOf("/")+1); |
127 | 127 |
MetaCatUtil.debugMessage("Trying: " + identifier, 35); |
... | ... | |
129 | 129 |
refUrl, refBase); |
130 | 130 |
} else { |
131 | 131 |
identifier = identifier+","+ldapBase; |
132 |
MetaCatUtil.debugMessage("Trying: " + identifier); |
|
132 |
MetaCatUtil.debugMessage("Trying: " + identifier, 35);
|
|
133 | 133 |
authenticated = ldapAuthenticate(identifier, password); |
134 | 134 |
} |
135 | 135 |
//authenticated = ldapAuthenticate(identifier, password); |
... | ... | |
209 | 209 |
ctx = new InitialDirContext(env); |
210 | 210 |
double stopTime = System.currentTimeMillis(); |
211 | 211 |
util.debugMessage("Connection time thru " + ldapsUrl + " was: " + |
212 |
(stopTime-startTime)/1000 + " seconds."); |
|
212 |
(stopTime-startTime)/1000 + " seconds.", 35);
|
|
213 | 213 |
authenticated = true; |
214 | 214 |
//tls.close(); |
215 | 215 |
ctx.close(); |
... | ... | |
241 | 241 |
t.start(); |
242 | 242 |
Thread.sleep(5000); //this is a manual override of ldap's |
243 | 243 |
//hideously long time out period. |
244 |
util.debugMessage("Awake after 5 seconds."); |
|
244 |
util.debugMessage("Awake after 5 seconds.", 35);
|
|
245 | 245 |
if (referralContext == null) |
246 | 246 |
{ |
247 | 247 |
t.interrupt(); |
... | ... | |
589 | 589 |
NamingEnumeration enum = ctx.search(ldapBase, filter, ctls); |
590 | 590 |
|
591 | 591 |
// Print the groups |
592 |
MetaCatUtil.debugMessage("getting group results."); |
|
592 |
MetaCatUtil.debugMessage("getting group results.", 50);
|
|
593 | 593 |
while (enum.hasMore()) { |
594 | 594 |
SearchResult sr = (SearchResult)enum.next(); |
595 | 595 |
uvec.add(sr.getName()+","+ldapBase); |
... | ... | |
604 | 604 |
{ |
605 | 605 |
refExc = re; |
606 | 606 |
Thread t = new Thread(new GetGroup()); |
607 |
util.debugMessage("Starting thread..."); |
|
607 |
util.debugMessage("Starting thread...", 50);
|
|
608 | 608 |
t.start(); |
609 |
util.debugMessage("sleeping for 5 seconds."); |
|
609 |
util.debugMessage("sleeping for 5 seconds.", 50);
|
|
610 | 610 |
try |
611 | 611 |
{ |
612 | 612 |
Thread.sleep(5000); |
... | ... | |
617 | 617 |
} |
618 | 618 |
//this is a manual override of jndi's hideously long time |
619 | 619 |
//out period. |
620 |
util.debugMessage("Awake after 5 seconds."); |
|
620 |
util.debugMessage("Awake after 5 seconds.", 40);
|
|
621 | 621 |
if (referralContext == null) |
622 | 622 |
{ |
623 | 623 |
util.debugMessage("thread timed out...returning groups: " + uvec.toString(), 35); |
... | ... | |
979 | 979 |
|
980 | 980 |
// get all users |
981 | 981 |
if (isValid) { |
982 |
MetaCatUtil.debugMessage("\nGetting all users ...."); |
|
982 |
MetaCatUtil.debugMessage("\nGetting all users ....", 20);
|
|
983 | 983 |
String[] users = authservice.getUsers(user, password); |
984 |
MetaCatUtil.debugMessage("Users found: " + users.length); |
|
984 |
MetaCatUtil.debugMessage("Users found: " + users.length, 20);
|
|
985 | 985 |
|
986 | 986 |
} |
987 | 987 |
|
988 | 988 |
// get the whole list groups and users in XML format |
989 | 989 |
if (isValid) { |
990 |
MetaCatUtil.debugMessage("\nTrying principals...."); |
|
990 |
MetaCatUtil.debugMessage("\nTrying principals....", 20);
|
|
991 | 991 |
authservice = new AuthLdap(); |
992 | 992 |
String out = authservice.getPrincipals(user, password); |
993 | 993 |
java.io.File f = new java.io.File("principals.xml"); |
... | ... | |
997 | 997 |
buff.flush(); |
998 | 998 |
buff.close(); |
999 | 999 |
fw.close(); |
1000 |
MetaCatUtil.debugMessage("\nFinished getting principals."); |
|
1000 |
MetaCatUtil.debugMessage("\nFinished getting principals.", 20);
|
|
1001 | 1001 |
} |
1002 | 1002 |
|
1003 | 1003 |
} catch (ConnectException ce) { |
1004 |
MetaCatUtil.debugMessage(ce.getMessage()); |
|
1004 |
MetaCatUtil.debugMessage(ce.getMessage(), 30);
|
|
1005 | 1005 |
} catch (java.io.IOException ioe) { |
1006 |
MetaCatUtil.debugMessage("I/O Error writing to file principals.txt"); |
|
1006 |
MetaCatUtil.debugMessage("I/O Error writing to file principals.txt", 20);
|
|
1007 | 1007 |
} |
1008 | 1008 |
} |
1009 | 1009 |
|
... | ... | |
1059 | 1059 |
catch (AuthenticationException ae) |
1060 | 1060 |
{ |
1061 | 1061 |
util.debugMessage("Error running referral handler thread: " + |
1062 |
ae.getMessage()); |
|
1062 |
ae.getMessage(), 20);
|
|
1063 | 1063 |
//check if has another referral |
1064 | 1064 |
moreReferrals=refExc.skipReferral(); |
1065 | 1065 |
//don't get the context |
... | ... | |
1069 | 1069 |
catch (NamingException ne) |
1070 | 1070 |
{ |
1071 | 1071 |
util.debugMessage("Error running referral handler thread: " + |
1072 |
ne.getMessage()); |
|
1072 |
ne.getMessage(), 20);
|
|
1073 | 1073 |
//check if has another referral |
1074 | 1074 |
moreReferrals=refExc.skipReferral(); |
1075 | 1075 |
//don't get context |
... | ... | |
1083 | 1083 |
public void run() |
1084 | 1084 |
{ |
1085 | 1085 |
referralContext = null; |
1086 |
MetaCatUtil.debug("getting groups context");
|
|
1086 |
MetaCatUtil.debugMessage("getting groups context", 50);
|
|
1087 | 1087 |
DirContext refDirContext=null; |
1088 | 1088 |
boolean moreReferrals=true; |
1089 | 1089 |
//set a while loop is because we don't know if a referral excption |
... | ... | |
1097 | 1097 |
refInfo = (String)refExc.getReferralInfo(); |
1098 | 1098 |
if(refInfo != null) |
1099 | 1099 |
{ |
1100 |
MetaCatUtil.debug("Referral in thread to: " + |
|
1101 |
refInfo.toString()); |
|
1100 |
MetaCatUtil.debugMessage("Referral in thread to: " +
|
|
1101 |
refInfo.toString(), 40);
|
|
1102 | 1102 |
} |
1103 | 1103 |
else |
1104 | 1104 |
{ |
1105 |
MetaCatUtil.debug("getting refInfo Manually");
|
|
1105 |
MetaCatUtil.debugMessage("getting refInfo Manually", 50);
|
|
1106 | 1106 |
refInfo = (String)refExc.getReferralContext().getEnvironment(). |
1107 | 1107 |
get(Context.PROVIDER_URL); |
1108 | 1108 |
} |
1109 |
MetaCatUtil.debug("refInfo: " + refInfo);
|
|
1109 |
MetaCatUtil.debugMessage("refInfo: " + refInfo, 40);
|
|
1110 | 1110 |
|
1111 | 1111 |
env.put(Context.INITIAL_CONTEXT_FACTORY, |
1112 | 1112 |
"com.sun.jndi.ldap.LdapCtxFactory"); |
1113 | 1113 |
env.put(Context.REFERRAL, "throw"); |
1114 | 1114 |
env.put(Context.PROVIDER_URL, refInfo); |
1115 | 1115 |
|
1116 |
MetaCatUtil.debug("creating referralContext");
|
|
1116 |
MetaCatUtil.debugMessage("creating referralContext", 40);
|
|
1117 | 1117 |
referralContext = new InitialDirContext(env); |
1118 |
MetaCatUtil.debug("referralContext created");
|
|
1118 |
MetaCatUtil.debugMessage("referralContext created", 40);
|
|
1119 | 1119 |
//get context and jump out the while loop |
1120 | 1120 |
moreReferrals=false; |
1121 | 1121 |
}//try |
... | ... | |
1129 | 1129 |
catch (AuthenticationException ae) |
1130 | 1130 |
{ |
1131 | 1131 |
util.debugMessage("Error running referral handler thread: " + |
1132 |
ae.getMessage()); |
|
1132 |
ae.getMessage(), 50);
|
|
1133 | 1133 |
//check if has another referral |
1134 | 1134 |
moreReferrals=refExc.skipReferral(); |
1135 | 1135 |
//don't get the context |
... | ... | |
1138 | 1138 |
catch (NamingException ne) |
1139 | 1139 |
{ |
1140 | 1140 |
util.debugMessage("Error running referral handler thread: " + |
1141 |
ne.getMessage()); |
|
1141 |
ne.getMessage(), 50);
|
|
1142 | 1142 |
//check if has another referral |
1143 | 1143 |
moreReferrals=refExc.skipReferral(); |
1144 | 1144 |
//don't get context |
Also available in: Unified diff
Change the debugMessage from (string) to (string int)