留言板

Overriding screenName validator

Edouard Piot,修改在12 年前。

Overriding screenName validator

New Member 帖子: 13 加入日期: 11-5-13 最近的帖子
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,修改在12 年前。

RE: Overriding screenName validator

Liferay Legend 帖子: 1191 加入日期: 10-3-10 最近的帖子
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,修改在12 年前。

RE: Overriding screenName validator

New Member 帖子: 13 加入日期: 11-5-13 最近的帖子
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,修改在12 年前。

[SOLVED] RE: Overriding screenName validator

New Member 帖子: 13 加入日期: 11-5-13 最近的帖子
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,修改在10 年前。

RE: [SOLVED] RE: Overriding screenName validator

New Member 发布: 1 加入日期: 13-3-4 最近的帖子
Hello,
I have the same problem. Can you explain to me how to resolve the problem?
thank you!