portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/users user-details.jsp
Date Thu, 03 Feb 2005 01:30:54 GMT
ate         2005/02/02 17:30:54

  Modified:    applications/security/src/java/org/apache/jetspeed/portlets/security/users
                        UserDetailsPortlet.java
               applications/security/src/webapp/WEB-INF/security/users
                        user-details.jsp
  Added:       applications/security/src/java/org/apache/jetspeed/portlets/security/resources
                        UsersResources.properties
                        UsersPwdResources_en.properties
                        UsersResources_nl.properties
  Log:
  Now displaying exception/error messages, for now only password validation errors are localized.
  
  Revision  Changes    Path
  1.3       +60 -6     jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
  
  Index: UserDetailsPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UserDetailsPortlet.java	22 Dec 2004 22:59:40 -0000	1.2
  +++ UserDetailsPortlet.java	3 Feb 2005 01:30:53 -0000	1.3
  @@ -16,12 +16,15 @@
   package org.apache.jetspeed.portlets.security.users;
   
   import java.io.IOException;
  +import java.io.NotSerializableException;
   import java.security.Principal;
  +import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.LinkedHashMap;
   import java.util.LinkedList;
   import java.util.List;
  +import java.util.ResourceBundle;
   import java.util.Set;
   import java.util.prefs.Preferences;
   
  @@ -29,6 +32,7 @@
   import javax.portlet.ActionResponse;
   import javax.portlet.PortletConfig;
   import javax.portlet.PortletException;
  +import javax.portlet.PortletRequest;
   import javax.portlet.PortletSession;
   import javax.portlet.RenderRequest;
   import javax.portlet.RenderResponse;
  @@ -41,6 +45,9 @@
   import org.apache.jetspeed.profiler.rules.PrincipalRule;
   import org.apache.jetspeed.security.Group;
   import org.apache.jetspeed.security.GroupManager;
  +import org.apache.jetspeed.security.InvalidNewPasswordException;
  +import org.apache.jetspeed.security.InvalidPasswordException;
  +import org.apache.jetspeed.security.PasswordAlreadyUsedException;
   import org.apache.jetspeed.security.PasswordCredential;
   import org.apache.jetspeed.security.Role;
   import org.apache.jetspeed.security.RoleManager;
  @@ -93,7 +100,9 @@
   
       /** the id of the groups control */
       private static final String GROUPS_CONTROL = "jetspeedGroups";
  -    
  +
  +    /** The Error Messages KEY */
  +    public static final String ERROR_MESSAGES = "errorMessages";
       
       private UserManager  userManager;
       private RoleManager  roleManager;
  @@ -270,6 +279,13 @@
              
               request.setAttribute(SecurityResources.REQUEST_SELECT_TAB, selectedTab);
           }
  +
  +        // check for ErrorMessages
  +        ArrayList errorMessages = (ArrayList)PortletMessaging.consume(request, ERROR_MESSAGES);
  +        if (errorMessages != null )
  +        {
  +            request.setAttribute(ERROR_MESSAGES,errorMessages);
  +        }
           
           super.doView(request, response);
       }
  @@ -336,7 +352,26 @@
                   updateUserCredential(actionRequest, actionResponse);
               }
           }
  -    }    
  +    }
  +    
  +    private void publishErrorMessage(PortletRequest request, String message)
  +    {
  +        try
  +        {
  +            ArrayList errors = (ArrayList)PortletMessaging.receive(request,ERROR_MESSAGES);
  +            if ( errors == null )
  +            {
  +                errors = new ArrayList();
  +            }
  +            errors.add(message);
  +            PortletMessaging.publish(request, ERROR_MESSAGES, errors);
  +        }
  +        catch (NotSerializableException e)
  +        {
  +            // TODO Auto-generated catch block
  +            e.printStackTrace();
  +        }                
  +    }
       
       public void removeUser(ActionRequest actionRequest, ActionResponse actionResponse)

       throws PortletException
  @@ -354,7 +389,7 @@
               }
               catch (Exception e)
               {
  -                
  +                publishErrorMessage(actionRequest,e.getMessage());
               }
           }
       }
  @@ -377,6 +412,8 @@
   
       private void updateUserCredential(ActionRequest actionRequest, ActionResponse actionResponse)
       {
  +        ResourceBundle bundle = ResourceBundle.getBundle("org.apache.jetspeed.portlets.security.resources.UsersResources",actionRequest.getLocale());
  +
           String userName = (String)
           actionRequest.getPortletSession().getAttribute(SecurityResources.PAM_CURRENT_USER,

                                PortletSession.APPLICATION_SCOPE);
  @@ -417,10 +454,21 @@
                       }
                   }
               }
  +            catch ( InvalidPasswordException ipe )
  +            {
  +                publishErrorMessage(actionRequest,bundle.getString("chgpwd.error.invalidPassword"));
  +            }
  +            catch ( InvalidNewPasswordException inpe )
  +            {
  +                publishErrorMessage(actionRequest,bundle.getString("chgpwd.error.invalidNewPassword"));
  +            }
  +            catch ( PasswordAlreadyUsedException paue )
  +            {
  +                publishErrorMessage(actionRequest,bundle.getString("chgpwd.error.passwordAlreadyUsed"));
  +            }
               catch (SecurityException e)
               {
  -                // TODO: logging
  -                System.err.println("failed to update user credential " + userName + ":
" + e);                                      
  +                publishErrorMessage(actionRequest,e.getMessage());
               }
           }
       }
  @@ -529,6 +577,7 @@
                       }
                       catch (SecurityException e)
                       {
  +                        publishErrorMessage(actionRequest,e.getMessage());
                           // TODO: logging
                           System.err.println("failed to remove user from role: " + userName
+ ", "  + roleNames[ix] + e);                       
                       }                
  @@ -555,6 +604,7 @@
                   }
                   catch (SecurityException e)
                   {
  +                    publishErrorMessage(actionRequest,e.getMessage());
                       // TODO: logging
                       System.err.println("failed to add user to role: " + userName + ", "
 + roleName + e);                       
                   }
  @@ -585,6 +635,7 @@
                       }
                       catch (SecurityException e)
                       {
  +                        publishErrorMessage(actionRequest,e.getMessage());
                           // TODO: logging
                           System.err.println("failed to remove user from group: " + userName
+ ", "  + groupNames[ix] + e);                       
                       }                
  @@ -611,6 +662,7 @@
                   }
                   catch (SecurityException e)
                   {
  +                    publishErrorMessage(actionRequest,e.getMessage());
                       // TODO: logging
                       System.err.println("failed to add user to group: " + userName + ",
"  + groupName + e);                       
                   }
  @@ -720,6 +772,7 @@
                   }
                   catch (Exception e)
                   {
  +                    publishErrorMessage(actionRequest,e.getMessage());
                       // TODO: logging
                       System.err.println("failed to set rule for principal: " + userName
+ ", "  + locatorName + e);                       
                   }
  @@ -758,6 +811,7 @@
                       }
                       catch (Exception e)
                       {
  +                        publishErrorMessage(actionRequest,e.getMessage());
                           // TODO: logging
                           System.err.println("failed to remove rule for principal: " + userName
+ ", "  + locatorNames[ix] + e);                       
                       }                
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/resources/UsersResources.properties
  
  Index: UsersResources.properties
  ===================================================================
  # Copyright 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.
  #
  # $Id: UsersResources.properties,v 1.1 2005/02/03 01:30:54 ate Exp $
  #
  
  ## change password
  chgpwd.error.invalidPassword=Current password invalid
  chgpwd.error.invalidNewPassword=Invalid new password
  chgpwd.error.passwordAlreadyUsed=Password already used
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/resources/UsersPwdResources_en.properties
  
  Index: UsersPwdResources_en.properties
  ===================================================================
  # Copyright 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.
  #
  # $Id: UsersPwdResources_en.properties,v 1.1 2005/02/03 01:30:54 ate Exp $
  #
  # LOCALIZATION MAINTAINER:
  #  Jetspeed Development Team
  
  ## change password
  chgpwd.error.invalidPassword=Current password invalid
  chgpwd.error.invalidNewPassword=Invalid new password
  chgpwd.error.passwordAlreadyUsed=Password already used
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/resources/UsersResources_nl.properties
  
  Index: UsersResources_nl.properties
  ===================================================================
  # Copyright 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.
  #
  # $Id: UsersResources_nl.properties,v 1.1 2005/02/03 01:30:54 ate Exp $
  #
  
  ## change password
  chgpwd.error.invalidPassword=Huidig wachtwoord ongeldig
  chgpwd.error.invalidNewPassword=Ongeldig nieuw wachtwoord
  chgpwd.error.passwordAlreadyUsed=Wachtwoord reeds eerder gebruikt
  
  
  
  1.7       +43 -0     jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/users/user-details.jsp
  
  Index: user-details.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/users/user-details.jsp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- user-details.jsp	11 Jan 2005 09:30:52 -0000	1.6
  +++ user-details.jsp	3 Feb 2005 01:30:54 -0000	1.7
  @@ -14,6 +14,7 @@
   <%@ page import="javax.portlet.*" %>
   <%@ page import="java.util.*" %>
   <%@ page import="org.apache.portals.bridges.beans.TabBean" %>
  +<%@ page import="org.apache.jetspeed.portlets.security.users.UserDetailsPortlet" %>
   <%@ page import="org.apache.jetspeed.portlets.security.users.JetspeedUserBean" %>
   <%@ page import="org.apache.jetspeed.om.common.preference.*" %>
   <%@ page import="org.apache.jetspeed.om.common.*" %>
  @@ -24,6 +25,8 @@
   
   <fmt:setBundle basename="org.apache.jetspeed.portlets.security.resources.SecurityResources"
/>
   
  +<c:set var="errorMessagesKey"><%=UserDetailsPortlet.ERROR_MESSAGES%></c:set>
  +<c:set var="errorMessages" value="${requestScope[errorMessagesKey]}"/>
   
   <portlet:defineObjects/>
   
  @@ -57,6 +60,14 @@
     <div id="attributes">	
     <portlet:actionURL var="edit_user_attr_link" />
     
  +  <c:if test="${errorMessages != null}">
  +    <ul>
  +    <c:forEach items="${errorMessages}" var="error">
  +      <li style="color:red"><c:out value="${error}"/></li>
  +    </c:forEach>
  +    </ul>
  +  </c:if>
  +
   	<form name="Edit_UserAttr_Form" action="<c:out value="${edit_user_attr_link}"/>"
method="post">
   		<input type="hidden" name="portlet_action" value="security_user.edit_user_attribute"/>
   		
  @@ -118,6 +129,14 @@
     <div id="Credential">
     <portlet:actionURL var="edit_credential_link" />
     
  +  <c:if test="${errorMessages != null}">
  +    <ul>
  +    <c:forEach items="${errorMessages}" var="error">
  +      <li style="color:red"><c:out value="${error}"/></li>
  +    </c:forEach>
  +    </ul>
  +  </c:if>
  +
     <form name="Edit_Credential_Form" action="<c:out value="${edit_credential_link}"/>"
method="post">
       <input type="hidden" name="portlet_action" value="security_user.update_user_credential"/>
   
       <table>
  @@ -194,6 +213,14 @@
     <div id="Role">
     <portlet:actionURL var="edit_role_link" />
     
  +  <c:if test="${errorMessages != null}">
  +    <ul>
  +    <c:forEach items="${errorMessages}" var="error">
  +      <li style="color:red"><c:out value="${error}"/></li>
  +    </c:forEach>
  +    </ul>
  +  </c:if>
  +
   	<form name="Edit_Role_Form" action="<c:out value="${edit_role_link}"/>" method="post">
   		<input type="hidden" name="portlet_action" value="security_user.edit_role"/>		
   		<table>
  @@ -246,6 +273,14 @@
     <div id="Group">
     <portlet:actionURL var="edit_group_link" />
     
  +  <c:if test="${errorMessages != null}">
  +    <ul>
  +    <c:forEach items="${errorMessages}" var="error">
  +      <li style="color:red"><c:out value="${error}"/></li>
  +    </c:forEach>
  +    </ul>
  +  </c:if>
  +
   	<form name="Edit_Group_Form" action="<c:out value="${edit_group_link}"/>" method="post">
   		<input type="hidden" name="portlet_action" value="security_user.edit_group"/>	

   		<table>
  @@ -299,6 +334,14 @@
     <div id="Profile">	
     <portlet:actionURL var="edit_profile_link" />
     
  +  <c:if test="${errorMessages != null}">
  +    <ul>
  +    <c:forEach items="${errorMessages}" var="error">
  +      <li style="color:red"><c:out value="${error}"/></li>
  +    </c:forEach>
  +    </ul>
  +  </c:if>
  +
   	<form name="Edit_Profile_Form" action="<c:out value="${edit_profile_link}"/>"
method="post">
   		<input type="hidden" name="portlet_action" value="security_user.remove_user_rule"/>
	
   		<table>
  
  
  

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


Mime
View raw message