Foren
screenName Validator
alamut avani, geändert vor 14 Jahren.
screenName Validator
New Member Beiträge: 11 Beitrittsdatum: 08.07.07 Neueste Beiträge
Hello,
I want to change the control of screename, so that we can add phone numbers as an identifier.
I created a validator class that replaces com.liferay.portal.security.auth.ScreenNameValidator in portal-ext.properties.
THE new class return true every time but nothing changed I still an error when trying to insert a screename with that digit.
Can you help meeeeeeeee plizzzzzzzzzz
sorry I forgot, I'm using liferay 5.2.2.
I want to change the control of screename, so that we can add phone numbers as an identifier.
I created a validator class that replaces com.liferay.portal.security.auth.ScreenNameValidator in portal-ext.properties.
THE new class return true every time but nothing changed I still an error when trying to insert a screename with that digit.
Can you help meeeeeeeee plizzzzzzzzzz
sorry I forgot, I'm using liferay 5.2.2.
Amos Fong, geändert vor 14 Jahren.
RE: screenName Validator
Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
Hi Alamut,
There are some other restrictions that are not included in validator. Look in UserLocalServiceImpl.validateScreenName. I think one of them is that the screenname cannot be only numbers
There are some other restrictions that are not included in validator. Look in UserLocalServiceImpl.validateScreenName. I think one of them is that the screenname cannot be only numbers
alamut avani, geändert vor 14 Jahren.
RE: screenName Validator
New Member Beiträge: 11 Beitrittsdatum: 08.07.07 Neueste Beiträge
Thank's a Lot Amos :-)
Kensuke Ono, geändert vor 14 Jahren.
RE: screenName Validator
New Member Beiträge: 4 Beitrittsdatum: 09.09.09 Neueste Beiträge
Hello,
We also have to use numbers as screenName.
So I modified a several codes and it seems to work fine.
In this modification, screenName must start with "id-".
"id-" is automatically added or removed when the user login or authenticate against AD.
(1)com.liferay.portal.service.impl.UserLocalServiceImpl (line 265)
(2)com.liferay.portal.action.LoginAction (line 68)
(3)com.liferay.portal.security.auth.LDAPAuth (line 159)
(4)com.liferay.portal.security.ldap.PortalLDAPUtil (line 700)
(5)com.liferay.portlet.login.action.LoginAction (line 140)
(6)com.liferay.portlet.login.action.ForgotPasswordAction (line 133)
We also have to use numbers as screenName.
So I modified a several codes and it seems to work fine.
In this modification, screenName must start with "id-".
"id-" is automatically added or removed when the user login or authenticate against AD.
(1)com.liferay.portal.service.impl.UserLocalServiceImpl (line 265)
Company company = companyPersistence.findByPrimaryKey(companyId);
screenName = getScreenName(screenName);
////////////////////////////////////////////////////////////////////////////////
// ADD
if (!screenName.startsWith("id-"))
{
screenName = "id-" + screenName;
}
////////////////////////////////////////////////////////////////////////////////
(2)com.liferay.portal.action.LoginAction (line 68)
HttpSession session = request.getSession();
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
WebKeys.THEME_DISPLAY);
////////////////////////////////////////////////////////////////////////////////
// ADD
if (session.getAttribute("j_username") != null &&
!session.getAttribute("j_username").toString().startsWith("id-"))
{
String j_username = session.getAttribute("j_username").toString();
session.removeAttribute("j_username");
session.setAttribute("j_username", "id-" + j_username);
}
////////////////////////////////////////////////////////////////////////////////
(3)com.liferay.portal.security.auth.LDAPAuth (line 159)
LdapContext ctx = PortalLDAPUtil.getContext(companyId);
if (ctx == null) {
return authenticateRequired(
companyId, userId, emailAddress, FAILURE);
}
// Process LDAP auth search filter
////////////////////////////////////////////////////////////////////////////////
// ADD
String screenName2 = screenName;
if (screenName.startsWith("id-")){
screenName2 = screenName.replaceFirst("id-", "");
}
String filter = PortalLDAPUtil.getAuthSearchFilter(
companyId, emailAddress, screenName2, String.valueOf(userId));
////////////////////////////////////////////////////////////////////////////////
(4)com.liferay.portal.security.ldap.PortalLDAPUtil (line 700)
long creatorUserId = 0;
boolean passwordReset = false;
boolean autoScreenName = false;
String screenName = LDAPUtil.getAttributeValue(
attrs, userMappings.getProperty("screenName")).toLowerCase();
////////////////////////////////////////////////////////////////////////////////
// ADD
screenName = "id-" + screenName;
////////////////////////////////////////////////////////////////////////////////
String emailAddress = LDAPUtil.getAttributeValue(
attrs, userMappings.getProperty("emailAddress"));
(5)com.liferay.portlet.login.action.LoginAction (line 140)
HttpServletRequest request = PortalUtil.getHttpServletRequest(
actionRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(
actionResponse);
String login = ParamUtil.getString(actionRequest, "login");
////////////////////////////////////////////////////////////////////////////////
// ADD
if (!login.startsWith("id-")){
login = "id-" + login;
}
////////////////////////////////////////////////////////////////////////////////
String password = ParamUtil.getString(actionRequest, "password");
boolean rememberMe = ParamUtil.getBoolean(actionRequest, "rememberMe");
(6)com.liferay.portlet.login.action.ForgotPasswordAction (line 133)
long userId = ParamUtil.getLong(actionRequest, "userId");
String screenName = ParamUtil.getString(actionRequest, "screenName");
////////////////////////////////////////////////////////////////////////////////
// ADD
if (!screenName.startsWith("id-")){
screenName = "id-" + screenName;
}
////////////////////////////////////////////////////////////////////////////////
String emailAddress = ParamUtil.getString(
actionRequest, "emailAddress");