Hedwig provides pluggable security through JAAS login module. Using this mechanism, you can use legacy database or LDAP directory to verify if the given password is correct for the user. For general information on JAAS see the JAAS Authentication Tutorial and the reference guide.
JAAS configures itself using a configuration provider. The default JAAS configuration provider locates its configuration file by looking at - among other things - the java.security.auth.login.config system property. In Hedwig this property locates the conf/login.config file. The login.config file lists one or more login module configurations. In order to use JAAS login module you must set auth_scheme parameter from default.properties file to the one of login module configurations in the login.config file.
Take a look at the following configuration for example: default.properties
auth_scheme=PropertiesLogin
PropertiesLogin { com.hs.mail.security.login.PropertiesLoginModule required file="users.properties" ; };
Legacy database can be used to verify password. The query setting contains the SQL query to look up the password. If the passwords are in plaintext format, you can omit the encoder option. Otherwise you must specify which password encoder to use. See the Password_Schemes for more information about password encoder.
JdbcLogin { com.hs.mail.security.login.JdbcLoginModule required debug=true driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:localhost:1521:xe" username="legacy" password="s3cret" query="SELECT passwd FROM user WHERE mail = ?" encoder=com.hs.mail.security.login.MD5PasswordEncoder ; };
LDAP directory can be used to verify password.
LdapLogin { com.hs.mail.security.login.JndiLoginModule required context.factory=com.sun.jndi.ldap.LdapCtxFactory url="ldap://ldap.domain.com:389" username="cn=admin,ou=User,dc=domain,dc=com" password=password authentication=simple base="ou=User,dc=domain,dc=com" searchFilter="(mail={0})" subtree=true ; };
Password scheme means the format in which the password is stored in database. Followings are password schemes supported by Hedwig and class name of password encoder which implements its encryption algorithm.
com.hs.mail.security.login.PlaintextPasswordEncoder
com.hs.mail.security.login.CryptPasswordEncoder
com.hs.mail.security.login.MD5PasswordEncoder