Authentication type
First, we must define authentication.type to sso:
|
# Defines the authentication method to sso
authentication.type = sso
|
SSO implementation
Next, the must define which class will handle SSO. It should be an implementation of
net.jforum.sso.SSO. The default class,
RemoteUserSSO, just checks if a call to
requset.getRemoteUser() does not return
null. This may be enough for most of the situations.
sso.implementation = net.jforum.sso.RemoteUserSSO
|
If you want to use your own SSO handler, just set this key.
 | Be careful
The class must implement the interface net.jforum.sso.SSO, otherwise you'll get runtime errors when trying to use JForum
|
Default email and password
By default, JForum will set a dummy value for the email and password attributes. The settings are in
SystemGlobals.properties, as follow:
# The default email to use if sso.email.attribute is empty
sso.default.email = sso@user
# The default password to use if sso.password.attribute is empty
sso.default.password = sso
|
If, for any reason, you would like to set another value for those properties, you can put the email and / or the password in the session, so JForum can have a chance of accessing it. The attribute's name you should set are also defined in SystemGlobals.properties. The default setting is here listed:
# The attribute name to search in the session for the password.
sso.password.attribute = password
# Same as above
sso.email.attribute = email
|
Using this logic, if you want to set a custom email or password, you must add it to the session before getting into JForum:
1 // Set the SSO password and email for the current user
2 session.setAttribute("sso.password.attribute", "a secret");
3 session.setAttribute("sso.email.attribute", "user@email.com");
|
 | Dont' forget
Of course, the password and email attributes will only be used if the user who's authenticating is not registered yet.
|
web.xml example
Much probably you will want / have to set up
web.xml in order to get SSO working. Below is an example:
01 <!-- Example of SSO configuration -->
02 <security-role>
03 <role-name>user</role-name>
04 </security-role>
05
06 <security-constraint>
07 <web-resource-collection>
08 <web-resource-name>Restricted Area</web-resource-name>
09 <url-pattern>/*</url-pattern>
10 </web-resource-collection>
11
12 <auth-constraint>
13 <role-name>user</role-name>
14 </auth-constraint>
15 </security-constraint>
16
17 <login-config>
18 <auth-method>BASIC</auth-method>
19 <realm-name>YOUR REAL NAME HERE</realm-name>
20 </login-config>
|