Fórumok

Overriding screenName validator

Edouard Piot, módosítva 12 év-val korábban

Overriding screenName validator

New Member Bejegyzések: 13 Csatlakozás dátuma: 2011.05.13. Legújabb bejegyzések
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 :



package com.mycompany.classes;

import com.liferay.portal.security.auth.LiberalScreenNameValidator;

public class MyValidator extends LiberalScreenNameValidator {

	@Override
	public boolean validate(long companyId, String screenName) {
		
		if(super.validate(companyId, screenName))
			return true;
		else {
			
			if(screenName.contains("é"))
				return true;
			else
				return false;
			
		}
			
	}

}



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


Unfortunately, when I try to add a user containing the letter "é", I got a Java error :
12: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
thumbnail
jelmer kuperus, módosítva 12 év-val korábban

RE: Overriding screenName validator

Liferay Legend Bejegyzések: 1191 Csatlakozás dátuma: 2010.03.10. Legújabb bejegyzések
Just use

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


The whole point of LiberalScreenNameValidator is that it accepts everything, including accented characters
Edouard Piot, módosítva 12 év-val korábban

RE: Overriding screenName validator

New Member Bejegyzések: 13 Csatlakozás dátuma: 2011.05.13. Legújabb bejegyzések
jelmer kuperus:
Just use

users.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, módosítva 12 év-val korábban

[SOLVED] RE: Overriding screenName validator

New Member Bejegyzések: 13 Csatlakozás dátuma: 2011.05.13. Legújabb bejegyzések
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, módosítva 10 év-val korábban

RE: [SOLVED] RE: Overriding screenName validator

New Member Bejegyzés: 1 Csatlakozás dátuma: 2013.03.04. Legújabb bejegyzések
Hello,
I have the same problem. Can you explain to me how to resolve the problem?
thank you!