1 19 20 package com.lutris.airsent.presentation.customer; 21 22 import com.lutris.airsent.presentation.BasePO; 23 import com.lutris.appserver.server.httpPresentation.*; 24 import com.lutris.appserver.server.session.*; 25 import com.lutris.util.*; 26 import org.w3c.dom.*; 29 import org.w3c.dom.html.*; 30 import org.enhydra.xml.xmlc.XMLObject; 31 import com.lutris.airsent.spec.AirSentException; 32 33 import com.lutris.airsent.presentation.AirSentPresentationException; 34 import com.lutris.airsent.presentation.AirSentConstants; 35 import java.util.*; 36 import com.lutris.airsent.spec.customer.Customer; 37 38 42 public class Login extends BasePO { 43 44 47 private static final int AUTH_LEVEL = AirSentConstants.UNAUTH_USER; 48 49 55 public int getRequiredAuthLevel() { 56 return AUTH_LEVEL; 57 } 58 59 62 public XMLObject handleDefault() throws HttpPresentationException { 63 return showPage(null); 64 } 65 66 71 public XMLObject showPage(String errorMsg) 72 throws AirSentPresentationException { 73 LoginHTML page = 74 (LoginHTML) myComms.xmlcFactory.create(LoginHTML.class); 75 76 try { 77 if (null != errorMsg 78 || null 79 != (errorMsg = 80 getSessionData().getAndClearUserMessage())) { 81 page.setTextErrorText(errorMsg); 82 } else { 83 page.getElementErrorText().getParentNode().removeChild(page.getElementErrorText()); 84 } 85 } catch (Exception e) { 86 throw new AirSentPresentationException("Trouble showing page", e); 87 } 88 89 return page; 90 } 91 92 97 public XMLObject handleLogin() throws HttpPresentationException { 98 String login = 99 getComms().request.getParameter(AirSentConstants.LOGIN_NAME); 100 String password = 101 getComms().request.getParameter(AirSentConstants.PASSWORD_NAME); 102 Customer customer = null; 103 104 try { 105 if ((customer = 106 getApplication().getHomeManager().getCustomerManager().validatePassword(login, 107 password)) == null) { 108 return showPage("Invalid username or password."); 109 } else { 110 getSessionData().setCustomer(customer); 111 getSessionData().setUserAuth(AirSentConstants.CUSTOMER_USER); 112 113 this.getSessionData().setUserMessage("Welcome, " + customer.getFirstName()); 114 throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO); 116 } 117 123 }catch(NullPointerException ex){ 124 throw new ClientPageRedirectException(AirSentConstants.ORDERSTEP1_PO); 125 126 127 } catch (Exception ex) { 128 throw new AirSentPresentationException("System error finding user", 129 ex); 130 } 131 } 132 133 } 134 135 | Popular Tags |