directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szoer...@apache.org
Subject svn commit: r777276 - /directory/sandbox/szoerner/apacheds-tomcatrealm/src/main/java/org/apache/directory/tomcatrealm/EmbeddedApacheDsRealm.java
Date Thu, 21 May 2009 21:46:19 GMT
Author: szoerner
Date: Thu May 21 21:46:18 2009
New Revision: 777276

URL: http://svn.apache.org/viewvc?rev=777276&view=rev
Log:
Comments improved, warnings removed

Modified:
    directory/sandbox/szoerner/apacheds-tomcatrealm/src/main/java/org/apache/directory/tomcatrealm/EmbeddedApacheDsRealm.java

Modified: directory/sandbox/szoerner/apacheds-tomcatrealm/src/main/java/org/apache/directory/tomcatrealm/EmbeddedApacheDsRealm.java
URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/apacheds-tomcatrealm/src/main/java/org/apache/directory/tomcatrealm/EmbeddedApacheDsRealm.java?rev=777276&r1=777275&r2=777276&view=diff
==============================================================================
--- directory/sandbox/szoerner/apacheds-tomcatrealm/src/main/java/org/apache/directory/tomcatrealm/EmbeddedApacheDsRealm.java
(original)
+++ directory/sandbox/szoerner/apacheds-tomcatrealm/src/main/java/org/apache/directory/tomcatrealm/EmbeddedApacheDsRealm.java
Thu May 21 21:46:18 2009
@@ -28,6 +28,8 @@
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.realm.RealmBase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
@@ -43,9 +45,6 @@
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 /**
  * An Apache Tomcat realm whichs embeds Apache Directory Server.
  * 
@@ -191,6 +190,13 @@
 				"Operation getPassword not supported by this realm");
 	}
 
+	/**
+	 * Perform a search to find a user entry.
+	 * 
+	 * @param username
+	 *            username, a unique id of the user
+	 * @return DN of the user entry, or null if not found
+	 */
 	protected LdapDN searchEntryByUsername(String username) {
 		LdapDN dn = null;
 
@@ -206,6 +212,7 @@
 					SearchScope.SUBTREE, filter,
 					AliasDerefMode.NEVER_DEREF_ALIASES, null, 0, 0);
 
+			@SuppressWarnings("unchecked")
 			CursorIterator iter = new CursorIterator(cursor);
 			if (iter.hasNext()) {
 				ServerEntry entry = (ServerEntry) iter.next();
@@ -223,10 +230,11 @@
 	protected boolean authenticate(LdapDN userDN, String credentials) {
 		boolean authenticated = false;
 		try {
-			directoryService.getSession(userDN, credentials.getBytes());
+			CoreSession session = directoryService.getSession(userDN, credentials.getBytes());
 			authenticated = true;
+			session.unbind();
 		} catch (Exception e) {
-			e.printStackTrace();
+			// ignored
 		}
 		return authenticated;
 	}
@@ -252,6 +260,7 @@
 					SearchScope.SUBTREE, filter,
 					AliasDerefMode.NEVER_DEREF_ALIASES, null, 0, 0);
 
+			@SuppressWarnings("unchecked")
 			CursorIterator iter = new CursorIterator(cursor);
 			while (iter.hasNext()) {
 				ServerEntry entry = (ServerEntry) iter.next();
@@ -281,7 +290,6 @@
 		ExprNode filter = FilterParser.parse(sFilter);
 
 		return filter;
-
 	}
 
 }



Mime
View raw message