1 23 24 package org.infoglue.cms.applications.common.actions; 25 26 import org.infoglue.cms.controllers.usecases.common.LoginUCC; 27 import org.infoglue.cms.controllers.usecases.common.LoginUCCFactory; 28 import org.infoglue.cms.security.AuthenticationModule; 29 30 public class LoginAction extends InfoGlueAbstractAction 31 { 32 private static final long serialVersionUID = 35668814570153876L; 33 34 private String userName = null; 35 private String password = null; 36 private String errorMessage = ""; 37 private String referringUrl = null; 38 39 public void setUserName(String userName) 40 { 41 this.userName = userName; 42 } 43 44 public String getUserName() 45 { 46 return this.userName; 47 } 48 49 public void setPassword(String password) 50 { 51 this.password = password; 52 } 53 54 public String getPassword() 55 { 56 return this.password; 57 } 58 59 public String getErrorMessage() 60 { 61 return this.errorMessage; 62 } 63 64 public String doExecute() throws Exception 65 { 66 if(this.getRequest().getRemoteUser() != null) 67 return "redirect"; 68 else 69 return "success"; 70 } 71 72 public String doInvalidLogin() throws Exception 73 { 74 if(this.getRequest().getRemoteUser() != null) 75 { 76 return "redirect"; 77 } 78 else 79 { 80 return "invalidLogin"; 81 } 82 } 83 84 public String doLogonUser() throws Exception 85 { 86 LoginUCC loginController = LoginUCCFactory.newLoginUCC(); 87 boolean isAccepted = loginController.authorizeSystemUser(this.userName, this.password); 88 89 if(isAccepted) 90 { 91 return "userAccepted"; 92 } 93 else 94 { 95 errorMessage = "The logon information given was incorrect, please verify and try again."; 96 return "invalidLogin"; 97 } 98 } 99 100 104 105 public String doLogout() throws Exception 106 { 107 getHttpSession().invalidate(); 108 109 AuthenticationModule authenticationModule = AuthenticationModule.getAuthenticationModule(null, null); 110 boolean redirected = authenticationModule.logoutUser(getRequest(), getResponse()); 111 112 if(redirected) 113 return NONE; 114 else 115 return "logout"; 116 } 117 118 public String getPrincipal() 119 { 120 java.security.Principal principal = getRequest().getUserPrincipal(); 121 return "Principal:" + principal.getName(); 122 } 123 124 public String getReferringUrl() 125 { 126 return referringUrl; 127 } 128 129 public void setReferringUrl(String string) 130 { 131 referringUrl = string; 132 } 133 134 } | Popular Tags |