Project

General

Profile

« Previous | Next » 

Revision 3023

Added by sgarg over 18 years ago

Cleaned up the code with proper debug statements..

View differences:

src/edu/ucsb/nceas/metacat/AuthLdap.java
121 121
    	// Check the usename as passed in
122 122
        logMetacat.info("Calling ldapAuthenticate");
123 123
        logMetacat.info("with user as identifier: " + identifier);
124
        logMetacat.info("and password as: " + password);
125 124

  
126 125
        authenticated = ldapAuthenticate(identifier, password, 
127 126
        		(new Boolean(MetaCatUtil.getOption("onlySecureLDAPConnection"))).booleanValue());
......
131 130
        	logMetacat.info("Looking up DN for: " + identifier);
132 131
        	identifier = getIdentifyingName(identifier, ldapUrl, ldapBase);
133 132
        	if(identifier == null){
134
        		logMetacat.warn("No DN found from getIdentifyingName");
133
        		logMetacat.info("No DN found from getIdentifyingName");
135 134
        		return authenticated;
136 135
        	}
137 136
        	
......
145 144
        		logMetacat.debug("identifier starts with ldap");
146 145

  
147 146
        		refUrl = identifier.substring(0, identifier.lastIndexOf("/") + 1);
148
        		logMetacat.info("Ref ldapUrl: " + refUrl);
149 147
        		int position = identifier.indexOf(",");
150 148
        		int position2 = identifier.indexOf(",", position + 1);
149
        		
151 150
        		refBase = identifier.substring(position2 + 1);
152
        		logMetacat.info("Ref ldapBase: " + refBase);
153 151
        		identifier = identifier.substring(identifier.lastIndexOf("/") + 1);
154
        		logMetacat.info("Trying: " + identifier);
152
        		
155 153
        		logMetacat.info("Calling ldapAuthenticate");
156 154
        		logMetacat.info("with user as identifier: " + identifier);
157
        		logMetacat.info("and password as: " + password);
158 155
        		logMetacat.info("and refUrl as: " + refUrl);
159 156
        		logMetacat.info("and refBase as: " + refBase);
160 157

  
......
163 160
                			.booleanValue());
164 161
        	} else {
165 162
        		logMetacat.info("identifier doesnt start with ldap");
163
        		identifier = identifier + "," + ldapBase;
164
        		
166 165
        		logMetacat.info("Calling ldapAuthenticate");
167 166
        		logMetacat.info("with user as identifier: " + identifier);
168
        		logMetacat.info("and password as: " + password);
169

  
170
        		identifier = identifier + "," + ldapBase;
171
        		logMetacat.info("Trying: " + identifier);
167
        		
172 168
        		authenticated = ldapAuthenticate(identifier, password,
173 169
            		(new Boolean(MetaCatUtil.getOption("onlySecureLDAPConnection"))).booleanValue());
174 170
        	}
175 171
        }
176 172
    }
177 173
    catch (NullPointerException e) {
178
    	logMetacat.error("NullPointerException b' password is null");
179 174
    	logMetacat.error("NullPointerException while authenticating in " +
180 175
                        "AuthLdap.authenticate: " + e);
181 176
    	e.printStackTrace();
......
221 216
	  
222 217
	  boolean authenticated = false;
223 218
		
224
	  logMetacat.warn(secureConnectionOnly + "");
225 219
	  String server = "";
226 220
	  String userDN = "";
227 221
	  logMetacat.info("dn is: " + dn);
......
282 276
	                                 + ioe.getMessage());
283 277
			   
284 278
			   if(secureConnectionOnly){
285
			   	  return authenticated;
279
			   	  
280
				   return authenticated;
281
			   
286 282
			   } else {
287
				
283

  
284
				   logMetacat.info("Trying to authenticate without TLS");
288 285
				   env.put(Context.SECURITY_AUTHENTICATION, "simple");
289 286
				   env.put(Context.SECURITY_PRINCIPAL, userDN);
290 287
				   env.put(Context.SECURITY_CREDENTIALS, password);
......
305 302
	   } catch (NamingException e) {
306 303
		   logMetacat.warn("Caught NamingException in login: " + e.getClass().getName());
307 304
		   logMetacat.info(e.toString() + "  " + e.getRootCause());
308
		   e.printStackTrace();
309 305
       }
310 306

  
311 307
       return authenticated;
......
333 329
      try {
334 330
    	  int position = user.indexOf(",");
335 331
          String uid = user.substring(user.indexOf("=") + 1, position);
336
          logMetacat.warn("uid is: " + uid);
332
          logMetacat.info("uid is: " + uid);
337 333
          String org = user.substring(user.indexOf("=", position + 1) + 1,
338 334
                                        user.indexOf(",", position + 1));
339
          logMetacat.warn("org is: " + org);
335
          logMetacat.info("org is: " + org);
340 336
           
341 337
          DirContext sctx = new InitialDirContext(env);
342 338
          SearchControls ctls = new SearchControls();
343 339
          ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
344 340
          String filter = "(&(uid=" + uid + ")(o=" + org + "))";
345
          logMetacat.warn("Filter: " + filter);
341
          logMetacat.warn("Searching for DNs with following filter: " + filter);
346 342
          
347 343
          for (boolean moreReferrals = true; moreReferrals;) {
348 344
              try {
......
360 356
                  moreReferrals = false;
361 357
              } catch (ReferralException e) {
362 358
            	  logMetacat.info("Got referral: " + e.getReferralInfo());
363

  
364
                  // Point to the new context from the referral
359
            	  // Point to the new context from the referral
365 360
                  if (moreReferrals) {
366 361
                      sctx = (DirContext) e.getReferralContext();
367 362
                  }

Also available in: Unified diff