Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Edouard Piot
Overriding screenName validator
September 5, 2011 5:37 AM
Answer

Edouard Piot

Rank: New Member

Posts: 13

Join Date: May 13, 2011

Recent Posts

Hi,


I'm trying to override Liferay's liberal validator (I need screenNames supporting accented characters).
I started a new Hook Plugin project from eclipse IDE, created a package com.mycompany.classes and then a class MyValidator containing the following code :

 1
 2
 3package com.mycompany.classes;
 4
 5import com.liferay.portal.security.auth.LiberalScreenNameValidator;
 6
 7public class MyValidator extends LiberalScreenNameValidator {
 8
 9    @Override
10    public boolean validate(long companyId, String screenName) {
11       
12        if(super.validate(companyId, screenName))
13            return true;
14        else {
15            
16            if(screenName.contains("é"))
17                return true;
18            else
19                return false;
20            
21        }
22            
23    }
24
25}


I installed the plugin and then rebooted Liferay with the parameter :
1users.screen.name.validator=com.mycompany.classes.MyValidador


Unfortunately, when I try to add a user containing the letter "é", I got a Java error :
112:04:33,827 ERROR [ScreenNameValidatorFactory:42] java.lang.ClassNotFoundException: com.mycompany.classes.MyValidator


I know this must be a newbie question but I can't figure out what's wrong.
Thanks for your help!


Édouard
Jelmer Kuperus
RE: Overriding screenName validator
September 5, 2011 6:53 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

Just use

1users.screen.name.validator=com.liferay.portal.security.auth.LiberalScreenNameValidator


The whole point of LiberalScreenNameValidator is that it accepts everything, including accented characters
Edouard Piot
RE: Overriding screenName validator
September 5, 2011 7:40 AM
Answer

Edouard Piot

Rank: New Member

Posts: 13

Join Date: May 13, 2011

Recent Posts

jelmer kuperus:
Just use

1users.screen.name.validator=com.liferay.portal.security.auth.LiberalScreenNameValidator


The whole point of LiberalScreenNameValidator is that it accepts everything, including accented characters


I'm currently using LiberalScreenNameValidator, it work well with screen names containing underscore, but doesn't with accents.
If you're sure this validator support accents, could this be a database-related problem ?

When I import users from Active Directory, I get a UserScreenNameException on users with accented sAMAccountName, and the accented character is represented by a "?"...
Edouard Piot
[SOLVED] RE: Overriding screenName validator
September 6, 2011 2:51 AM
Answer

Edouard Piot

Rank: New Member

Posts: 13

Join Date: May 13, 2011

Recent Posts

Problem Solved.

In fact, the DefaultValidator (or LiberalValidator) is not responsible of the whole validation process.
There is a another method called validateScreenName, located in UserLocalServiceImpl.java. This methods performs additional verifications, and it fails here when you got accents in screen names.

The only way to get rid of this is to create an ext plugin, as this is apparently impossible to override the validateScreenName method using UserLocalServiceWrapper (through an Hook Plugin)...
Paz Belmonte
RE: [SOLVED] RE: Overriding screenName validator
May 28, 2013 4:07 AM
Answer

Paz Belmonte

Rank: New Member

Posts: 1

Join Date: March 4, 2013

Recent Posts

Hello,
I have the same problem. Can you explain to me how to resolve the problem?
thank you!