001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: MemoryRealmForm.java 6599 2005-04-21 08:59:54Z kemlerp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.security;
027:
028: import javax.servlet.http.HttpServletRequest;
029:
030: import org.apache.struts.action.ActionMessage;
031: import org.apache.struts.action.ActionErrors;
032: import org.apache.struts.action.ActionMapping;
033:
034: /**
035: * @author Michel-Ange ANTON
036: */
037: public class MemoryRealmForm extends FactoryRealmForm {
038:
039: // --------------------------------------------------------- Constants
040:
041: // --------------------------------------------------------- Properties variables
042:
043: private String[] groups = new String[0];
044: private String[] roles = new String[0];
045:
046: // --------------------------------------------------------- Public Methods
047:
048: /**
049: * Reset all properties to their default values.
050: *
051: * @param mapping The mapping used to select this instance
052: * @param request The servlet request we are processing
053: */
054:
055: public void reset(ActionMapping mapping, HttpServletRequest request) {
056: super .reset(mapping, request);
057:
058: roles = new String[0];
059: groups = new String[0];
060: }
061:
062: /**
063: * Validate the properties that have been set from this HTTP request,
064: * and return an <code>ActionErrors</code> object that encapsulates any
065: * validation errors that have been found. If no errors are found, return
066: * <code>null</code> or an <code>ActionErrors</code> object with no
067: * recorded error messages.
068: *
069: * @param mapping The mapping used to select this instance
070: * @param request The servlet request we are processing
071: * @return List of errors
072: */
073: public ActionErrors validate(ActionMapping mapping,
074: HttpServletRequest request) {
075: ActionErrors oErrors = new ActionErrors();
076: if ((getName() == null) || (getName().length() == 0)) {
077: oErrors
078: .add(
079: "name",
080: new ActionMessage(
081: "error.security.factory.memory.realm.name.required"));
082: }
083: if ((getName() != null) && (getName().length() > 0)) {
084: if (getName().indexOf(' ') >= 0) {
085: oErrors
086: .add(
087: "name",
088: new ActionMessage(
089: "error.security.factory.memory.realm.name.nospace"));
090: }
091: }
092: return oErrors;
093: }
094:
095: // --------------------------------------------------------- Properties Methods
096:
097: public String[] getGroups() {
098: return groups;
099: }
100:
101: public void setGroups(String[] groups) {
102: this .groups = groups;
103: }
104:
105: public String[] getRoles() {
106: return roles;
107: }
108:
109: public void setRoles(String[] roles) {
110: this.roles = roles;
111: }
112: }
|