users@glassfish.java.net

[gf-users] Custom realm using x509 certificates and DB realm in Glassfish 3.1.1

From: Ali Gholami <gholami_at_kth.se>
Date: Wed, 31 Dec 2014 12:13:29 +0100

Hi,

I need a custom realm to authenticate two groups of users. One group is
authenticated using x509 certificate and another group using a custom
two-factor authentication DBRealm (username/one-time password). I wonder
if someone knows how to implement such custom realm for these two groups
in Glassfish 3.1.1.

I was reading the custom realm documentation and it seems I should
implement a custom LoginModule (MyCustomLoginModule) that extends
AppservCertificateLoginModule and AppservPasswordLoginModule. But as you
know multiple inheritance is not allowed in Java and also both these
classes have authenticateUser() method in common:

--------
   @Override
     protected void authenticateUser() throws LoginException {
     }
--------

My two-factor DB realm works fine for one group of users as I could
extend AppservPasswordLoginModule without any problem:

--------
public class MyCustomLoginModule extends AppservPasswordLoginModule {
   @Override
     protected void authenticateUser() throws LoginException {
         // my code
     }
}
--------

Now the issue is adding certificate authentication to the
MyCustomLoginModule to enable other group with certificates to be
authenticated. I should clarify users with certificates do not use
two-factor authentication. They will be only authenticated through their
personal x509 certificates protected with a password embedded in their
browsers.

I would appreciate if someone could give me some hints to solve this
problem.

Best regards
Ali