Extract from my server.xml :
<basicRegistry id="basic" realm="customRealm">
<user name="defaultUser@example.com" password="password" />
</basicRegistry>
Currently, this requires login from the user in the form of a dialog box.
I would like for the user to be logged in as defaultUser@example.com
by default, without any dialog boxes or having to type anything.
How can I do this?
You could try to use this kind of link to provide authentication credentials in it:
http://userid:secretpassword@yourHost/context-root
Check if it will work and is good enough for your case.
UPDATE
1) The other solution could be to implement FORM login. So you need to change security settings in your application and add following to the web.xml
<login-config>
<auth-method>FORM</auth-method>
<realm-name>myrealm</realm-name>
<form-login-config>
<form-login-page>login.jsp</form-login-page>
<form-error-page>login.jsp</form-error-page>
</form-login-config>
</login-config>
Then you would need to send POST
request to
http://yourHost/context-root/j_security_check
with j_username=userid
and j_password=password
2) Second solution which would would work totally seamlessly would be to create custom TAI like described here - Developing a custom TAI for the Liberty profile
Relevant code fragment from that page:
import com.ibm.wsspi.security.tai.TrustAssociationInterceptor;
public class SimpleTAI implements TrustAssociationInterceptor {
...
public TAIResult negotiateValidateandEstablishTrust(HttpServletRequest req,
HttpServletResponse resp) throws WebTrustAssociationFailedException {
// Add logic to authenticate a request and return a TAI result.
String tai_user = "taiUser";
return TAIResult.create(HttpServletResponse.SC_OK, tai_user);
}
Add the TAI class to the Liberty profile server. Use one of the following methods to add the TAI class to the Liberty profile server: