1 23 24 package discRack.presentation.personMgmt; 25 26 import discRack.spec.*; 27 import discRack.presentation.BasePO; 28 import discRack.presentation.DiscRackPresentationException; 29 30 import com.lutris.appserver.server.httpPresentation.*; 31 import com.lutris.appserver.server.session.*; 32 import com.lutris.util.*; 33 import org.w3c.dom.*; 36 import org.w3c.dom.html.*; 37 import org.enhydra.xml.xmlc.XMLObject; 38 39 45 public class Login extends BasePO { 46 47 50 private static String SUBMIT_NAME = "submit"; 51 private static String LOGIN_NAME = "login"; 52 private static String PASSWORD_NAME = "password"; 53 private static String ERROR_NAME = "ERROR_NAME"; 54 55 58 public boolean loggedInUserRequired() { 59 return false; 60 } 61 62 65 public XMLObject handleDefault() 66 throws HttpPresentationException { 67 return showPage(null); 68 } 69 70 76 public XMLObject handleLogin() 77 throws HttpPresentationException { 78 String login = this.getComms().request.getParameter(LOGIN_NAME); 79 String password = this.getComms().request.getParameter(PASSWORD_NAME); 80 81 82 Person user = null; 83 84 89 90 try { 91 92 user =((PersonGenerator)PersonGeneratorFactory.getPersonGenerator("discRack.business.person.PersonGeneratorImpl")).findPerson(login); 93 94 95 96 if(null == user || !user.getPassword().equals(password)) { 97 return showPage("Invalid username or password"); 98 } else { 100 this.setUser(user); 101 throw new ClientPageRedirectException(getComms().request.getApplicationPath()+DISC_CATALOG_PAGE); 102 } 103 }catch(NullPointerException ex){ 104 105 throw new ClientPageRedirectException(getComms().request.getApplicationPath()+DISC_CATALOG_PAGE); 106 107 } catch(DiscRackException ex) { 108 this.writeDebugMsg("System error finding user: " + ex.getMessage()); 109 throw new DiscRackPresentationException("System error finding user", ex); 110 } 111 } 112 113 119 public XMLObject handleLogout() 120 throws HttpPresentationException { 121 this.removeUserFromSession(); 122 return (ExitHTML)myComms.xmlcFactory.create(ExitHTML.class); 123 } 125 126 132 public XMLObject handleThrowException() 133 throws Exception { 134 throw new Exception ("This is a test exception thrown from Login.java handleThrowException()"); 135 } 136 137 143 public XMLObject showPage(String errorMsg) { 144 145 LoginHTML page = (LoginHTML)myComms.xmlcFactory.create(LoginHTML.class); 146 147 if(null != errorMsg || 148 null != (errorMsg = this.getSessionData().getAndClearUserMessage())) { 149 page.setTextErrorText(errorMsg); 150 } else { 151 page.getElementErrorText().getParentNode().removeChild(page.getElementErrorText()); 152 } 153 154 return page; 155 } 156 } 157 158 159 | Popular Tags |