UserMemoryRealmForm.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * Initial developer(s): Michel-Ange ANTON
00022  * --------------------------------------------------------------------------
00023  * $Id: UserMemoryRealmForm.java,v 1.4 2004/03/19 14:31:48 sauthieg Exp $
00024  * --------------------------------------------------------------------------
00025  */
00026 
00027 package org.objectweb.jonas.webapp.jonasadmin.security;
00028 
00029 import java.util.ArrayList;
00030 
00031 import javax.servlet.http.HttpServletRequest;
00032 
00033 import org.apache.struts.action.ActionError;
00034 import org.apache.struts.action.ActionErrors;
00035 import org.apache.struts.action.ActionForm;
00036 import org.apache.struts.action.ActionMapping;
00037 import org.objectweb.jonas.webapp.jonasadmin.Jlists;
00038 
00039 public class UserMemoryRealmForm extends ActionForm {
00040 
00041 // --------------------------------------------------------- Constants
00042 
00043 // --------------------------------------------------------- Properties variables
00044 
00045     private String action = null;
00046     private String user = null;
00047     private String password = null;
00048     private String confirmPassword = null;
00049     private java.util.ArrayList listGroupsUser = new ArrayList();
00050     private java.util.ArrayList listGroupsRealm = new ArrayList();
00051     private java.util.ArrayList listGroupsUsed = new ArrayList();
00052     private java.util.ArrayList listGroupsNotused = new ArrayList();
00053     private java.util.ArrayList listRolesUser = new ArrayList();
00054     private java.util.ArrayList listRolesRealm = new ArrayList();
00055     private java.util.ArrayList listRolesUsed = new ArrayList();
00056     private java.util.ArrayList listRolesNotused = new ArrayList();
00057     private String groupsUsed = null;
00058     private String groupsNotused = null;
00059     private String rolesUsed = null;
00060     private String rolesNotused = null;
00061     private String[] groupsNotusedSelected = new String[0];
00062     private String[] groupsUsedSelected = new String[0];
00063     private String[] rolesNotusedSelected = new String[0];
00064     private String[] rolesUsedSelected = new String[0];
00065 
00066 // --------------------------------------------------------- Public Methods
00067 
00074     public void reset(ActionMapping mapping, HttpServletRequest request) {
00075         password = null;
00076         confirmPassword = null;
00077         groupsUsed = null;
00078         groupsNotused = null;
00079         rolesUsed = null;
00080         rolesNotused = null;
00081         // Mandatory !
00082         groupsNotusedSelected = new String[0];
00083         groupsUsedSelected = new String[0];
00084         rolesNotusedSelected = new String[0];
00085         rolesUsedSelected = new String[0];
00086     }
00087 
00098     public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
00099         ActionErrors oErrors = new ActionErrors();
00100         // Create errors
00101         if (action.equals("create") == true) {
00102             user = user.trim();
00103             if (user.length() == 0) {
00104                 oErrors.add("user"
00105                     , new ActionError("error.security.factory.memory.realm.user.name.required"));
00106             }
00107             if (password.length() == 0) {
00108                 oErrors.add("password"
00109                     , new ActionError("error.security.factory.memory.realm.user.password.required"));
00110             }
00111             if (confirmPassword.length() == 0) {
00112                 oErrors.add("password"
00113                     , new ActionError("error.security.factory.memory.realm.user.confirmPassword.required"));
00114             }
00115         }
00116         // Create and apply errors (but this test exists only to not overload the errors)
00117         if (oErrors.size() == 0) {
00118             if (password.length() > 0) {
00119                 if (password.equals(confirmPassword) == false) {
00120                     oErrors.add("password"
00121                         , new ActionError("error.security.factory.memory.realm.user.password.change.different"));
00122                 }
00123             }
00124             if ((confirmPassword.length() > 0) && (password.length() == 0)) {
00125                 oErrors.add("password"
00126                     , new ActionError("error.security.factory.memory.realm.user.password.change.required"));
00127             }
00128         }
00129         // Replace the elements in their good place
00130         if (oErrors.size() > 0) {
00131             listRolesUsed = Jlists.getArrayList(rolesUsed, Jlists.SEPARATOR);
00132             listRolesNotused = Jlists.getArrayList(rolesNotused, Jlists.SEPARATOR);
00133             listGroupsUsed = Jlists.getArrayList(groupsUsed, Jlists.SEPARATOR);
00134             listGroupsNotused = Jlists.getArrayList(groupsNotused, Jlists.SEPARATOR);
00135         }
00136         return oErrors;
00137     }
00138 
00139 // --------------------------------------------------------- Properties Methods
00140 
00141     public String getUser() {
00142         return user;
00143     }
00144 
00145     public void setUser(String user) {
00146         this.user = user;
00147     }
00148 
00149     public String getPassword() {
00150         return password;
00151     }
00152 
00153     public void setPassword(String password) {
00154         this.password = password;
00155     }
00156 
00157     public String getConfirmPassword() {
00158         return confirmPassword;
00159     }
00160 
00161     public void setConfirmPassword(String confirmPassword) {
00162         this.confirmPassword = confirmPassword;
00163     }
00164 
00165     public java.util.ArrayList getListGroupsUser() {
00166         return listGroupsUser;
00167     }
00168 
00169     public void setListGroupsUser(java.util.ArrayList listGroupsUser) {
00170         this.listGroupsUser = listGroupsUser;
00171     }
00172 
00173     public java.util.ArrayList getListGroupsRealm() {
00174         return listGroupsRealm;
00175     }
00176 
00177     public void setListGroupsRealm(java.util.ArrayList listGroupsRealm) {
00178         this.listGroupsRealm = listGroupsRealm;
00179     }
00180 
00181     public java.util.ArrayList getListGroupsUsed() {
00182         return listGroupsUsed;
00183     }
00184 
00185     public void setListGroupsUsed(java.util.ArrayList listGroupsUsed) {
00186         this.listGroupsUsed = listGroupsUsed;
00187     }
00188 
00189     public java.util.ArrayList getListGroupsNotused() {
00190         return listGroupsNotused;
00191     }
00192 
00193     public void setListGroupsNotused(java.util.ArrayList listGroupsNotused) {
00194         this.listGroupsNotused = listGroupsNotused;
00195     }
00196 
00197     public java.util.ArrayList getListRolesUser() {
00198         return listRolesUser;
00199     }
00200 
00201     public void setListRolesUser(java.util.ArrayList listRolesUser) {
00202         this.listRolesUser = listRolesUser;
00203     }
00204 
00205     public java.util.ArrayList getListRolesRealm() {
00206         return listRolesRealm;
00207     }
00208 
00209     public void setListRolesRealm(java.util.ArrayList listRolesRealm) {
00210         this.listRolesRealm = listRolesRealm;
00211     }
00212 
00213     public java.util.ArrayList getListRolesUsed() {
00214         return listRolesUsed;
00215     }
00216 
00217     public void setListRolesUsed(java.util.ArrayList listRolesUsed) {
00218         this.listRolesUsed = listRolesUsed;
00219     }
00220 
00221     public java.util.ArrayList getListRolesNotused() {
00222         return listRolesNotused;
00223     }
00224 
00225     public void setListRolesNotused(java.util.ArrayList listRolesNotused) {
00226         this.listRolesNotused = listRolesNotused;
00227     }
00228 
00229     public String getGroupsUsed() {
00230         return groupsUsed;
00231     }
00232 
00233     public void setGroupsUsed(String groupsUsed) {
00234         this.groupsUsed = groupsUsed;
00235     }
00236 
00237     public String getGroupsNotused() {
00238         return groupsNotused;
00239     }
00240 
00241     public void setGroupsNotused(String groupsNotused) {
00242         this.groupsNotused = groupsNotused;
00243     }
00244 
00245     public String getRolesUsed() {
00246         return rolesUsed;
00247     }
00248 
00249     public void setRolesUsed(String rolesUsed) {
00250         this.rolesUsed = rolesUsed;
00251     }
00252 
00253     public String getRolesNotused() {
00254         return rolesNotused;
00255     }
00256 
00257     public void setRolesNotused(String rolesNotused) {
00258         this.rolesNotused = rolesNotused;
00259     }
00260 
00261     public String[] getGroupsNotusedSelected() {
00262         return groupsNotusedSelected;
00263     }
00264 
00265     public void setGroupsNotusedSelected(String[] groupsNotusedSelected) {
00266         this.groupsNotusedSelected = groupsNotusedSelected;
00267     }
00268 
00269     public String[] getGroupsUsedSelected() {
00270         return groupsUsedSelected;
00271     }
00272 
00273     public void setGroupsUsedSelected(String[] groupsUsedSelected) {
00274         this.groupsUsedSelected = groupsUsedSelected;
00275     }
00276 
00277     public String[] getRolesNotusedSelected() {
00278         return rolesNotusedSelected;
00279     }
00280 
00281     public void setRolesNotusedSelected(String[] rolesNotusedSelected) {
00282         this.rolesNotusedSelected = rolesNotusedSelected;
00283     }
00284 
00285     public String[] getRolesUsedSelected() {
00286         return rolesUsedSelected;
00287     }
00288 
00289     public void setRolesUsedSelected(String[] rolesUsedSelected) {
00290         this.rolesUsedSelected = rolesUsedSelected;
00291     }
00292 
00293     public String getAction() {
00294         return action;
00295     }
00296 
00297     public void setAction(String action) {
00298         this.action = action;
00299     }
00300 
00301 }

Generated on Tue Feb 15 15:05:30 2005 for JOnAS by  doxygen 1.3.9.1