cancel
Showing results for 
Search instead for 
Did you mean: 

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

veera_
Champ on-the-rise
Champ on-the-rise

Hi,

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

<tr>
<td class="login_label">
<label for="username"> <fmt:message bundle="${messages}" key="label.login.username" />
</label>
</td>
<td>
<input class="login_input" type="text" name="user_name" id="username" size="22">
</td>
</tr>

Thanks Veera

1 ACCEPTED ANSWER

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

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 {

@Override
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

  <extension
      target="org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService"
      point="authenticators">

    <authenticationPlugin name="ADMINSITRATOR_FILTER_AUTH" enabled="true"
        class="org.nuxeo.ecm.mobile.filter.ApplicationFormAuthenticator">
      <needStartingURLSaving>true</needStartingURLSaving>
    </authenticationPlugin>
  </extension>
  <extension
      target="org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService"
      point="chain">
    <authenticationChain>
      <plugins>
        <plugin>ADMINSITRATOR_FILTER_AUTH</plugin>
        <plugin>WEBSERVICES_AUTH</plugin>
      </plugins>
    </authenticationChain>
  </extension>

Hope this will help you.

View answer in original post

11 REPLIES 11

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

What do you want to do exactly ?

veera_
Champ on-the-rise
Champ on-the-rise

Hi,

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

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 {

@Override
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

  <extension
      target="org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService"
      point="authenticators">

    <authenticationPlugin name="ADMINSITRATOR_FILTER_AUTH" enabled="true"
        class="org.nuxeo.ecm.mobile.filter.ApplicationFormAuthenticator">
      <needStartingURLSaving>true</needStartingURLSaving>
    </authenticationPlugin>
  </extension>
  <extension
      target="org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService"
      point="chain">
    <authenticationChain>
      <plugins>
        <plugin>ADMINSITRATOR_FILTER_AUTH</plugin>
        <plugin>WEBSERVICES_AUTH</plugin>
      </plugins>
    </authenticationChain>
  </extension>

Hope this will help you.

Hi,

This is in my answer, the part

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

You must not fork our code. This is evil.

Sorry for that wrong work...

You will need to have development skills for that.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.