dcwaterm / pwm

Automatically exported from code.google.com/p/pwm
0 stars 0 forks source link

Guest User Update Guest Form display failure #673

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enable Guest registration
2. Create Guest user
3. Update Guest User (Search for guest user)

What is the expected output? What do you see instead?
Form (default or change should be displayed)

instead it shows

[ form definition is not available ]

What version of PWM are you using?

1.8.0 (current trunk)

What ldap directory and version are you using?

openDJ 2.6.0

Please paste any error log messages below:

Does not display log messages, it seems the got in 
GuestRegistrationServlet.java does not set the form when the search is 
successful and as such there is no form to for the form.jsp to extract and use.

Original issue reported on code.google.com by will.d...@gmail.com on 27 Mar 2015 at 4:05

GoogleCodeExporter commented 9 years ago
I've come up with a solution to this, it seems the form data loading has 
changed and the GuestRegistrationServlet has not been updated to continue. 
Below is the svn diff to fix it. (also included some java 6 type warning fixes)

Index: src/password/pwm/http/PwmRequest.java
===================================================================
--- src/password/pwm/http/PwmRequest.java   (revision 765)
+++ src/password/pwm/http/PwmRequest.java   (working copy)
@@ -569,9 +569,9 @@
             final boolean readOnly,
             final boolean showPasswordFields
     ) {
-        final LinkedHashMap<FormConfiguration,String> formDataMapValue = 
formDataMap == null 
+        final LinkedHashMap<FormConfiguration,String> formDataMapValue = ( 
formDataMap == null )
                 ? new LinkedHashMap<FormConfiguration,String>() 
-                : new LinkedHashMap<>(formDataMap);
+                : new LinkedHashMap<FormConfiguration,String>(formDataMap);

         this.setAttribute(PwmConstants.REQUEST_ATTR.FormConfiguration, new ArrayList<>(formConfiguration));
         this.setAttribute(PwmConstants.REQUEST_ATTR.FormData, formDataMapValue);
Index: src/password/pwm/http/servlet/GuestRegistrationServlet.java
===================================================================
--- src/password/pwm/http/servlet/GuestRegistrationServlet.java (revision 765)
+++ src/password/pwm/http/servlet/GuestRegistrationServlet.java (working copy)
@@ -287,7 +287,7 @@
             final FormMap formProps = guBean.getFormValues();
             try {
                 final List<FormConfiguration> guestUpdateForm = config.readSettingAsForm(PwmSetting.GUEST_UPDATE_FORM);
-                final Set<String> involvedAttrs = new HashSet<>();
+                final Set<String> involvedAttrs = new HashSet<String>();
                 for (final FormConfiguration formItem : guestUpdateForm) {
                     if (!formItem.getName().equalsIgnoreCase(HTTP_PARAM_EXPIRATION_DATE)) {
                         involvedAttrs.add(formItem.getName());
@@ -296,7 +296,7 @@
                 final UserDataReader userDataReader = LdapUserDataReader.selfProxiedReader(pwmApplication, pwmSession,
                         theGuest);
                 final Map<String,String> userAttrValues = userDataReader.readStringAttributes(involvedAttrs);
-                if (origAdminOnly && adminDnAttribute != null && 
adminDnAttribute.length() > 0) {
+                if (origAdminOnly && (adminDnAttribute != null) && 
adminDnAttribute.length() > 0) {
                     final String origAdminDn = userAttrValues.get(adminDnAttribute);
                     if (origAdminDn != null && origAdminDn.length() > 0) {
                         if (!pwmSession.getUserInfoBean().getUserIdentity().getUserDN().equalsIgnoreCase(origAdminDn)) {
@@ -315,16 +315,19 @@
                     }
                 }

+                final Map<FormConfiguration, String> formData = new 
HashMap<FormConfiguration, String>();
                 for (final FormConfiguration formItem : guestUpdateForm) {
                     final String key = formItem.getName();
                     final String value = userAttrValues.get(key);
                     if (value != null) {
                         formProps.put(key, value);
+                        formData.put(formItem, value);
                     }
                 }

                 guBean.setUpdateUserIdentity(theGuest);

+                pwmRequest.addFormInfoToRequestAttr(guestUpdateForm, formData, 
false, false);
                 pwmRequest.forwardToJsp(PwmConstants.JSP_URL.GUEST_UPDATE);
                 return;
             } catch (ChaiOperationException e) {

Original comment by will.d...@gmail.com on 29 Mar 2015 at 11:49