1 26 27 package org.objectweb.jonas.webapp.jonasadmin.security; 28 29 import java.util.ArrayList ; 30 31 import javax.servlet.http.HttpServletRequest ; 32 33 import org.apache.struts.action.ActionMessage; 34 import org.apache.struts.action.ActionErrors; 35 import org.apache.struts.action.ActionForm; 36 import org.apache.struts.action.ActionMapping; 37 import org.objectweb.jonas.webapp.jonasadmin.Jlists; 38 39 public class UserMemoryRealmForm extends ActionForm { 40 41 43 45 private String action = null; 46 private String user = null; 47 private String password = null; 48 private String confirmPassword = null; 49 private java.util.ArrayList listGroupsUser = new ArrayList (); 50 private java.util.ArrayList listGroupsRealm = new ArrayList (); 51 private java.util.ArrayList listGroupsUsed = new ArrayList (); 52 private java.util.ArrayList listGroupsNotused = new ArrayList (); 53 private java.util.ArrayList listRolesUser = new ArrayList (); 54 private java.util.ArrayList listRolesRealm = new ArrayList (); 55 private java.util.ArrayList listRolesUsed = new ArrayList (); 56 private java.util.ArrayList listRolesNotused = new ArrayList (); 57 private String groupsUsed = null; 58 private String groupsNotused = null; 59 private String rolesUsed = null; 60 private String rolesNotused = null; 61 private String [] groupsNotusedSelected = new String [0]; 62 private String [] groupsUsedSelected = new String [0]; 63 private String [] rolesNotusedSelected = new String [0]; 64 private String [] rolesUsedSelected = new String [0]; 65 66 68 74 public void reset(ActionMapping mapping, HttpServletRequest request) { 75 password = null; 76 confirmPassword = null; 77 groupsUsed = null; 78 groupsNotused = null; 79 rolesUsed = null; 80 rolesNotused = null; 81 groupsNotusedSelected = new String [0]; 83 groupsUsedSelected = new String [0]; 84 rolesNotusedSelected = new String [0]; 85 rolesUsedSelected = new String [0]; 86 } 87 88 98 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 99 ActionErrors oErrors = new ActionErrors(); 100 if (action.equals("create") == true) { 102 user = user.trim(); 103 if (user.length() == 0) { 104 oErrors.add("user" 105 , new ActionMessage("error.security.factory.memory.realm.user.name.required")); 106 } 107 if (password.length() == 0) { 108 oErrors.add("password" 109 , new ActionMessage("error.security.factory.memory.realm.user.password.required")); 110 } 111 if (confirmPassword.length() == 0) { 112 oErrors.add("password" 113 , new ActionMessage("error.security.factory.memory.realm.user.confirmPassword.required")); 114 } 115 } 116 if (oErrors.size() == 0) { 118 if (password.length() > 0) { 119 if (!password.equals(confirmPassword)) { 120 oErrors.add("password" 121 , new ActionMessage("error.security.factory.memory.realm.user.password.change.different")); 122 } 123 } 124 if ((confirmPassword.length() > 0) && (password.length() == 0)) { 125 oErrors.add("password" 126 , new ActionMessage("error.security.factory.memory.realm.user.password.change.required")); 127 } 128 } 129 if (oErrors.size() > 0) { 131 listRolesUsed = Jlists.getArrayList(rolesUsed, Jlists.SEPARATOR); 132 listRolesNotused = Jlists.getArrayList(rolesNotused, Jlists.SEPARATOR); 133 listGroupsUsed = Jlists.getArrayList(groupsUsed, Jlists.SEPARATOR); 134 listGroupsNotused = Jlists.getArrayList(groupsNotused, Jlists.SEPARATOR); 135 } 136 return oErrors; 137 } 138 139 141 public String getUser() { 142 return user; 143 } 144 145 public void setUser(String user) { 146 this.user = user; 147 } 148 149 public String getPassword() { 150 return password; 151 } 152 153 public void setPassword(String password) { 154 this.password = password; 155 } 156 157 public String getConfirmPassword() { 158 return confirmPassword; 159 } 160 161 public void setConfirmPassword(String confirmPassword) { 162 this.confirmPassword = confirmPassword; 163 } 164 165 public java.util.ArrayList getListGroupsUser() { 166 return listGroupsUser; 167 } 168 169 public void setListGroupsUser(java.util.ArrayList listGroupsUser) { 170 this.listGroupsUser = listGroupsUser; 171 } 172 173 public java.util.ArrayList getListGroupsRealm() { 174 return listGroupsRealm; 175 } 176 177 public void setListGroupsRealm(java.util.ArrayList listGroupsRealm) { 178 this.listGroupsRealm = listGroupsRealm; 179 } 180 181 public java.util.ArrayList getListGroupsUsed() { 182 return listGroupsUsed; 183 } 184 185 public void setListGroupsUsed(java.util.ArrayList listGroupsUsed) { 186 this.listGroupsUsed = listGroupsUsed; 187 } 188 189 public java.util.ArrayList getListGroupsNotused() { 190 return listGroupsNotused; 191 } 192 193 public void setListGroupsNotused(java.util.ArrayList listGroupsNotused) { 194 this.listGroupsNotused = listGroupsNotused; 195 } 196 197 public java.util.ArrayList getListRolesUser() { 198 return listRolesUser; 199 } 200 201 public void setListRolesUser(java.util.ArrayList listRolesUser) { 202 this.listRolesUser = listRolesUser; 203 } 204 205 public java.util.ArrayList getListRolesRealm() { 206 return listRolesRealm; 207 } 208 209 public void setListRolesRealm(java.util.ArrayList listRolesRealm) { 210 this.listRolesRealm = listRolesRealm; 211 } 212 213 public java.util.ArrayList getListRolesUsed() { 214 return listRolesUsed; 215 } 216 217 public void setListRolesUsed(java.util.ArrayList listRolesUsed) { 218 this.listRolesUsed = listRolesUsed; 219 } 220 221 public java.util.ArrayList getListRolesNotused() { 222 return listRolesNotused; 223 } 224 225 public void setListRolesNotused(java.util.ArrayList listRolesNotused) { 226 this.listRolesNotused = listRolesNotused; 227 } 228 229 public String getGroupsUsed() { 230 return groupsUsed; 231 } 232 233 public void setGroupsUsed(String groupsUsed) { 234 this.groupsUsed = groupsUsed; 235 } 236 237 public String getGroupsNotused() { 238 return groupsNotused; 239 } 240 241 public void setGroupsNotused(String groupsNotused) { 242 this.groupsNotused = groupsNotused; 243 } 244 245 public String getRolesUsed() { 246 return rolesUsed; 247 } 248 249 public void setRolesUsed(String rolesUsed) { 250 this.rolesUsed = rolesUsed; 251 } 252 253 public String getRolesNotused() { 254 return rolesNotused; 255 } 256 257 public void setRolesNotused(String rolesNotused) { 258 this.rolesNotused = rolesNotused; 259 } 260 261 public String [] getGroupsNotusedSelected() { 262 return groupsNotusedSelected; 263 } 264 265 public void setGroupsNotusedSelected(String [] groupsNotusedSelected) { 266 this.groupsNotusedSelected = groupsNotusedSelected; 267 } 268 269 public String [] getGroupsUsedSelected() { 270 return groupsUsedSelected; 271 } 272 273 public void setGroupsUsedSelected(String [] groupsUsedSelected) { 274 this.groupsUsedSelected = groupsUsedSelected; 275 } 276 277 public String [] getRolesNotusedSelected() { 278 return rolesNotusedSelected; 279 } 280 281 public void setRolesNotusedSelected(String [] rolesNotusedSelected) { 282 this.rolesNotusedSelected = rolesNotusedSelected; 283 } 284 285 public String [] getRolesUsedSelected() { 286 return rolesUsedSelected; 287 } 288 289 public void setRolesUsedSelected(String [] rolesUsedSelected) { 290 this.rolesUsedSelected = rolesUsedSelected; 291 } 292 293 public String getAction() { 294 return action; 295 } 296 297 public void setAction(String action) { 298 this.action = action; 299 } 300 301 } | Popular Tags |