简体   繁体   English

如何在 Jakarta EE 应用程序中激活我自己的 Jakarta HttpAuthenticationMechanism 实现

[英]How to activate my own Jakarta HttpAuthenticationMechanism implementation in Jakarta EE app

I am creating an simple Jakarta EE 9 app.我正在创建一个简单的Jakarta EE 9应用程序。 Because of my own reason, I have to implement my own HttpAuthenticationMechanism (I am not using built-in HttpAuthenticationMechanism CDI beans).由于我自己的原因,我必须实现我自己的 HttpAuthenticationMechanism(我没有使用内置的HttpAuthenticationMechanism CDI bean)。

I am having an issue with activating my own HttpAuthenticationMechanism.我在激活自己的 HttpAuthenticationMechanism 时遇到问题。 In my login servlet, I try to call SecurityContext.authenticate(request, response, AuthenticationParameters) to process a login manually, but my own HttpAuthenticationMechanism never get called.在我的登录 servlet 中,我尝试调用SecurityContext.authenticate(request, response, AuthenticationParameters)来手动处理登录,但我自己的 HttpAuthenticationMechanism 从未被调用。 It was supposed to be called.它应该被调用。

My own HttpAuthenticationMechanism & its annotations我自己的 HttpAuthenticationMechanism 及其注释

@ApplicationScoped
@Alternative
@jakarta.annotation.Priority(jakarta.interceptor.Interceptor.Priority.APPLICATION)
@AutoApplySession

public class MyOwnHttpAuthenticationMechanism implements HttpAuthenticationMechanism {

    @Override
    public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMessageContext)
            throws AuthenticationException {
        
        // Never called
    }
}

As you see, I already added @Alternative and @Priority to activate the bean.如您所见,我已经添加了@Alternative 和@Priority 来激活bean。

My environment:我的环境:

  • Jakarta EE 9.1雅加达 EE 9.1
  • Wildfly 26 preview for Jakarta EE 9 Jakarta EE 9 的 Wildfly 26 预览版
  • I also changed Integrated JASPI from ON to OFF on the Wildfly.我还在Wildfly 上将 Integrated JASPI从 ON 更改为 OFF。
  • my jboss-web.xml: < security-domain> jaspitest < /security-domain>我的 jboss-web.xml: <security-domain> jaspitest < /security-domain>
  • Java 11 Java 11

Any helps?有帮助吗? Thank you!谢谢!

I found out what was wrong.我发现出了什么问题。 There was NO security domain 'jaspitest' in Wildfly 26. This security domain existed in Wildfly before by default, but no longer exists . Wildfly 26 中没有'jaspitest' 安全域。这个安全域以前在Wildfly 中默认存在,但现在不存在了 That was the reason why my own HttpAuthenticationMechanism did not get invoked.这就是我自己的 HttpAuthenticationMechanism 没有被调用的原因。

Solution : Use Security Domain 'other' instead, OR remove the security-domain tag from jboss-web.xml, OR your own security domain解决方案:改用安全域“其他” ,或者从 jboss-web.xml 中删除安全域标签,或者您自己的安全域

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM