You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/09/23 03:00:24 UTC

svn commit: r698052 - in /portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets: localeselector/ security/users/

Author: ate
Date: Mon Sep 22 18:00:23 2008
New Revision: 698052

URL: http://svn.apache.org/viewvc?rev=698052&view=rev
Log:
Synchronizing with latest j2 security refactoring changes

Modified:
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/localeselector/LocaleSelectorPortlet.java
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
    portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserDetails.java

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/localeselector/LocaleSelectorPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/localeselector/LocaleSelectorPortlet.java?rev=698052&r1=698051&r2=698052&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/localeselector/LocaleSelectorPortlet.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/localeselector/LocaleSelectorPortlet.java Mon Sep 22 18:00:23 2008
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.util.Locale;
-import java.util.prefs.Preferences;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -34,9 +33,6 @@
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.AttributeReadOnlyException;
-import org.apache.jetspeed.security.AttributesNotExtendableException;
-import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.SecurityAttributes;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
@@ -128,26 +124,11 @@
                     SecurityAttributes secAttrs = user.getSecurityAttributes();
                     secAttrs.getAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, true).setStringValue(JetspeedLocale.convertLocaleToString(preferedLocale));
                 }
-                catch (AttributesReadOnlyException e)
-                {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
                 catch (SecurityException e)
                 {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                 }
-                catch (AttributeReadOnlyException e)
-                {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
-                catch (AttributesNotExtendableException e)
-                {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
             }
 
             session.setAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, preferedLocale,

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java?rev=698052&r1=698051&r2=698052&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java Mon Sep 22 18:00:23 2008
@@ -58,10 +58,6 @@
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.profiler.rules.PrincipalRule;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.AttributeReadOnlyException;
-import org.apache.jetspeed.security.AttributeRequiredException;
-import org.apache.jetspeed.security.AttributesNotExtendableException;
-import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.InvalidNewPasswordException;
@@ -129,6 +125,8 @@
 	private static final String GROUPS_CONTROL = "jetspeedGroups";
 
 	public static final String USER_ADMINISTRATION = "J2 User Administration";
+	
+	private static final java.sql.Date MAX_DATE = java.sql.Date.valueOf("8099-01-01");
 
 	private PageManager pageManager;
 	private UserManager userManager;
@@ -737,13 +735,13 @@
 						{
 							//userManager.setPasswordExpiration(userName, null);
 							//TODO need to ask
-							credential.setExpirationDate(User.MAX_DATE);	
+							credential.setExpirationDate(MAX_DATE);	
 							audit.logAdminCredentialActivity(actionRequest.getUserPrincipal().getName(), getIPAddress(actionRequest), userName,
 									AuditActivity.PASSWORD_EXTEND, USER_ADMINISTRATION);
 						}
 						else if (expiredFlagStr.equals("unlimited"))
 						{
-							credential.setExpirationDate(User.MAX_DATE);							
+							credential.setExpirationDate(MAX_DATE);							
 							audit.logAdminCredentialActivity(actionRequest.getUserPrincipal().getName(), getIPAddress(actionRequest), userName,
 									AuditActivity.PASSWORD_UNLIMITED, USER_ADMINISTRATION);
 						}
@@ -792,21 +790,10 @@
 	                    audit.logAdminAttributeActivity(actionRequest.getUserPrincipal().getName(), getIPAddress(actionRequest), userName,
 	                            AuditActivity.USER_ADD_ATTRIBUTE, attr.getName(), value, value, USER_ADMINISTRATION);
 					}
-					catch (AttributesReadOnlyException aroe)
-					{
-						SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes read only");
-						return;
-					}
-					catch (AttributesNotExtendableException e)
-					{
-						SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes not extendable");
-                        return;
-					}
-                    catch (AttributeReadOnlyException e)
-                    {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attribute read only");
-                        return;
-                    }
+	                catch (SecurityException e)
+	                {
+	                    SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER, e.getMessage());
+	                }
 				}
 			}
 			try
@@ -852,20 +839,9 @@
                         audit.logAdminAttributeActivity(actionRequest.getUserPrincipal().getName(), getIPAddress(actionRequest), userName,
                                 AuditActivity.USER_UPDATE_ATTRIBUTE, userAttrName, before, value, USER_ADMINISTRATION);
                     }
-                    catch (AttributeReadOnlyException e)
-                    {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attribute read only");
-                        return;
-                    }
-                    catch (AttributesReadOnlyException e)
-                    {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes read only");
-                        return;
-                    }
-                    catch (AttributesNotExtendableException e)
+                    catch (SecurityException e)
                     {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes not extendable");
-                        return;
+                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER, e.getMessage());
                     }
                 }
                 try
@@ -901,18 +877,6 @@
                 {
                     SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER, e.getMessage());
                 }
-                catch (AttributeReadOnlyException e)
-                {
-                    SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attribute read only");
-                }
-                catch (AttributesReadOnlyException e)
-                {
-                    SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes read only");
-                }
-                catch (AttributesNotExtendableException e)
-                {
-                    SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes not extendable");
-                }
 			}
 		}
 	}
@@ -944,25 +908,9 @@
                                 AuditActivity.USER_DELETE_ATTRIBUTE, userAttrNames[ix], attr.getStringValue(), "", USER_ADMINISTRATION);
                         }
                     }
-                    catch (AttributeReadOnlyException e)
-                    {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attribute read only");
-                        return;
-                    }
-                    catch (AttributesReadOnlyException e)
-                    {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes read only");
-                        return;
-                    }
-                    catch (AttributesNotExtendableException e)
-                    {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attributes not extendable");
-                        return;
-                    }
-                    catch (AttributeRequiredException e)
+                    catch (SecurityException e)
                     {
-                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER,"Attribute is required");
-                        return;
+                        SecurityUtil.publishErrorMessage(actionRequest, SecurityResources.TOPIC_USER, e.getMessage());
                     }
 				}
 	            if (save)

Modified: portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserDetails.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserDetails.java?rev=698052&r1=698051&r2=698052&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserDetails.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/security-refactoring/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserDetails.java Mon Sep 22 18:00:23 2008
@@ -39,10 +39,6 @@
 import org.apache.jetspeed.portlets.wicket.component.TextFieldPropertyColumn;
 import org.apache.jetspeed.profiler.rules.PrincipalRule;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
-import org.apache.jetspeed.security.AttributeReadOnlyException;
-import org.apache.jetspeed.security.AttributeRequiredException;
-import org.apache.jetspeed.security.AttributesNotExtendableException;
-import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.InvalidNewPasswordException;
 import org.apache.jetspeed.security.InvalidPasswordException;
@@ -85,7 +81,7 @@
  */
 public class WicketUserDetails extends WicketUserAdmin
 {
-
+    private static final java.sql.Date MAX_DATE = java.sql.Date.valueOf("8099-01-01");
     protected transient String userName;
     protected transient Principal userPrincipal;
     protected transient User user;
@@ -388,21 +384,7 @@
                                     getAuditActivity().logAdminAttributeActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(), getUserName(), AuditActivity.USER_DELETE_ATTRIBUTE, userAttrName, userAttrValue, "", USER_ADMINISTRATION);
                                     save = true;
                                 }
-                                catch (AttributesReadOnlyException e)
-                                {
-                                    // TODO Auto-generated catch block
-                                    e.printStackTrace();
-                                    save = false;
-                                    break;
-                                }
-                                catch (AttributeReadOnlyException e)
-                                {
-                                    // TODO Auto-generated catch block
-                                    e.printStackTrace();
-                                    save = false;
-                                    break;
-                                }
-                                catch (AttributeRequiredException e)
+                                catch (SecurityException e)
                                 {
                                     // TODO Auto-generated catch block
                                     e.printStackTrace();
@@ -450,21 +432,6 @@
 							getUserManager().updateUser(user);
 	                        getAuditActivity().logAdminAttributeActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(), getUserName(), AuditActivity.USER_ADD_ATTRIBUTE, userAttrName, "", userAttrValue, USER_ADMINISTRATION);                                                
 						}
-						catch (AttributesReadOnlyException e)
-						{
-							// TODO Auto-generated catch block
-							e.printStackTrace();
-						}
-						catch (AttributesNotExtendableException e)
-						{
-							// TODO Auto-generated catch block
-							e.printStackTrace();
-						}
-                        catch (AttributeReadOnlyException e)
-                        {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        }
                         catch (SecurityException e)
                         {
                             // TODO Auto-generated catch block
@@ -616,13 +583,13 @@
                             {
                                 //getUserManager().setPasswordExpiration(getUserName(), null);
                             	//TODO confirm with Ate/David
-                            	credential.setExpirationDate(User.MAX_DATE);
+                            	credential.setExpirationDate(MAX_DATE);
                                 getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(), getUserName(), AuditActivity.PASSWORD_EXTEND, USER_ADMINISTRATION);
                             }
                             else if (expiredFlagStr.equals("unlimited"))
                             {
                                 //getUserManager().setPasswordExpiration(getUserName(), User.MAX_DATE);
-                            	credential.setExpirationDate(User.MAX_DATE);
+                            	credential.setExpirationDate(MAX_DATE);
                                 getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(), getUserName(), AuditActivity.PASSWORD_UNLIMITED, USER_ADMINISTRATION);
                             }
                         }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org