Set default login/authentication in server.xml. How can you do this?

孤者浪人 提交于 2019-12-12 01:45:20

问题


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?


回答1:


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:

  • Put the custom TAI class in a JAR file, for example simpleTAI.jar, then make the JAR file available as a shared library. See Configuring TAI for the Liberty profile.
  • Package the custom TAI class as a feature. See Developing a custom TAI as a Liberty profile feature.


来源:https://stackoverflow.com/questions/25531193/set-default-login-authentication-in-server-xml-how-can-you-do-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!