*/
public static boolean doLogin(String userName, String password, boolean rememberMe, HttpServletRequest request, HttpServletResponse response) throws NoSuchUserException {
try {
User user = null;
boolean match = false;
Company comp = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany();
if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
if(userName.equalsIgnoreCase(APILocator.getUserAPI().getSystemUser().getEmailAddress())){
SecurityLogger.logInfo(LoginFactory.class,"An invalid attempt to login with email as " + userName + " from IP: " + request.getRemoteAddr());
return false;
}
} else {
if(userName.equalsIgnoreCase(APILocator.getUserAPI().getSystemUser().getUserId())){
SecurityLogger.logInfo(LoginFactory.class,"An invalid attempt to login with userID as " + userName + " from IP: " + request.getRemoteAddr());
return false;
}
}
if ((PRE_AUTHENTICATOR != null) &&
(0 < PRE_AUTHENTICATOR.length()) &&
PRE_AUTHENTICATOR.equals(Config.getStringProperty("LDAP_FRONTEND_AUTH_IMPLEMENTATION"))) {
Class ldap_auth_impl_class = Class.forName(Config.getStringProperty("LDAP_FRONTEND_AUTH_IMPLEMENTATION"));
Authenticator ldap_auth_impl = (Authenticator) ldap_auth_impl_class.newInstance();
int auth = 0;
if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
auth = ldap_auth_impl.authenticateByEmailAddress(comp.getCompanyId(), userName, password);
} else {
auth = ldap_auth_impl.authenticateByUserId(comp.getCompanyId(), userName, password);
}
if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
user = APILocator.getUserAPI().loadByUserByEmail(userName, APILocator.getUserAPI().getSystemUser(), false);
} else {
user = APILocator.getUserAPI().loadUserById(userName, APILocator.getUserAPI().getSystemUser(), false);
}
try{
boolean SYNC_PASSWORD = BaseAuthenticator.SYNC_PASSWORD;
if(!SYNC_PASSWORD){
String roleName = LDAPImpl.LDAP_USER_ROLE;
if(com.dotmarketing.business.APILocator.getRoleAPI().doesUserHaveRole(user, roleName)){
user.setPassword(DotCustomLoginPostAction.FAKE_PASSWORD);
APILocator.getUserAPI().save(user,APILocator.getUserAPI().getSystemUser(),false);
}
}
}catch (Exception e) {
Logger.debug(LoginFactory.class, "syncPassword not set or unable to load user", e);
}
match = auth == Authenticator.SUCCESS;
} else {
if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
user = APILocator.getUserAPI().loadByUserByEmail(userName, APILocator.getUserAPI().getSystemUser(), false);
} else {
user = APILocator.getUserAPI().loadUserById(userName, APILocator.getUserAPI().getSystemUser(), false);
}