论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Shashant Panwar
Impact for implementing String hash code for Screen Name
2013年1月29日 下午12:40
答复

Shashant Panwar

等级: Junior Member

帖子: 28

加入日期: 2012年9月21日

最近的帖子

Hi,
I am implementing a change where I need to update the screen name with the String hashcode value(earlier screen was original username) in liferay db.I want to store the hash code in liferay db because it does not support special characters like (_,@,etc).
I was wondering how to handle the scenario where hashcode of string is same as groupId value or userId value because all are numeric values except my generated code is int and others are long.
Can any member or someone from liferay staff explain me the impact of doing this? I don't future hassles in future as it will impact the whole application.

Thanks & Regards,
Shashant
David H Nebinger
RE: Impact for implementing String hash code for Screen Name
2013年1月29日 下午1:03
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 11779

加入日期: 2006年9月1日

最近的帖子

Screen name is not really used for anything real besides the login. It is not a key field, so it is not an FKEY used by any other table, such as group id and whatnot. I often use the screen name in logging because a) it's unique and b) it is shorter than the full name.

Changing the screen name to a hash code is, IMHO, pointless, as no one would remember it for logging in and it is worthless when using in a logging statement.

Sounds to me like you're really asking if you can steal the username away from Liferay and use it for your own purposes. I'd recommend not doing that; stick to approved ways for adding custom fields to the User object, i.e. expandos.
Shashant Panwar
RE: Impact for implementing String hash code for Screen Name
2013年1月30日 上午7:43
答复

Shashant Panwar

等级: Junior Member

帖子: 28

加入日期: 2012年9月21日

最近的帖子

Hi David,
Thanks for replying.
Actually I am making this change because I want to allow users to enter special character.I already implemented custom attributes but in order to change the existing screen name I have to make this change, Liferay "validateSceenName" method checks if screen Name is numeric then it validates screen Name(it should not be equal to userId or groupId value).

Thanks,
Shashant
David H Nebinger
RE: Impact for implementing String hash code for Screen Name
2013年1月30日 上午8:59
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 11779

加入日期: 2006年9月1日

最近的帖子

Again, screen name is not really visible anywhere in the Liferay system, outside of allowing it to be used for login. Most sites typically use the email address for the login, and in those cases screen name doesn't really need to exist at all.

Now, that being said, you don't need to override anything to affect this change. There's a property that you can add to portal-ext.properties, users.screen.name.validator, which has the class Liferay should use for screen name validation. You would just need to implement your own class (see com.liferay.portal.security.auth.DefaultScreenNameValidator or LiberalScreenNameValidator for examples) and specify it in the file.

However, unless you're using screen name for the login, I wouldn't worry about what the screen name actually is.
Shashant Panwar
RE: Impact for implementing String hash code for Screen Name
2013年1月31日 上午10:25
答复

Shashant Panwar

等级: Junior Member

帖子: 28

加入日期: 2012年9月21日

最近的帖子

Thanks David, references cleared my doubts emoticon
Siby Mathew
RE: Impact for implementing String hash code for Screen Name
2013年2月1日 上午2:11
答复

Siby Mathew

等级: Expert

帖子: 267

加入日期: 2011年3月4日

最近的帖子

Hi David,
Actually there is an issue with the liferay implementation of the screenname validator.
If you see UserLocalServiceImpl.validateScreenName(), the method is doing some extra validation even after invoking the screen name validator instance.
Due to this, I think the users.screen.name.validator might not work.

Thanks,
Siby
Praveen Acharya
RE: Impact for implementing String hash code for Screen Name
2015年12月16日 上午2:14
答复

Praveen Acharya

等级: New Member

帖子: 1

加入日期: 2015年9月15日

最近的帖子

We have a requirment to hash the screenName and store in the User_ table. Question is:
1. When creating the new user which file to change for hashing and storing in db.
2. When login which file to change for the login to work. The user is going to enter plaintext screenName but db will have hashed screenName.

And as mentioned, if screenName is not used anywhere else in Liferay. hopefully just the above two will keep Liferay stable and unbroken in all other respects.

Thanks