Modified: 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java?view=diff&rev=505014&r1=505013&r2=505014
==============================================================================
--- 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java
 Thu Feb  8 11:31:01 2007
@@ -1,480 +1,215 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy 
of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations 
under
- * the License.
- */
-
-package org.apache.jetspeed.serializer.objects;
-
-import java.util.ArrayList;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import javolution.xml.XMLBinding;
-import javolution.xml.XMLFormat;
-import javolution.xml.stream.XMLStreamException;
-
-public class JSSnapshot
-{
-
-    public static final int softwareVersion = 1;
-
-    public static final int softwareSubVersion = 0;
-
-    private String name;
-
-    private int savedVersion;
-
-    private int savedSubversion;
-
-    private String dateCreated;
-
-    private String dataSource;
-
-    private String encryption;
-
-    private JSMimeTypes mimeTypes;
-
-    private JSMediaTypes mediaTypes;
-
-    private JSClients clients;
-
-    private JSCapabilities capabilities;
-
-    private JSRoles roles;
-
-    private JSGroups groups;
-
-    private JSUsers users;
-
-    private JSPermissions permissions;
-
-    private JSProfilingRules rules;
-
-    private String defaultRule;
-
-    /**
-     * check the software version and subvversion against the saved
-     * version...and verify whether it is compatible...
-     * 
-     * @return the current software can process this file
-     */
-    public boolean checkVersion()
-    {
-        return true;
-    }
-
-    public JSSnapshot()
-    {
-        System.out.println("JSSnapshot Class created");
-    }
-
-    public JSSnapshot(String name)
-    {
-        this.name = name;
-        mimeTypes = new JSMimeTypes();
-        mediaTypes = new JSMediaTypes();
-        clients = new JSClients();
-        capabilities = new JSCapabilities();
-        roles = new JSRoles();
-        groups = new JSGroups();
-        users = new JSUsers();
-        permissions = new JSPermissions();
-        rules = new JSProfilingRules();
-    }
-
- 
-    
/***************************************************************************
-     * SERIALIZER
-     */
-    private static final XMLFormat XML = new XMLFormat(JSSnapshot.class)
-    {
-
-        public void write(Object o, OutputElement xml)
-                throws XMLStreamException
-        {
-               
-            try
-            {
-                JSSnapshot g = (JSSnapshot) o;
-
-                /** attributes here */
-
-                xml.setAttribute("name", g.getName());
-
-                /** named fields HERE */
-
-                xml.add(String.valueOf(g.getSoftwareVersion()),
-                        "softwareVersion");
-                xml.add(String.valueOf(g.getSoftwareSubVersion()),
-                        "softwareSubVersion");
-                xml.add(g.getDefaultRule(), "default_rule", String.class);
-
-                xml.add(g.encryption,"encryption",String.class);
-                
-                /** implicitly named (through binding) fields here */
-
-                xml.add(g.getMimeTypes());
-                xml.add(g.getMediaTypes());
-                xml.add(g.getCapabilities());
-                xml.add(g.getClients());
-                
-                xml.add(g.getRoles()); 
-                xml.add(g.getGroups());
-                xml.add(g.getUsers()); 
-                
-                xml.add(g.getPermissions());
-                xml.add(g.getRules());
-
-            } catch (Exception e)
-            {
-                e.printStackTrace();
-            }
-        }
-
-        public void read(InputElement xml, Object o)
-        {
-            try
-            {
-                JSSnapshot g = (JSSnapshot) o;
-                g.name = 
StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
-                Object o1 = xml.get("softwareVersion",String.class);
-                if (o1 instanceof String)
-                    g.savedVersion = Integer.parseInt(((String) o1));
-                o1 = xml.get("softwareSubVersion",String.class);
-                if (o1 instanceof String)
-                    g.savedSubversion = Integer.parseInt(((String) o1));
-                o1 = xml.get("default_rule",String.class);
-                if (o1 instanceof String) g.defaultRule = 
StringEscapeUtils.unescapeHtml((String) o1);
-                o1 = xml.get("encryption",String.class);
-                if (o1 instanceof String) g.encryption = 
StringEscapeUtils.unescapeHtml((String) o1);
-
-                while (xml.hasNext())
-                {
-                    o1 = xml.getNext(); // mime
-
-                    if (o1 instanceof JSMimeTypes)
-                        g.mimeTypes = (JSMimeTypes) o1;
-                    else if (o1 instanceof JSMediaTypes)
-                        g.mediaTypes = (JSMediaTypes) o1;
-                    else if (o1 instanceof JSClients)
-                        g.clients = (JSClients) o1;
-                    else if (o1 instanceof JSCapabilities)
-                        g.capabilities = (JSCapabilities) o1;
-                    else if (o1 instanceof JSRoles)
-                        g.roles = (JSRoles) o1;
-                    else if (o1 instanceof JSGroups)
-                        g.groups = (JSGroups) o1;
-                    else if (o1 instanceof JSUsers)
-                        g.users = (JSUsers) o1;
-                    else if (o1 instanceof JSPermissions)
-                        g.permissions = (JSPermissions) o1;
-                    else if (o1 instanceof JSProfilingRules)
-                        g.rules = (JSProfilingRules) o1;
-                }
-            } catch (Exception e)
-            {
-                e.printStackTrace();
-            }
-        }
-    };
-
-    /**
-     * @return Returns the name.
-     */
-    public String getName()
-    {
-        return name;
-    }
-
-    /**
-     * @return Returns the groups.
-     */
-    public JSGroups getGroups()
-    {
-        return groups;
-    }
-
-    /**
-     * @param groups
-     *            The groups to set.
-     */
-    public void setGroups(JSGroups groups)
-    {
-        this.groups = groups;
-    }
-
-    /**
-     * @return Returns the roles.
-     */
-    public JSRoles getRoles()
-    {
-        return roles;
-    }
-
-    /**
-     * @param roles
-     *            The roles to set.
-     */
-    public void setRoles(JSRoles roles)
-    {
-        this.roles = roles;
-    }
-
-    /**
-     * @return Returns the roles.
-     */
-    public JSUsers getUsers()
-    {
-        return users;
-    }
-
-    /**
-     * @return Returns the encryption.
-     */
-    public String getEncryption()
-    {
-        return encryption;
-    }
-
-    /**
-     * @param encryption
-     *            The encryption to set.
-     */
-    public void setEncryption(String encryption)
-    {
-        this.encryption = encryption;
-    }
-
-    /**
-     * @return Returns the softwareSubVersion.
-     */
-    public static int getSoftwareSubVersion()
-    {
-        return softwareSubVersion;
-    }
-
-    /**
-     * @return Returns the softwareVersion.
-     */
-    public static int getSoftwareVersion()
-    {
-        return softwareVersion;
-    }
-
-    /**
-     * @return Returns the capabilities.
-     */
-    public JSCapabilities getCapabilities()
-    {
-        return capabilities;
-    }
-
-    /**
-     * @param capabilities
-     *            The capabilities to set.
-     */
-    public void setCapabilities(JSCapabilities capabilities)
-    {
-        this.capabilities = capabilities;
-    }
-
-    /**
-     * @return Returns the clients.
-     */
-    public JSClients getClients()
-    {
-        return clients;
-    }
-
-    /**
-     * @param clients
-     *            The clients to set.
-     */
-    public void setClients(JSClients clients)
-    {
-        this.clients = clients;
-    }
-
-    /**
-     * @return Returns the dataSource.
-     */
-    public String getDataSource()
-    {
-        return dataSource;
-    }
-
-    /**
-     * @param dataSource
-     *            The dataSource to set.
-     */
-    public void setDataSource(String dataSource)
-    {
-        this.dataSource = dataSource;
-    }
-
-    /**
-     * @return Returns the dateCreated.
-     */
-    public String getDateCreated()
-    {
-        return dateCreated;
-    }
-
-    /**
-     * @param dateCreated
-     *            The dateCreated to set.
-     */
-    public void setDateCreated(String dateCreated)
-    {
-        this.dateCreated = dateCreated;
-    }
-
-    /**
-     * @return Returns the mediaTypes.
-     */
-    public JSMediaTypes getMediaTypes()
-    {
-        return mediaTypes;
-    }
-
-    /**
-     * @param mediaTypes
-     *            The mediaTypes to set.
-     */
-    public void setMediaTypes(JSMediaTypes mediaTypes)
-    {
-        this.mediaTypes = mediaTypes;
-    }
-
-    /**
-     * @return Returns the mimeTypes.
-     */
-    public JSMimeTypes getMimeTypes()
-    {
-        return mimeTypes;
-    }
-
-    /**
-     * @param mimeTypes
-     *            The mimeTypes to set.
-     */
-    public void setMimeTypes(JSMimeTypes mimeTypes)
-    {
-        this.mimeTypes = mimeTypes;
-    }
-
-    /**
-     * @return Returns the savedSubversion.
-     */
-    public int getSavedSubversion()
-    {
-        return savedSubversion;
-    }
-
-    /**
-     * @param savedSubversion
-     *            The savedSubversion to set.
-     */
-    public void setSavedSubversion(int savedSubversion)
-    {
-        this.savedSubversion = savedSubversion;
-    }
-
-    /**
-     * @return Returns the savedVersion.
-     */
-    public int getSavedVersion()
-    {
-        return savedVersion;
-    }
-
-    /**
-     * @param savedVersion
-     *            The savedVersion to set.
-     */
-    public void setSavedVersion(int savedVersion)
-    {
-        this.savedVersion = savedVersion;
-    }
-
-    /**
-     * @param name
-     *            The name to set.
-     */
-    public void setName(String name)
-    {
-        this.name = name;
-    }
-
-    /**
-     * @param users
-     *            The users to set.
-     */
-    public void setUsers(JSUsers users)
-    {
-        this.users = users;
-    }
-
-    /**
-     * @return Returns the permissions.
-     */
-    public JSPermissions getPermissions()
-    {
-        return permissions;
-    }
-
-    /**
-     * @param permissions
-     *            The permissions to set.
-     */
-    public void setPermissions(JSPermissions permissions)
-    {
-        this.permissions = permissions;
-    }
-
-    /**
-     * @return Returns the rules.
-     */
-    public JSProfilingRules getRules()
-    {
-        return rules;
-    }
-
-    /**
-     * @param rules
-     *            The rules to set.
-     */
-    public void setRules(JSProfilingRules rules)
-    {
-        this.rules = rules;
-    }
-
-    /**
-     * @return Returns the defaultRule.
-     */
-    public String getDefaultRule()
-    {
-        return defaultRule;
-    }
-
-    /**
-     * @param defaultRule
-     *            The defaultRule to set.
-     */
-    public void setDefaultRule(String defaultRule)
-    {
-        this.defaultRule = defaultRule;
-    }
-
-}
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+
+package org.apache.jetspeed.serializer.objects;
+
+import java.util.ArrayList;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+import javolution.xml.XMLBinding;
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+public abstract class JSSnapshot
+{
+               
+
+           private String name;
+
+           private int savedVersion;
+
+           private int savedSubversion;
+
+           private String dateCreated;
+
+           private String dataSource;
+
+
+           /**
+            * check the software version and subvversion against the saved
+            * version...and verify whether it is compatible...
+            * 
+            * @return the current software can process this file
+            */
+           public boolean checkVersion()
+           {
+               return true;
+           }
+
+           public JSSnapshot()
+           {
+               System.out.println(this.getClass().getName() + " created");
+           }
+
+           public JSSnapshot(String name)
+           {
+               this.name = name;
+           }
+
+        
+
+
+           /**
+            * @return Returns the name.
+            */
+           public final String getName()
+           {
+               return name;
+           }
+
+
+           /**
+            * @return Returns the softwareSubVersion.
+            */
+           public abstract int getSoftwareSubVersion();
+
+           /**
+            * @return Returns the softwareVersion.
+            */
+           public abstract int getSoftwareVersion();
+
+           /**
+            * @return Returns the dataSource.
+            */
+           public final String getDataSource()
+           {
+               return dataSource;
+           }
+
+           /**
+            * @param dataSource
+            *            The dataSource to set.
+            */
+           public final  void setDataSource(String dataSource)
+           {
+               this.dataSource = dataSource;
+           }
+
+           /**
+            * @return Returns the dateCreated.
+            */
+           public final  String getDateCreated()
+           {
+               return dateCreated;
+           }
+
+           /**
+            * @param dateCreated
+            *            The dateCreated to set.
+            */
+           public final  void setDateCreated(String dateCreated)
+           {
+               this.dateCreated = dateCreated;
+           }
+
+
+           /**
+            * @return Returns the savedSubversion.
+            */
+           public final  int getSavedSubversion()
+           {
+               return savedSubversion;
+           }
+
+           /**
+            * @param savedSubversion
+            *            The savedSubversion to set.
+            */
+           public final  void setSavedSubversion(int savedSubversion)
+           {
+               this.savedSubversion = savedSubversion;
+           }
+
+           /**
+            * @return Returns the savedVersion.
+            */
+           public final  int getSavedVersion()
+           {
+               return savedVersion;
+           }
+
+           /**
+            * @param savedVersion
+            *            The savedVersion to set.
+            */
+           public final  void setSavedVersion(int savedVersion)
+           {
+               this.savedVersion = savedVersion;
+           }
+
+           /**
+            * @param name
+            *            The name to set.
+            */
+           public final  void setName(String name)
+           {
+               this.name = name;
+           }
+
+
+
+    
/***************************************************************************
+     * SERIALIZER
+     */
+    protected static final XMLFormat XML = new XMLFormat(JSSnapshot.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+               
+            try
+            {
+                JSSnapshot g = (JSSnapshot) o;
+
+                /** attributes here */
+
+                xml.setAttribute("name", g.getName());
+
+                /** named fields HERE */
+
+                xml.add(String.valueOf(g.getSoftwareVersion()),
+                        "softwareVersion");
+                xml.add(String.valueOf(g.getSoftwareSubVersion()),
+                        "softwareSubVersion");
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+                JSSnapshot g = (JSSnapshot) o;
+                g.name = 
StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
+                Object o1 = xml.get("softwareVersion",String.class);
+                if (o1 instanceof String)
+                    g.savedVersion = Integer.parseInt(((String) o1));
+                o1 = xml.get("softwareSubVersion",String.class);
+                if (o1 instanceof String)
+                    g.savedSubversion = Integer.parseInt(((String) o1));
+           } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+    };
+
+ 
+}

Modified: 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUser.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUser.java?view=diff&rev=505014&r1=505013&r2=505014
==============================================================================
--- 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUser.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUser.java
 Thu Feb  8 11:31:01 2007
@@ -1,481 +1,481 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy 
of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations 
under
- * the License.
- */
-package org.apache.jetspeed.serializer.objects;
-
-import java.security.Principal;
-import java.util.ArrayList;
-import java.sql.Date;
-import java.util.Iterator;
-import java.util.prefs.Preferences;
-
-import javolution.xml.XMLFormat;
-import javolution.xml.stream.XMLStreamException;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-/**
- * Jetspeed Serialized (JS) User
- * 
- * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
- * @version $Id: $
- */
-public class JSUser
-{
-
-    private String name;
-
-    private char[] password;
-
-    private JSPWAttributes pwData = null;
-
-    private ArrayList roles = null;
-
-    private ArrayList groups = null;
-
-    private JSUserAttributes userInfo = null;
-
-    private JSNameValuePairs preferences = null;
-
-    private ArrayList publicCredentials = null;
-
-    private ArrayList privateCredentials = null;
-
-    private JSUserRoles roleString;
-
-    private JSUserGroups groupString;
-
-    private JSPrincipalRules rules = new JSPrincipalRules();
-
-    private transient Principal principal;
-
-    public JSUser()
-    {
-    }
-
-    public void addPublicCredential(Object o)
-    {
-        if (publicCredentials == null) publicCredentials = new ArrayList();
-        publicCredentials.add(o);
-    }
-
-    public void addPrivateCredential(Object o)
-    {
-        if (privateCredentials == null) privateCredentials = new ArrayList();
-        privateCredentials.add(o);
-    }
-
-    public void addGroup(JSGroup group)
-    {
-        if (groups == null) groups = new ArrayList();
-        groups.add(group);
-    }
-
-    public void addRole(JSRole role)
-    {
-        if (roles == null) roles = new ArrayList();
-        roles.add(role);
-    }
-
-    public ArrayList getGroups()
-    {
-        return groups;
-    }
-
-    public void setGroups(ArrayList groups)
-    {
-        this.groups = groups;
-    }
-
-    public char[] getPassword()
-    {
-        return password;
-    }
-
-    public void setUserCredential(String name, char[] password, Date 
expirationDate, boolean isEnabled, boolean isExpired, boolean requireUpdate)
-    {
-        setName(name);
-        setPassword(password);
-        pwData = new JSPWAttributes();
-        if (password != null)
-        {
-               pwData.getMyMap().put("password",this.getPasswordString());
-               if (expirationDate != null)
-               {
-                       
pwData.getMyMap().put("expirationDate",expirationDate.toString());
-               }
-               pwData.getMyMap().put("enabled",(isEnabled?"TRUE":"FALSE"));
-               
pwData.getMyMap().put("requiresUpdate",(requireUpdate?"TRUE":"FALSE"));
-        }
-    }
-
-    protected void resetPassword()
-    {
-       try
-       {
-               if (pwData != null)
-               {
-                       Object o = pwData.getMyMap().get("password");
-               
-                       String pw = StringEscapeUtils.unescapeHtml((String)o);
-                       if ((pw != null) && (pw.length()>0))
-                               password = pw.toCharArray();
-                       else
-                               password = null;
-               }
-       }
-       catch (Exception e)
-       {
-                       password = null;
-       }
-    }
-    
-    public boolean getPwEnabled()
-    {
-               return getPWBoolean("enabled",false);
-    }
-    public boolean getPwRequiredUpdate()
-    {
-               return getPWBoolean("requiresUpdate",false);
-    }
-
-    
-
-    
-    
-    public Date getPwExpirationDate()
-    {
-       if (pwData != null)
-       {
-               Object o = pwData.getMyMap().get("expirationDate");
-               if (o == null)
-                       return null;
-               if ( o instanceof Date)
-                       return (Date)o;
-               
-               Date d = Date.valueOf((String)o);
-               return d;
-               
-       }
-       return null;
-    }
-    
-    
-   private boolean getPWBoolean(String property, boolean defaultSetting)
-    {
-               if (pwData == null)
-                       return defaultSetting;
-               try
-               {
-                       Object o = pwData.getMyMap().get(property);
-                       if (o == null)
-                               return defaultSetting;
-                       return ((String)o).equalsIgnoreCase("TRUE");
-               }
-               catch (Exception e)
-               {
-                       return defaultSetting;
-               }
-    }
-   
-    public void setPassword(char[] password)
-    {
-        this.password = password;
-    }
-
-    public void setName(String name)
-    {
-        this.name = name;
-    }
-
-    public ArrayList getRoles()
-    {
-        return roles;
-    }
-
-    public void setRoles(ArrayList roles)
-    {
-        this.roles = roles;
-    }
-
-    public String getName()
-    {
-        return name;
-    }
-
-    /*
-     * private void initUser() throws Exception { User user = null; try {
-     * ums.addUser("test", "password01"); user = ums.getUser("test"); } catch
-     * (SecurityException sex) { assertTrue("user exists. should not have 
thrown
-     * an exception.", false); }
-     * 
-     * Preferences userInfoPrefs = user.getPreferences().node("userinfo");
-     * userInfoPrefs.put("user.name.given", "Test Dude");
-     * userInfoPrefs.put("user.name.family", "Dudley"); }
-     * 
-     */
-
-    /**
-     * @return Returns the preferences.
-     */
-    public JSNameValuePairs getPreferences()
-    {
-        return preferences;
-    }
-
-    /**
-     * @param preferences
-     *            The preferences to set.
-     */
-    public void setPreferences(Preferences preferences)
-    {
-        this.preferences = new JSNameValuePairs(preferences);
-    }
-
-    /**
-     * @return Returns the privateCredentials.
-     */
-    public ArrayList getPrivateCredentials()
-    {
-        return privateCredentials;
-    }
-
-    /**
-     * @param privateCredentials
-     *            The privateCredentials to set.
-     */
-    public void setPrivateCredentials(ArrayList privateCredentials)
-    {
-        this.privateCredentials = privateCredentials;
-    }
-
-    /**
-     * @return Returns the publicCredentials.
-     */
-    public ArrayList getPublicCredentials()
-    {
-        return publicCredentials;
-    }
-
-    /**
-     * @param publicCredentials
-     *            The publicCredentials to set.
-     */
-    public void setPublicCredentials(ArrayList publicCredentials)
-    {
-        this.publicCredentials = publicCredentials;
-    }
-
-    /**
-     * @param userInfo
-     *            The userInfo to set.
-     */
-    public void setUserInfo(Preferences userInfo)
-    {
-        this.userInfo = new JSUserAttributes(userInfo);
-    }
-
-    /**
-     * @return Returns the userInfo.
-     */
-    public JSUserAttributes getUserInfo()
-    {
-        return userInfo;
-    }
-
-    
/***************************************************************************
-     * SERIALIZER
-     */
-    private static final XMLFormat XML = new XMLFormat(JSUser.class)
-    {
-
-        public void write(Object o, OutputElement xml)
-                throws XMLStreamException
-        {
-            try
-            {
-                JSUser g = (JSUser) o;
-                String s = g.getName();
-                if ((s == null) || (s.length() == 0)) s = "guest";
-                xml.setAttribute("name", s);
-
-                
-                xml.add(g.getPwData());
-
-                /** named fields HERE */
- 
-                /** implicitly named (through binding) fields here */
-                g.groupString = new JSUserGroups(g.putTokens(g.getGroups()));
-                g.roleString = new JSUserRoles(g.putTokens(g.getRoles()));
-
-                xml.add(g.roleString);
-                xml.add(g.groupString);
-                xml.add(g.preferences);
-                xml.add(g.userInfo);
-                xml.add(g.rules);
-
-            } catch (Exception e)
-            {
-                e.printStackTrace();
-            }
-        }
-
-        public void read(InputElement xml, Object o)
-        {
-            try
-            {
-                JSUser g = (JSUser) o;
-                g.name = 
StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
-                
-                
-                Object o1 = null;
- 
-
-                               while (xml.hasNext())
-                               {
-                                       o1 = xml.getNext(); // mime
-                                       
-                                       
-                                       if (o1 instanceof JSPWAttributes)
-                                       {
-                                               g.pwData = (JSPWAttributes) o1;
-                                               g.resetPassword();
-                                       }
-                                       else
-                                       if (o1 instanceof JSUserGroups)
-                                               g.groupString = (JSUserGroups) 
o1;
-                                       else
-                           if (o1 instanceof JSUserRoles)
-                               g.roleString = (JSUserRoles) o1;
-                           else
-                            if (o1 instanceof JSUserAttributes)
-                                   g.userInfo  = (JSUserAttributes) o1;
-                                   else
-                                       if (o1 instanceof JSNameValuePairs)
-                                               g.preferences  = 
(JSNameValuePairs) o1;
-                                       else
-                                       if (o1 instanceof JSPrincipalRules)
-                                       g.rules  = (JSPrincipalRules) o1;
-                }
-                
- 
-            } catch (Exception e)
-            {
-                e.printStackTrace();
-            }
-        }
-
-    };
-
-
-    private String append(JSRole rule)
-    {
-        return rule.getName();
-    }
-
-    private String append(JSGroup group)
-    {
-        return group.getName();
-    }
-
-    private String append(Object s)
-    {
-        if (s instanceof JSRole) return append((JSRole) s);
-        if (s instanceof JSGroup) return append((JSGroup) s);
-
-        return s.toString();
-    }
-
-    private String putTokens(ArrayList _list)
-    {
-        if ((_list == null) || (_list.size() == 0)) return "";
-        boolean _start = true;
-        Iterator _it = _list.iterator();
-        StringBuffer _sb = new StringBuffer();
-        while (_it.hasNext())
-        {
-            if (!_start)
-                _sb.append(',');
-            else
-                _start = false;
-
-            _sb.append(append(_it.next()));
-        }
-        return _sb.toString();
-    }
-
-    private String getPasswordString()
-    {
-        if ((this.getPassword() == null) || (this.getPassword().length == 0))
-            return "";
-        else
-            return new String(this.getPassword());
-    }
-
-    /**
-     * @return Returns the rules.
-     */
-    public JSPrincipalRules getRules()
-    {
-        return rules;
-    }
-
-    /**
-     * @param rules
-     *            The rules to set.
-     */
-    public void setRules(JSPrincipalRules rules)
-    {
-        this.rules = rules;
-    }
-
-    /**
-     * @return Returns the principal.
-     */
-    public Principal getPrincipal()
-    {
-        return principal;
-    }
-
-    /**
-     * @param principal
-     *            The principal to set.
-     */
-    public void setPrincipal(Principal principal)
-    {
-        this.principal = principal;
-    }
-
-       public JSUserGroups getGroupString()
-       {
-               return groupString;
-       }
-
-       public JSUserRoles getRoleString()
-       {
-               return roleString;
-       }
-
-       public JSPWAttributes getPwData()
-       {
-               return pwData;
-       }
-
-       public void setPwData(JSPWAttributes pwData)
-       {
-               this.pwData = pwData;
-       }
-
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.jetspeed.serializer.objects;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.sql.Date;
+import java.util.Iterator;
+import java.util.prefs.Preferences;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.commons.lang.StringEscapeUtils;
+
+/**
+ * Jetspeed Serialized (JS) User
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class JSUser
+{
+
+    private String name;
+
+    private char[] password;
+
+    private JSPWAttributes pwData = null;
+
+    private ArrayList roles = null;
+
+    private ArrayList groups = null;
+
+    private JSUserAttributes userInfo = null;
+
+    private JSNVPElements preferences = null;
+
+    private ArrayList publicCredentials = null;
+
+    private ArrayList privateCredentials = null;
+
+    private JSUserRoles roleString;
+
+    private JSUserGroups groupString;
+
+    private JSPrincipalRules rules = new JSPrincipalRules();
+
+    private transient Principal principal;
+
+    public JSUser()
+    {
+    }
+
+    public void addPublicCredential(Object o)
+    {
+        if (publicCredentials == null) publicCredentials = new ArrayList();
+        publicCredentials.add(o);
+    }
+
+    public void addPrivateCredential(Object o)
+    {
+        if (privateCredentials == null) privateCredentials = new ArrayList();
+        privateCredentials.add(o);
+    }
+
+    public void addGroup(JSGroup group)
+    {
+        if (groups == null) groups = new ArrayList();
+        groups.add(group);
+    }
+
+    public void addRole(JSRole role)
+    {
+        if (roles == null) roles = new ArrayList();
+        roles.add(role);
+    }
+
+    public ArrayList getGroups()
+    {
+        return groups;
+    }
+
+    public void setGroups(ArrayList groups)
+    {
+        this.groups = groups;
+    }
+
+    public char[] getPassword()
+    {
+        return password;
+    }
+
+    public void setUserCredential(String name, char[] password, Date 
expirationDate, boolean isEnabled, boolean isExpired, boolean requireUpdate)
+    {
+        setName(name);
+        setPassword(password);
+        pwData = new JSPWAttributes();
+        if (password != null)
+        {
+               pwData.getMyMap().put("password",this.getPasswordString());
+               if (expirationDate != null)
+               {
+                       
pwData.getMyMap().put("expirationDate",expirationDate.toString());
+               }
+               pwData.getMyMap().put("enabled",(isEnabled?"TRUE":"FALSE"));
+               
pwData.getMyMap().put("requiresUpdate",(requireUpdate?"TRUE":"FALSE"));
+        }
+    }
+
+    protected void resetPassword()
+    {
+       try
+       {
+               if (pwData != null)
+               {
+                       Object o = pwData.getMyMap().get("password");
+               
+                       String pw = StringEscapeUtils.unescapeHtml((String)o);
+                       if ((pw != null) && (pw.length()>0))
+                               password = pw.toCharArray();
+                       else
+                               password = null;
+               }
+       }
+       catch (Exception e)
+       {
+                       password = null;
+       }
+    }
+    
+    public boolean getPwEnabled()
+    {
+               return getPWBoolean("enabled",false);
+    }
+    public boolean getPwRequiredUpdate()
+    {
+               return getPWBoolean("requiresUpdate",false);
+    }
+
+    
+
+    
+    
+    public Date getPwExpirationDate()
+    {
+       if (pwData != null)
+       {
+               Object o = pwData.getMyMap().get("expirationDate");
+               if (o == null)
+                       return null;
+               if ( o instanceof Date)
+                       return (Date)o;
+               
+               Date d = Date.valueOf((String)o);
+               return d;
+               
+       }
+       return null;
+    }
+    
+    
+   private boolean getPWBoolean(String property, boolean defaultSetting)
+    {
+               if (pwData == null)
+                       return defaultSetting;
+               try
+               {
+                       Object o = pwData.getMyMap().get(property);
+                       if (o == null)
+                               return defaultSetting;
+                       return ((String)o).equalsIgnoreCase("TRUE");
+               }
+               catch (Exception e)
+               {
+                       return defaultSetting;
+               }
+    }
+   
+    public void setPassword(char[] password)
+    {
+        this.password = password;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public ArrayList getRoles()
+    {
+        return roles;
+    }
+
+    public void setRoles(ArrayList roles)
+    {
+        this.roles = roles;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    /*
+     * private void initUser() throws Exception { User user = null; try {
+     * ums.addUser("test", "password01"); user = ums.getUser("test"); } catch
+     * (SecurityException sex) { assertTrue("user exists. should not have 
thrown
+     * an exception.", false); }
+     * 
+     * Preferences userInfoPrefs = user.getPreferences().node("userinfo");
+     * userInfoPrefs.put("user.name.given", "Test Dude");
+     * userInfoPrefs.put("user.name.family", "Dudley"); }
+     * 
+     */
+
+    /**
+     * @return Returns the preferences.
+     */
+    public JSNVPElements getPreferences()
+    {
+        return preferences;
+    }
+
+    /**
+     * @param preferences
+     *            The preferences to set.
+     */
+    public void setPreferences(Preferences preferences)
+    {
+        this.preferences = new JSNVPElements(preferences);
+    }
+
+    /**
+     * @return Returns the privateCredentials.
+     */
+    public ArrayList getPrivateCredentials()
+    {
+        return privateCredentials;
+    }
+
+    /**
+     * @param privateCredentials
+     *            The privateCredentials to set.
+     */
+    public void setPrivateCredentials(ArrayList privateCredentials)
+    {
+        this.privateCredentials = privateCredentials;
+    }
+
+    /**
+     * @return Returns the publicCredentials.
+     */
+    public ArrayList getPublicCredentials()
+    {
+        return publicCredentials;
+    }
+
+    /**
+     * @param publicCredentials
+     *            The publicCredentials to set.
+     */
+    public void setPublicCredentials(ArrayList publicCredentials)
+    {
+        this.publicCredentials = publicCredentials;
+    }
+
+    /**
+     * @param userInfo
+     *            The userInfo to set.
+     */
+    public void setUserInfo(Preferences userInfo)
+    {
+        this.userInfo = new JSUserAttributes(userInfo);
+    }
+
+    /**
+     * @return Returns the userInfo.
+     */
+    public JSUserAttributes getUserInfo()
+    {
+        return userInfo;
+    }
+
+    
/***************************************************************************
+     * SERIALIZER
+     */
+    private static final XMLFormat XML = new XMLFormat(JSUser.class)
+    {
+
+        public void write(Object o, OutputElement xml)
+                throws XMLStreamException
+        {
+            try
+            {
+                JSUser g = (JSUser) o;
+                String s = g.getName();
+                if ((s == null) || (s.length() == 0)) s = "guest";
+                xml.setAttribute("name", s);
+
+                
+                xml.add(g.getPwData());
+
+                /** named fields HERE */
+ 
+                /** implicitly named (through binding) fields here */
+                g.groupString = new JSUserGroups(g.putTokens(g.getGroups()));
+                g.roleString = new JSUserRoles(g.putTokens(g.getRoles()));
+
+                xml.add(g.roleString);
+                xml.add(g.groupString);
+                xml.add(g.preferences);
+                xml.add(g.userInfo);
+                xml.add(g.rules);
+
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+        public void read(InputElement xml, Object o)
+        {
+            try
+            {
+                JSUser g = (JSUser) o;
+                g.name = 
StringEscapeUtils.unescapeHtml(xml.getAttribute("name", "unknown"));
+                
+                
+                Object o1 = null;
+ 
+
+                               while (xml.hasNext())
+                               {
+                                       o1 = xml.getNext(); // mime
+                                       
+                                       
+                                       if (o1 instanceof JSPWAttributes)
+                                       {
+                                               g.pwData = (JSPWAttributes) o1;
+                                               g.resetPassword();
+                                       }
+                                       else
+                                       if (o1 instanceof JSUserGroups)
+                                               g.groupString = (JSUserGroups) 
o1;
+                                       else
+                           if (o1 instanceof JSUserRoles)
+                               g.roleString = (JSUserRoles) o1;
+                           else
+                            if (o1 instanceof JSUserAttributes)
+                                   g.userInfo  = (JSUserAttributes) o1;
+                                   else
+                                       if (o1 instanceof JSNVPElements)
+                                               g.preferences  = 
(JSNVPElements) o1;
+                                       else
+                                       if (o1 instanceof JSPrincipalRules)
+                                       g.rules  = (JSPrincipalRules) o1;
+                }
+                
+ 
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+
+    };
+
+
+    private String append(JSRole rule)
+    {
+        return rule.getName();
+    }
+
+    private String append(JSGroup group)
+    {
+        return group.getName();
+    }
+
+    private String append(Object s)
+    {
+        if (s instanceof JSRole) return append((JSRole) s);
+        if (s instanceof JSGroup) return append((JSGroup) s);
+
+        return s.toString();
+    }
+
+    private String putTokens(ArrayList _list)
+    {
+        if ((_list == null) || (_list.size() == 0)) return "";
+        boolean _start = true;
+        Iterator _it = _list.iterator();
+        StringBuffer _sb = new StringBuffer();
+        while (_it.hasNext())
+        {
+            if (!_start)
+                _sb.append(',');
+            else
+                _start = false;
+
+            _sb.append(append(_it.next()));
+        }
+        return _sb.toString();
+    }
+
+    private String getPasswordString()
+    {
+        if ((this.getPassword() == null) || (this.getPassword().length == 0))
+            return "";
+        else
+            return new String(this.getPassword());
+    }
+
+    /**
+     * @return Returns the rules.
+     */
+    public JSPrincipalRules getRules()
+    {
+        return rules;
+    }
+
+    /**
+     * @param rules
+     *            The rules to set.
+     */
+    public void setRules(JSPrincipalRules rules)
+    {
+        this.rules = rules;
+    }
+
+    /**
+     * @return Returns the principal.
+     */
+    public Principal getPrincipal()
+    {
+        return principal;
+    }
+
+    /**
+     * @param principal
+     *            The principal to set.
+     */
+    public void setPrincipal(Principal principal)
+    {
+        this.principal = principal;
+    }
+
+       public JSUserGroups getGroupString()
+       {
+               return groupString;
+       }
+
+       public JSUserRoles getRoleString()
+       {
+               return roleString;
+       }
+
+       public JSPWAttributes getPwData()
+       {
+               return pwData;
+       }
+
+       public void setPwData(JSPWAttributes pwData)
+       {
+               this.pwData = pwData;
+       }
+
 }

Modified: 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUserAttributes.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUserAttributes.java?view=diff&rev=505014&r1=505013&r2=505014
==============================================================================
--- 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUserAttributes.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSUserAttributes.java
 Thu Feb  8 11:31:01 2007
@@ -1,48 +1,48 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jetspeed.serializer.objects;
-
-/**
- * Serialized Name Value Pairs
- * <info>
- *   <name>user.first.name</name>
- *   <value>Paul</value>
- * </info>
- * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Hajo Birthelmer</a>
- * @version $Id: $
- */
-import java.util.HashMap;
-import java.util.Map;
-import java.util.prefs.*;
-
-public class JSUserAttributes extends JSNameValuePairs
-{
-
-
-       /**
-        * @param preferences
-        */
-       public JSUserAttributes(Preferences preferences)
-       {
-               super(preferences);
-       }
-    public JSUserAttributes()
-    {
-        super();
-    }
-}
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.serializer.objects;
+
+/**
+ * Serialized Name Value Pairs
+ * <info>
+ *   <name>user.first.name</name>
+ *   <value>Paul</value>
+ * </info>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Hajo Birthelmer</a>
+ * @version $Id: $
+ */
+import java.util.HashMap;
+import java.util.Map;
+import java.util.prefs.*;
+
+public class JSUserAttributes extends JSNVPElements
+{
+
+
+       /**
+        * @param preferences
+        */
+       public JSUserAttributes(Preferences preferences)
+       {
+               super(preferences);
+       }
+    public JSUserAttributes()
+    {
+        super();
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to