我正在为nexus编写自定义过滤器来进行身份验证。当我通过编写类似于sourcecode的过滤器模块添加过滤器时。我得到了一个guice供应异常。我不知道究竟是什么原因。它只是说空指针异常。
Sisu - Problem adding: org.sonatype.guice.bean.locators.LazyBeanEntry@7bb3bc to: org.apache.shiro.web.filter.mgt.DefaultFilterChainManager@5b460d via: org.sonatype.security.web.guice.SecurityWebModule$FilterChainManagerProvider@1d31aaa
com.google.inject.ProvisionException: Guice provision errors:
1) Error in custom provider, java.lang.NullPointerException
at org.sonatype.guice.bean.binders.LocatorWiring
while locating org.sonatype.nexus.security.filter.authc.PasswordDecryptor
for field at org.sonatype.nexus.security.filter.authc.NexusSecureHttpAuthenticationFilter.passwordDecryptor(NexusSecureHttpAuthenticationFilter.java:20)
while locating net.collab.iaf.sso.authentication.rest.CTFAuthenticationFilter
at file:/media/blackhole/temp/nexus/nexus-bundle-template-2.6.1-SNAPSHOT-bundle/nexus-bundle-template-2.6.1-SNAPSHOT/../sonatype-work/nexus/plugin-repository/authentication-0.0.1-SNAPSHOT/authentication-0.0.1-SNAPSHOT.jar!/
at file:/media/blackhole/temp/nexus/nexus-bundle-template-2.6.1-SNAPSHOT-bundle/nexus-bundle-template-2.6.1-SNAPSHOT/../sonatype-work/nexus/plugin-repository/authentication-0.0.1-SNAPSHOT/authentication-0.0.1-SNAPSHOT.jar!/
while locating javax.servlet.Filter annotated with @com.google.inject.name.Named(value=authcBasic)
1 error
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1006) [sisu-guice-3.1.4.jar:3.1.4]
我的自定义过滤器模块与上面链接中给出的源代码文件相同,只有authcBasic和authcNxBasic的过滤器。这里我有一个名为CTFAuthenticationFilter的自定义过滤器,而不是NexusSecureHttpAuthenticationFilter。请给出一些指示来解决这个问题。 我的过滤器模块的剪辑如下
@Override
protected void configure() {
requireBinding(FilterChainResolver.class);
logger.info("I am inside collabnetsso");
bindAuthcFilter("authcBasic", false, "Sonatype Nexus Repository Manager API");
bindAuthcFilter("authcNxBasic", true, "Sonatype Nexus Repository Manager API (specialized auth)");
}
private void bindAuthcFilter(String name, boolean fakeAuthSchem, String applicationName) {
logger.info("I am inside collabnetsso authc module");
CTFAuthenticationFilter filter = new CTFAuthenticationFilter();
filter.setApplicationName(applicationName);
filter.setFakeAuthScheme(Boolean.toString(fakeAuthSchem));
bindNamedFilter(name, filter);
}
这看起来很奇怪,因为它有时只会发生。如果它连续发生两次,在这两次中我的身份验证不会发生。但是,如果我重新启动,异常会消失,它会像魅力一样开始工作,并且会根据需要进行身份验证。 这带来了疑问,就像在关系中发生了任何竞争条件一样? 或者是谷歌的guice期望什么,有时候无法获得。