1 19 20 package com.lutris.airsent.presentation.messenger; 21 22 import com.lutris.appserver.server.httpPresentation.*; 23 import com.lutris.appserver.server.session.*; 24 import com.lutris.util.*; 25 import org.enhydra.xml.xmlc.XMLCUtil; 27 import org.w3c.dom.*; 28 import org.enhydra.xml.xmlc.XMLObject; 29 import java.util.Date ; 30 import com.lutris.airsent.presentation.AirSentPresentationException; 31 import com.lutris.airsent.presentation.AirSentConstants; 32 import com.lutris.airsent.presentation.DeviceBasePO; 33 import com.lutris.airsent.presentation.DeviceUtils; 34 import com.lutris.airsent.spec.messenger.Messenger; 35 import java.lang.reflect.Method ; 36 37 44 public class MessengerLogin extends DeviceBasePO { 45 46 49 private static final int AUTH_LEVEL = AirSentConstants.UNAUTH_USER; 50 51 57 public int getRequiredAuthLevel() { 58 return AUTH_LEVEL; 59 } 60 61 67 public XMLObject handleDefault() throws HttpPresentationException { 68 return showPage(null); 69 } 70 71 78 public XMLObject showPage(String errorMsg) 79 80 throws HttpPresentationException { 81 Class tempClass=null; 82 Object page= null; 83 Method setTextErrorText = null; 84 Method getTagErrorText = null; 85 86 try{ 87 Class stringClass=Class.forName("java.lang.String"); 88 tempClass = Class.forName(DeviceUtils.getPageName(myComms, "com.lutris.airsent.presentation.messenger.MessengerLogin")); 89 page= myComms.xmlcFactory.create(tempClass); 90 Class [] argTypeArr={stringClass}; 91 setTextErrorText = tempClass.getMethod("setTextErrorText",argTypeArr); 92 getTagErrorText = tempClass.getMethod("getElementErrorText",null); 93 }catch(Exception e){} 94 95 96 97 100 try { 101 Element error = (Element)getTagErrorText.invoke(page,null); 102 104 if (null != errorMsg 105 || null 106 != (errorMsg = 107 this.getSessionData().getAndClearUserMessage())) { 108 109 Object [] temp={errorMsg}; 110 setTextErrorText.invoke(page,temp); 111 } else { 113 Object [] temp={""}; 114 setTextErrorText.invoke(page,temp); 115 } 117 118 if (error.getAttributeNode("jsessionid") != null) { 121 error.getAttributeNode("jsessionid").setValue(myComms.session.getSessionKey()); 122 } 123 } catch (Exception ex) { 124 throw new AirSentPresentationException("Error in messenger login", 125 ex); 126 } 127 DeviceUtils.setURLTimeStamp((XMLObject)page); 128 return ((XMLObject)page); 129 } 130 131 136 public XMLObject handleLogin() throws HttpPresentationException { 137 String badge = 138 myComms.request.getParameter(AirSentConstants.LOGIN_NAME); 139 String password = 140 myComms.request.getParameter(AirSentConstants.PASSWORD_NAME); 141 Messenger messenger = null; 142 143 try { 144 if (badge == null || 145 password == null || 146 (messenger = getApplication().getHomeManager().getMessengerManager().validatePassword(badge, password)) == null) { 147 return showPage("Invalid login or password!!"); 148 } else { 149 150 getSessionData().setMessenger(messenger); 151 getSessionData().setUserAuth(AirSentConstants.MESSENGER_USER); 152 throw new ClientPageRedirectException(AirSentConstants.MESSENGER_MAIN_PAGE); 153 154 } 155 } catch (Exception ex) { 156 throw new AirSentPresentationException("System error logging in Messenger.", 157 ex); 158 } 159 160 } 161 162 } 163 164 | Popular Tags |