package com.cv.spring.webflow;
import org.apache.log4j.Logger;
/**
* @author Chandra Vardhan
*/
public class LoginService {
private final static Logger LOGGER = Logger.getLogger(LoginService.class);
public String performLogin(User user) throws InvalidCredentialsException {
LOGGER.info("In LoginService.performLogin(-) method !!!");
if (user != null) {
String loginName = user.getLoginName();
String password = user.getPassword();
LOGGER.info("Entered credentials are, username = "+loginName + "and password = "+password);
if (loginName != null
&& loginName.trim().equalsIgnoreCase("Chandra")
&& password != null
&& password.trim().equalsIgnoreCase("password")) {
LOGGER.info("User successfully logged in, Credentials are correct!!!");
// user successfully logged in
return "success";
} else {
LOGGER.info("User failed logged in, Credentials are wrong!!!");
LOGGER.info("Enter credentials as, username = Chandra and password = password");
throw new InvalidCredentialsException();
}
} else {
throw new InvalidCredentialsException();
}
}
public String createNewAccount(User user) throws InvalidCredentialsException {
if (user != null) {
String loginName = user.getLoginName();
String password = user.getPassword();
LOGGER.info("Entered credentials are, username = "+loginName + "and password = "+password);
if (loginName != null
&& loginName.trim().equalsIgnoreCase("Chandra")
&& password != null
&& password.trim().equalsIgnoreCase("password")) {
// user successfully logged in
LOGGER.info("User successfully logged in, Credentials are correct!!!");
return "success";
} else {
LOGGER.info("User failed logged in, Credentials are wrong!!!");
LOGGER.info("Enter credentials as, username = Chandra and password = password");
throw new InvalidCredentialsException();
}
} else {
throw new InvalidCredentialsException();
}
}
} |
No comments:
Post a Comment