注入RealmsManager

时间:2015-09-21 14:47:40

标签: java glassfish jax-rs

我正在编写ContainerRequestFilter来检查请求标头并提供可插入的身份验证机制,该机制将迭代已配置的AS安全域(例如Glassfish)并提供自定义SecurityContext。 我试图注入RealmsManager(在com.sun.enterprise.security.auth.realm.RealmsManager [1]中定义),在@Singleton中注明为ContainerRequestFilter。这是我的代码:

public class AuthenticationFilter implements ContainerRequestFilter {

    @Inject
    RealmsManager rm;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        if (rm != null) {
            requestContext.abortWith(Response.ok("OKAY").build());

        } else {
            requestContext.abortWith(Response.ok("NULL").build());
        }
}

但在部署WAR时出现此错误:

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied
    dependencies for type RealmsManager with qualifiers @Default
    at injection point [BackedAnnotatedField] @Inject

如何在RelamsManager中注入ContainerRequestFilter单身?

[1]以下是RealmsManager的来源:https://svn.java.net/svn/glassfish~svn/trunk/main/nucleus/security/core/src/main/java/com/sun/enterprise/security/auth/realm/RealmsManager.java

0 个答案:

没有答案