diff --git a/ccm-core/src/com/arsdigita/ui/admin/UserAddForm.java b/ccm-core/src/com/arsdigita/ui/admin/UserAddForm.java index 1ebe2091b..db0dab3e4 100755 --- a/ccm-core/src/com/arsdigita/ui/admin/UserAddForm.java +++ b/ccm-core/src/com/arsdigita/ui/admin/UserAddForm.java @@ -125,6 +125,8 @@ class UserAddForm extends UserForm auth.setPasswordAnswer((String) m_answer.getValue(state)); } auth.save(); + + auth.setSSOlogin((String) m_ssoLogin.getValue(state)); // Switch to browse tab. m_adminPanel.setTab(USER_TAB_BROWSE_INDEX, state); diff --git a/ccm-core/src/com/arsdigita/ui/admin/UserCreateSection.java b/ccm-core/src/com/arsdigita/ui/admin/UserCreateSection.java index 8a0f0305b..1629a898c 100644 --- a/ccm-core/src/com/arsdigita/ui/admin/UserCreateSection.java +++ b/ccm-core/src/com/arsdigita/ui/admin/UserCreateSection.java @@ -118,6 +118,8 @@ class UserCreateSection extends UserForm implements AdminConstants, Resettable { // Save user authentication credentials. final UserAuthentication auth = UserAuthentication.createForUser(user); + auth.setSSOlogin((String) m_ssoLogin.getValue(state)); + auth.setPassword((String) m_password.getValue(state)); if (securityConfig.getEnableQuestion()) { auth.setPasswordQuestion((String) m_question.getValue(state)); diff --git a/ccm-core/src/com/arsdigita/ui/admin/UserEditForm.java b/ccm-core/src/com/arsdigita/ui/admin/UserEditForm.java index 4c9d596d4..e69d9bb22 100755 --- a/ccm-core/src/com/arsdigita/ui/admin/UserEditForm.java +++ b/ccm-core/src/com/arsdigita/ui/admin/UserEditForm.java @@ -25,6 +25,7 @@ import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.kernel.EmailAddress; import com.arsdigita.kernel.PersonName; +import com.arsdigita.kernel.UserAuthentication; import com.arsdigita.kernel.User; import javax.mail.internet.InternetAddress; import org.apache.log4j.Logger; @@ -81,6 +82,9 @@ class UserEditForm extends UserForm } m_screenName.setValue(state, user.getScreenName()); + + final UserAuthentication auth = UserAuthentication.retrieveForUser(user); + m_ssoLogin.setValue(state, auth.getSSOlogin()); USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST.setVisible(state, true); m_emailList.setVisible(state, true); @@ -139,6 +143,10 @@ class UserEditForm extends UserForm user.save(); + final UserAuthentication auth = UserAuthentication.retrieveForUser(user); + auth.setSSOlogin((String) m_ssoLogin.getValue(state)); + auth.save(); + m_browsePane.displayUserInfoPanel(state); } } diff --git a/ccm-core/src/com/arsdigita/ui/admin/UserForm.java b/ccm-core/src/com/arsdigita/ui/admin/UserForm.java index d06f195ce..b7de5ea21 100755 --- a/ccm-core/src/com/arsdigita/ui/admin/UserForm.java +++ b/ccm-core/src/com/arsdigita/ui/admin/UserForm.java @@ -65,6 +65,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { protected TextField m_url; protected TextField m_screenName; protected EmailList m_emailList; + protected TextField m_ssoLogin; private final PasswordValidationListener m_pwListener; private final NotEmptyValidationListener m_notNullListener; private final SecurityConfig securityConfig = SecurityConfig.getConfig(); @@ -77,31 +78,30 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { addValidationListener(this); - // Bug #163373 add length checking for first/last names. We // do this with both maximum length parameters in the user/add // form and with validation of the value that come in for // processing. - int max = 60; m_firstName = new TextField( - new StringParameter(USER_FORM_INPUT_FIRST_NAME)); + new StringParameter(USER_FORM_INPUT_FIRST_NAME)); m_firstName.setMaxLength(max); m_firstName.setSize(20); m_firstName.addValidationListener(new NotEmptyValidationListener()); m_firstName.addValidationListener( - new StringLengthValidationListener(max)); + new StringLengthValidationListener(max)); add(USER_FORM_LABEL_FIRST_NAME); add(m_firstName); m_lastName = new TextField( - new StringParameter(USER_FORM_INPUT_LAST_NAME)); + new StringParameter(USER_FORM_INPUT_LAST_NAME)); m_lastName.setMaxLength(max); m_lastName.setSize(25); m_lastName.addValidationListener(new NotEmptyValidationListener()); - m_lastName.addValidationListener(new StringLengthValidationListener(max)); + m_lastName + .addValidationListener(new StringLengthValidationListener(max)); add(USER_FORM_LABEL_LAST_NAME); add(m_lastName); @@ -113,14 +113,14 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { // Password confirmation m_confirmPassword = new Password(new StringParameter( - USER_FORM_INPUT_PASSWORD_CONFIRMATION)); + USER_FORM_INPUT_PASSWORD_CONFIRMATION)); add(USER_FORM_LABEL_PASSWORD_CONFIRMATION); add(m_confirmPassword); // Password question - m_question = - new TextField(new StringParameter(USER_FORM_INPUT_QUESTION)); + m_question + = new TextField(new StringParameter(USER_FORM_INPUT_QUESTION)); m_question.setSize(50); if (securityConfig.getEnableQuestion()) { @@ -139,7 +139,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { // Primary email address m_primaryEmail = new TextField(new EmailParameter( - USER_FORM_INPUT_PRIMARY_EMAIL)); + USER_FORM_INPUT_PRIMARY_EMAIL)); m_primaryEmail.addValidationListener(new NotEmptyValidationListener()); m_primaryEmail.setSize(50); add(USER_FORM_LABEL_PRIMARY_EMAIL); @@ -151,20 +151,25 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { add(m_emailList); m_additionalEmail = new TextField(new EmailParameter( - USER_FORM_INPUT_ADDITIONAL_EMAIL)); + USER_FORM_INPUT_ADDITIONAL_EMAIL)); m_additionalEmail.setSize(50); add(USER_FORM_LABEL_ADDITIONAL_EMAIL); add(m_additionalEmail); // Screen name m_screenName = new TextField(new StringParameter( - USER_FORM_INPUT_SCREEN_NAME)); + USER_FORM_INPUT_SCREEN_NAME)); if (Kernel.getConfig().screenNameIsPrimaryIdentifier()) { m_screenName.addValidationListener(new NotEmptyValidationListener()); } add(USER_FORM_LABEL_SCREEN_NAME); add(m_screenName); + m_ssoLogin = new TextField(new StringParameter(USER_FORM_INPUT_SSO)); + m_ssoLogin.setSize(50); + add(USER_FORM_LABEL_SSO); + add(m_ssoLogin); + // URL m_url = new TextField(new URLParameter(USER_FORM_INPUT_URL)); m_url.setSize(50); @@ -179,14 +184,14 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { } /** - * Validate the form. Verifies that the password and - * password-confirm fields match. If not it adds an error to the - * password-confirm field. Also verifies that primary email - * address and screen name are unique amoung all users. + * Validate the form. Verifies that the password and password-confirm fields + * match. If not it adds an error to the password-confirm field. Also + * verifies that primary email address and screen name are unique amoung all + * users. */ @Override public void validate(FormSectionEvent event) - throws FormProcessException { + throws FormProcessException { PageState ps = event.getPageState(); FormData data = event.getFormData(); HttpServletRequest req = ps.getRequest(); @@ -200,22 +205,22 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { if (userID == null) { m_pwListener.validate( - new ParameterEvent(event.getSource(), - data.getParameter( - USER_FORM_INPUT_PASSWORD))); + new ParameterEvent(event.getSource(), + data.getParameter( + USER_FORM_INPUT_PASSWORD))); m_notNullListener.validate( - new ParameterEvent(event.getSource(), - data.getParameter( - USER_FORM_INPUT_PASSWORD_CONFIRMATION))); + new ParameterEvent(event.getSource(), + data.getParameter( + USER_FORM_INPUT_PASSWORD_CONFIRMATION))); String password = (String) m_password.getValue(ps); String confirm = (String) m_confirmPassword.getValue(ps); if (!StringUtils.emptyString(password) && !StringUtils.emptyString( - confirm)) { + confirm)) { if (!password.equals(confirm)) { data.addError(USER_FORM_INPUT_PASSWORD_CONFIRMATION, (String) USER_FORM_ERROR_PASSWORD_NOT_MATCH. - localize(req)); + localize(req)); } } } @@ -229,16 +234,16 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { if (answer == null || answer.trim().length() == 0) { data.addError(USER_FORM_INPUT_ANSWER, (String) USER_FORM_ERROR_ANSWER_NULL.localize( - req)); + req)); } } else { // Check for edit form if (answer != null && answer.length() > 0 && answer.trim(). - length() - == 0) { + length() + == 0) { data.addError(USER_FORM_INPUT_ANSWER, (String) USER_FORM_ERROR_ANSWER_NULL.localize( - req)); + req)); } } } @@ -247,7 +252,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { * Verify that primary email and screen name are unique */ DataQuery query = SessionManager.getSession().retrieveQuery( - "com.arsdigita.kernel.RetrieveUsers"); + "com.arsdigita.kernel.RetrieveUsers"); query.setParameter("excludeGroupId", new BigDecimal(0)); String email = null; @@ -258,7 +263,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { String screenName = (String) m_screenName.getValue(ps); Filter filter = query.addFilter( - "primaryEmail = :email or screenName = :sn"); + "primaryEmail = :email or screenName = :sn"); filter.set("email", email); filter.set("sn", screenName); @@ -268,21 +273,21 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { } /** - * If this query returns with any rows we have a duplicate - * screen name, email address, or both. Check the results and - * produce appropriate error messages. + * If this query returns with any rows we have a duplicate screen name, + * email address, or both. Check the results and produce appropriate + * error messages. */ while (query.next()) { if (screenName != null && screenName.equals(query.get("screenName"))) { data.addError(USER_FORM_INPUT_SCREEN_NAME, (String) USER_FORM_ERROR_SCREEN_NAME_NOT_UNIQUE. - localize(req)); + localize(req)); } if (email != null && email.equals(query.get("primaryEmail"))) { data.addError(USER_FORM_INPUT_PRIMARY_EMAIL, (String) USER_FORM_ERROR_PRIMARY_EMAIL_NOT_UNIQUE. - localize(req)); + localize(req)); } } @@ -319,4 +324,5 @@ class UserForm extends Form implements FormValidationListener, AdminConstants { m_answer.setVisible(state, isVisible); } } + } diff --git a/ccm-core/src/com/arsdigita/ui/login/UserEditForm.java b/ccm-core/src/com/arsdigita/ui/login/UserEditForm.java index acb1f7f80..f80b932ab 100755 --- a/ccm-core/src/com/arsdigita/ui/login/UserEditForm.java +++ b/ccm-core/src/com/arsdigita/ui/login/UserEditForm.java @@ -37,40 +37,42 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.form.Hidden; import com.arsdigita.bebop.parameters.URLParameter; import com.arsdigita.util.UncheckedWrapperException; +import com.arsdigita.kernel.UserAuthentication; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; /** - * Edits a user. If returnURL is passed in to the form, then redirects to - * that URL; otherwise redirects to the user workspace. + * Edits a user. If returnURL is passed in to the form, then redirects to that + * URL; otherwise redirects to the user workspace. * * * @author Sameer Ajmani * * @version $Id: UserEditForm.java 738 2005-09-01 12:36:52Z sskracic $ * - **/ + * + */ public class UserEditForm extends UserForm - implements FormProcessListener -{ + implements FormProcessListener { - private static final Logger s_log = - Logger.getLogger(UserEditForm.class); + private static final Logger s_log = Logger.getLogger(UserEditForm.class); - private UserAuthenticationListener m_listener = - new UserAuthenticationListener(); + private UserAuthenticationListener m_listener + = new UserAuthenticationListener(); private Hidden m_returnURL; private RequestLocal m_user = new RequestLocal() { - public Object initialValue(PageState ps) { - User result; - try { - result = User.retrieve(m_listener.getUser(ps).getOID()); - } catch (DataObjectNotFoundException e) { - result = null; - } - return result; + + public Object initialValue(PageState ps) { + User result; + try { + result = User.retrieve(m_listener.getUser(ps).getOID()); + } catch (DataObjectNotFoundException e) { + result = null; } - }; + return result; + } + + }; public UserEditForm() { super("user-edit", new ColumnPanel(2), false); @@ -78,8 +80,8 @@ public class UserEditForm extends UserForm addProcessListener(this); // export return URL - m_returnURL = new Hidden(new URLParameter - (LoginHelper.RETURN_URL_PARAM_NAME)); + m_returnURL = new Hidden(new URLParameter( + LoginHelper.RETURN_URL_PARAM_NAME)); m_returnURL.setPassIn(true); add(m_returnURL); } @@ -96,7 +98,7 @@ public class UserEditForm extends UserForm public void process(FormSectionEvent event) throws FormProcessException { - FormData data = event.getFormData(); + FormData data = event.getFormData(); PageState state = event.getPageState(); User user; @@ -120,15 +122,13 @@ public class UserEditForm extends UserForm // user.addEmailAddress // (new EmailAddress(additional.getAddress())); //} - // Bug #166274: Unexpected behavior when editing // primary email. // // Check to see if the primary email address has - // changed, and if so set it to the new value and + // changed, and if so set it to the new value and // delete the association with the old. If it // hasn't change don't do anything. - EmailAddress oaddr = user.getPrimaryEmail(); EmailAddress naddr = new EmailAddress(data.get(FORM_EMAIL).toString()); if (!oaddr.equals(naddr)) { @@ -139,8 +139,11 @@ public class UserEditForm extends UserForm user.save(); - // redirect to workspace or return URL, if specified + final UserAuthentication auth = UserAuthentication.retrieveForUser(user); + auth.setSSOlogin((String) m_ssoLogin.getValue(state)); + auth.save(); + // redirect to workspace or return URL, if specified final HttpServletRequest req = state.getRequest(); // final String path = LegacyInitializer.getFullURL @@ -151,4 +154,5 @@ public class UserEditForm extends UserForm throw new ReturnSignal(req, fallback); } + } diff --git a/ccm-core/src/com/arsdigita/ui/login/UserForm.java b/ccm-core/src/com/arsdigita/ui/login/UserForm.java index 00368830a..e5527aea1 100755 --- a/ccm-core/src/com/arsdigita/ui/login/UserForm.java +++ b/ccm-core/src/com/arsdigita/ui/login/UserForm.java @@ -75,6 +75,7 @@ public abstract class UserForm extends Form protected TextField m_question; protected TextField m_answer; protected TextField m_url; + protected TextField m_ssoLogin; protected Label m_securitySectionHeader = new Label(LoginHelper .getMessage("login.userNewForm.securitySectionHeader"), false); diff --git a/ccm-core/src/com/arsdigita/ui/login/UserNewForm.java b/ccm-core/src/com/arsdigita/ui/login/UserNewForm.java index f281e1d11..f7250267a 100755 --- a/ccm-core/src/com/arsdigita/ui/login/UserNewForm.java +++ b/ccm-core/src/com/arsdigita/ui/login/UserNewForm.java @@ -144,6 +144,7 @@ public class UserNewForm extends UserForm final String answer = (String)m_answer.getValue(state); final String firstName = (String)m_firstName.getValue(state); final String lastName = (String)m_lastName.getValue(state); + final String ssoLogin = (String) m_ssoLogin.getValue(state); String sn = null; if (!Kernel.getConfig().emailIsPrimaryIdentifier()) { sn = (String)m_screenName.getValue(state); @@ -183,6 +184,7 @@ public class UserNewForm extends UserForm auth.setPassword(password); auth.setPasswordQuestion(question); auth.setPasswordAnswer(answer); + auth.setSSOlogin(ssoLogin); auth.save(); } catch (PersistenceException e) { // problem with creating new User or retrieving