SSOLogin can now be set in UserEditForms

git-svn-id: https://svn.libreccm.org/ccm/trunk@6198 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2019-09-12 17:48:02 +00:00
parent cc70b41ada
commit 042e4006e2
7 changed files with 86 additions and 61 deletions

View File

@ -126,6 +126,8 @@ class UserAddForm extends UserForm
} }
auth.save(); auth.save();
auth.setSSOlogin((String) m_ssoLogin.getValue(state));
// Switch to browse tab. // Switch to browse tab.
m_adminPanel.setTab(USER_TAB_BROWSE_INDEX, state); m_adminPanel.setTab(USER_TAB_BROWSE_INDEX, state);
} }

View File

@ -118,6 +118,8 @@ class UserCreateSection extends UserForm implements AdminConstants, Resettable {
// Save user authentication credentials. // Save user authentication credentials.
final UserAuthentication auth = UserAuthentication.createForUser(user); final UserAuthentication auth = UserAuthentication.createForUser(user);
auth.setSSOlogin((String) m_ssoLogin.getValue(state));
auth.setPassword((String) m_password.getValue(state)); auth.setPassword((String) m_password.getValue(state));
if (securityConfig.getEnableQuestion()) { if (securityConfig.getEnableQuestion()) {
auth.setPasswordQuestion((String) m_question.getValue(state)); auth.setPasswordQuestion((String) m_question.getValue(state));

View File

@ -25,6 +25,7 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.kernel.EmailAddress; import com.arsdigita.kernel.EmailAddress;
import com.arsdigita.kernel.PersonName; import com.arsdigita.kernel.PersonName;
import com.arsdigita.kernel.UserAuthentication;
import com.arsdigita.kernel.User; import com.arsdigita.kernel.User;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -82,6 +83,9 @@ class UserEditForm extends UserForm
m_screenName.setValue(state, user.getScreenName()); 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); USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST.setVisible(state, true);
m_emailList.setVisible(state, true); m_emailList.setVisible(state, true);
} }
@ -139,6 +143,10 @@ class UserEditForm extends UserForm
user.save(); user.save();
final UserAuthentication auth = UserAuthentication.retrieveForUser(user);
auth.setSSOlogin((String) m_ssoLogin.getValue(state));
auth.save();
m_browsePane.displayUserInfoPanel(state); m_browsePane.displayUserInfoPanel(state);
} }
} }

View File

@ -65,6 +65,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
protected TextField m_url; protected TextField m_url;
protected TextField m_screenName; protected TextField m_screenName;
protected EmailList m_emailList; protected EmailList m_emailList;
protected TextField m_ssoLogin;
private final PasswordValidationListener m_pwListener; private final PasswordValidationListener m_pwListener;
private final NotEmptyValidationListener m_notNullListener; private final NotEmptyValidationListener m_notNullListener;
private final SecurityConfig securityConfig = SecurityConfig.getConfig(); private final SecurityConfig securityConfig = SecurityConfig.getConfig();
@ -77,12 +78,10 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
addValidationListener(this); addValidationListener(this);
// Bug #163373 add length checking for first/last names. We // Bug #163373 add length checking for first/last names. We
// do this with both maximum length parameters in the user/add // do this with both maximum length parameters in the user/add
// form and with validation of the value that come in for // form and with validation of the value that come in for
// processing. // processing.
int max = 60; int max = 60;
m_firstName = new TextField( m_firstName = new TextField(
@ -101,7 +100,8 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
m_lastName.setMaxLength(max); m_lastName.setMaxLength(max);
m_lastName.setSize(25); m_lastName.setSize(25);
m_lastName.addValidationListener(new NotEmptyValidationListener()); m_lastName.addValidationListener(new NotEmptyValidationListener());
m_lastName.addValidationListener(new StringLengthValidationListener(max)); m_lastName
.addValidationListener(new StringLengthValidationListener(max));
add(USER_FORM_LABEL_LAST_NAME); add(USER_FORM_LABEL_LAST_NAME);
add(m_lastName); add(m_lastName);
@ -119,8 +119,8 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
add(m_confirmPassword); add(m_confirmPassword);
// Password question // Password question
m_question = m_question
new TextField(new StringParameter(USER_FORM_INPUT_QUESTION)); = new TextField(new StringParameter(USER_FORM_INPUT_QUESTION));
m_question.setSize(50); m_question.setSize(50);
if (securityConfig.getEnableQuestion()) { if (securityConfig.getEnableQuestion()) {
@ -165,6 +165,11 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
add(USER_FORM_LABEL_SCREEN_NAME); add(USER_FORM_LABEL_SCREEN_NAME);
add(m_screenName); 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 // URL
m_url = new TextField(new URLParameter(USER_FORM_INPUT_URL)); m_url = new TextField(new URLParameter(USER_FORM_INPUT_URL));
m_url.setSize(50); m_url.setSize(50);
@ -179,10 +184,10 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
} }
/** /**
* Validate the form. Verifies that the password and * Validate the form. Verifies that the password and password-confirm fields
* password-confirm fields match. If not it adds an error to the * match. If not it adds an error to the password-confirm field. Also
* password-confirm field. Also verifies that primary email * verifies that primary email address and screen name are unique amoung all
* address and screen name are unique amoung all users. * users.
*/ */
@Override @Override
public void validate(FormSectionEvent event) public void validate(FormSectionEvent event)
@ -268,9 +273,9 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
} }
/** /**
* If this query returns with any rows we have a duplicate * If this query returns with any rows we have a duplicate screen name,
* screen name, email address, or both. Check the results and * email address, or both. Check the results and produce appropriate
* produce appropriate error messages. * error messages.
*/ */
while (query.next()) { while (query.next()) {
if (screenName != null && screenName.equals(query.get("screenName"))) { if (screenName != null && screenName.equals(query.get("screenName"))) {
@ -319,4 +324,5 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
m_answer.setVisible(state, isVisible); m_answer.setVisible(state, isVisible);
} }
} }
} }

View File

@ -37,30 +37,31 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Hidden; import com.arsdigita.bebop.form.Hidden;
import com.arsdigita.bebop.parameters.URLParameter; import com.arsdigita.bebop.parameters.URLParameter;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.kernel.UserAuthentication;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Edits a user. If returnURL is passed in to the form, then redirects to * Edits a user. If returnURL is passed in to the form, then redirects to that
* that URL; otherwise redirects to the user workspace. * URL; otherwise redirects to the user workspace.
* *
* *
* @author Sameer Ajmani * @author Sameer Ajmani
* *
* @version $Id: UserEditForm.java 738 2005-09-01 12:36:52Z sskracic $ * @version $Id: UserEditForm.java 738 2005-09-01 12:36:52Z sskracic $
* *
**/ *
*/
public class UserEditForm extends UserForm public class UserEditForm extends UserForm
implements FormProcessListener implements FormProcessListener {
{
private static final Logger s_log = private static final Logger s_log = Logger.getLogger(UserEditForm.class);
Logger.getLogger(UserEditForm.class);
private UserAuthenticationListener m_listener = private UserAuthenticationListener m_listener
new UserAuthenticationListener(); = new UserAuthenticationListener();
private Hidden m_returnURL; private Hidden m_returnURL;
private RequestLocal m_user = new RequestLocal() { private RequestLocal m_user = new RequestLocal() {
public Object initialValue(PageState ps) { public Object initialValue(PageState ps) {
User result; User result;
try { try {
@ -70,6 +71,7 @@ public class UserEditForm extends UserForm
} }
return result; return result;
} }
}; };
public UserEditForm() { public UserEditForm() {
@ -78,8 +80,8 @@ public class UserEditForm extends UserForm
addProcessListener(this); addProcessListener(this);
// export return URL // export return URL
m_returnURL = new Hidden(new URLParameter m_returnURL = new Hidden(new URLParameter(
(LoginHelper.RETURN_URL_PARAM_NAME)); LoginHelper.RETURN_URL_PARAM_NAME));
m_returnURL.setPassIn(true); m_returnURL.setPassIn(true);
add(m_returnURL); add(m_returnURL);
} }
@ -120,7 +122,6 @@ public class UserEditForm extends UserForm
// user.addEmailAddress // user.addEmailAddress
// (new EmailAddress(additional.getAddress())); // (new EmailAddress(additional.getAddress()));
//} //}
// Bug #166274: Unexpected behavior when editing // Bug #166274: Unexpected behavior when editing
// primary email. // primary email.
// //
@ -128,7 +129,6 @@ public class UserEditForm extends UserForm
// 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 // delete the association with the old. If it
// hasn't change don't do anything. // hasn't change don't do anything.
EmailAddress oaddr = user.getPrimaryEmail(); EmailAddress oaddr = user.getPrimaryEmail();
EmailAddress naddr = new EmailAddress(data.get(FORM_EMAIL).toString()); EmailAddress naddr = new EmailAddress(data.get(FORM_EMAIL).toString());
if (!oaddr.equals(naddr)) { if (!oaddr.equals(naddr)) {
@ -139,8 +139,11 @@ public class UserEditForm extends UserForm
user.save(); 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 HttpServletRequest req = state.getRequest();
// final String path = LegacyInitializer.getFullURL // final String path = LegacyInitializer.getFullURL
@ -151,4 +154,5 @@ public class UserEditForm extends UserForm
throw new ReturnSignal(req, fallback); throw new ReturnSignal(req, fallback);
} }
} }

View File

@ -75,6 +75,7 @@ public abstract class UserForm extends Form
protected TextField m_question; protected TextField m_question;
protected TextField m_answer; protected TextField m_answer;
protected TextField m_url; protected TextField m_url;
protected TextField m_ssoLogin;
protected Label m_securitySectionHeader = new Label(LoginHelper protected Label m_securitySectionHeader = new Label(LoginHelper
.getMessage("login.userNewForm.securitySectionHeader"), false); .getMessage("login.userNewForm.securitySectionHeader"), false);

View File

@ -144,6 +144,7 @@ public class UserNewForm extends UserForm
final String answer = (String)m_answer.getValue(state); final String answer = (String)m_answer.getValue(state);
final String firstName = (String)m_firstName.getValue(state); final String firstName = (String)m_firstName.getValue(state);
final String lastName = (String)m_lastName.getValue(state); final String lastName = (String)m_lastName.getValue(state);
final String ssoLogin = (String) m_ssoLogin.getValue(state);
String sn = null; String sn = null;
if (!Kernel.getConfig().emailIsPrimaryIdentifier()) { if (!Kernel.getConfig().emailIsPrimaryIdentifier()) {
sn = (String)m_screenName.getValue(state); sn = (String)m_screenName.getValue(state);
@ -183,6 +184,7 @@ public class UserNewForm extends UserForm
auth.setPassword(password); auth.setPassword(password);
auth.setPasswordQuestion(question); auth.setPasswordQuestion(question);
auth.setPasswordAnswer(answer); auth.setPasswordAnswer(answer);
auth.setSSOlogin(ssoLogin);
auth.save(); auth.save();
} catch (PersistenceException e) { } catch (PersistenceException e) {
// problem with creating new User or retrieving // problem with creating new User or retrieving