1 package com.mvnforum.auth.ldap; 2 3 import net.myvietnam.mvncore.exception.DatabaseException; 4 import net.myvietnam.mvncore.exception.ObjectNotFoundException; 5 import net.myvietnam.mvncore.util.StringUtil; 6 import net.myvietnam.mvncore.web.GenericRequest; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 import com.mvnforum.auth.AbstractSampleAuthenticator; 12 import com.mvnforum.db.DAOFactory; 13 14 public class SampleLDAPAuthenticator extends AbstractSampleAuthenticator { 15 16 private static Log log = LogFactory.getLog(SampleLDAPAuthenticator.class); 17 18 public String getRemoteUser(GenericRequest request) { 19 String memberName = (String )request.getSessionAttribute("UserName"); 20 memberName = StringUtil.getEmptyStringIfNull(memberName); 21 log.debug("Member Name is " + memberName); 22 if (memberName.length() > 0) { 23 try { 24 DAOFactory.getMemberDAO().findByAlternateKey_MemberName(memberName); 25 } catch (ObjectNotFoundException onfe) { 26 try { 28 createAccount(memberName, request); 29 } catch (Exception e) { 30 log.error("Error is :" + e); 32 return null; 33 } 34 } catch (DatabaseException de) { 35 log.error("Error is :" + de); 37 } 38 } 39 return memberName; 40 } 41 } | Popular Tags |