Can i compare the username field value with one string value(like Administrator) in login.jsp?


Can i compare the username field value with one string value(like Administrator) in login.jsp? How can i compare the username value with one string in this code?

If its equal means pass the value for authentication

else i have to set username value with null.

Can anyone help me?

Here is the code for username field in login.jsp

<td class=“login_label”>
<label for=“username”>

&lt;fmt:message bundle="${messages}" key="label.login.username" /><br>

<input class=“login_input” type=“text” name=“user_name” id=“username” size=“22”>

Thanks Veera

0 votes

1 answers



What do you want to do exactly ?


There are so many groups and users we can create in nuxeo. After that i login in nuxeo,

I need to test that username with one constant value(Administrator).

How can i compare username value with one string in the above code in login.jsp

If (username == "Administrator") then use default logic for login(pass the username, password values for authentication) else login should fail. thats why i have to set a null value for username field, then only login will fail.

How can i use this logic in login.jsp?

Don't worry about other users. Administrator only login in nuxeo.


I don't really understand your need. Why don't you use a local user management that stores only your administrator? Anyway I give my answer to your specific question :)

The better way is not to attach your logic to the login page, but on the authentication filter. For multiple raison but the main is that you can login to Nuxeo with other way than the login page. So must work on a central point: Authentication layer.

You need to have a little knowledge about development to do that. Here is the guide line:

  • install Nuxeo IDE
  • declare an authenticator that filters users except administrator
  • add it to the authentication chain
  • deploy your contribution into the server.

You just have to contribute a new Authenticator that fail for other username than Administrator, else do the default behavior. So my piece of advice will be to create a authenticator that extends the default one:

public class AdministratorFilterAuthenticator extends ApplicationFormAuthenticator {

public UserIdentificationInfo handleRetrieveIdentity(
        HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
            String userName = httpRequest.getParameter(usernameKey);
            if ("Administrator".equals(username)) {
                return super.handleRetrieveIdentity(httpRequest, httpResponse);
            return null;

Finally you will have to add your authenticator to the authentication chain and declare your authenticator


    <authenticationPlugin name="ADMINSITRATOR_FILTER_AUTH" enabled="true"

Hope this will help you.

1 votes


Thanks a lot. This is what i want. Thanks once again.

I can create authenticator but i don't know about authentication chain. where it ll be in nuxeo? I am new to nuxeo.



This is in my answer, the part :

 target=&quot;org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService&quot; point=&quot;chain&quot;

I create an authenticator plugin and put into..nuxeo/../server/nuxeo.ear/plugin folder.

I add authenticator into the authentication chain(I modify in authentication-framework.xml in nuxeo-platform-web-common-5.3.1.jar what you told above).

Restart server.

Its not working..Login sucessful for all users. Its not filtering.

Anything i missed? Please help me.



You must not fork our code. This is evil. :)

You just have to contribute to the extension point and add a required to a component you want to override. And that's it.

You are on jjboss or tomcat ? Please use the bundle directory instead plugin.

We can't help you more, without more investigation from you in logs (there is an answer that explain how to do that : Maybe you can check your component (XML file) that declares the authenticator is declared into the manifest, check the component name is unique, that you used Nuxeo IDE for creating your bundle (jar). That's a good start.


Sorry for that wrong work…

I am using nuxeo-jboss-5.3.1.

There is no error in my logger.

I can create authenticator plugin. After that

How and where should i add it to authenticator chain?

where should i place my plugin? I am new to nuxeo..

Give some brief idea.



You will need to have development skills for that.

I'll give you some reading for the night:

If you understood all things above you are ready to create your bundle:

  • Create your development environment:
  • Create then your component (XML File) into the OSGI-INF file that contains your chain definition and authenticator definition
  • Deploy with Nuxeo IDE feature (look the documentation)

Hope this will help.



Thanks for sending such a wonderful documentations.

I created authenticator plugin. I follow the above docs for creating project. After that,

I add the authenticator plugin to the authentication chain(Create a xml file and paste it into $JBOSS_HOME/server/default/deploy/nuxeo.ear/config folder).

After restart nuxeo-jboss-5.3.1,

The Logs shows

14:26:59,077 ERROR [NuxeoAuthenticationFilter] Auth plugin ADMINSITRATOR_FILTER_AUTH can not be retrieved from service 14:26:59,116 ERROR [DefaultNuxeoExceptionHandler] java.lang.NullPointerException

at org.nuxeo.ecm.platform.ui.web.auth.NuxeoAuthenticationFilter.initUnAuthenticatedURLPrefix(
at org.nuxeo.ecm.platform.ui.web.auth.NuxeoAuthenticationFilter.bypassAuth(
at org.nuxeo.ecm.platform.ui.web.auth.NuxeoAuthenticationFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoRequestControllerFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.nuxeo.ecm.platform.web.common.exceptionhandling.NuxeoExceptionFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

14:26:59,150 ERROR [nuxeo-error-log] Request Attributes:

NuxeoExceptionHandlerMarker : true securityError : false user_message : an unexpected error occurred

Can you give some more guidence to complete this task?



Hi bjalon, Julien Carsique & Anahide Tchertchian,

Thanks for your guidance. I solved this issue with the help of your previous comments and documents.

Thanks a lot…