小编alb*_*ano的帖子

Guice injector.getInstance() - 良好的做​​法?

假设我有两个应用程序共享同一个库.该库包含常见的类,如DAO,Utils等.共享库中的所有内容都与Guice连接.我的两个应用依赖于这个库,但没有直接依赖Guice.

 ______    ______    ______
|      |  |      |  |      |
| APP1 |->| LIB  |<-| APP2 |
'------'  '------'  '------'
Run Code Online (Sandbox Code Playgroud)

我目前使用这样的东西:

static <T> Utils.getInstanceOf (Class<T> type);
Run Code Online (Sandbox Code Playgroud)

这只是一个包装:

injector.getInstance (Class<T> type);
Run Code Online (Sandbox Code Playgroud)

但是guice文档说:

如果可行,请避免使用此方法,以便让Guice提前注入您的依赖项.

那么为两个应用程序提供依赖注入的最佳方法是什么,而不必在Guice模块中手动绑定它们?

java dependency-injection guice

14
推荐指数
3
解决办法
2万
查看次数

为什么Apache HttpClient 4.4拒绝www.googleapis.com作为有效的主机名?

我最近从4.3切换到HttpClient 4.4,我得到了SSLPeerUnverifiedException这样的说法:

Host name 'www.googleapis.com' does not match the certificate subject provided by the peer (CN=*.googleapis.com, O=Google Inc, L=Mountain View, ST=California, C=US)
Run Code Online (Sandbox Code Playgroud)

问题来自于HttpClient现在使用publicsuffix.org列表进行验证(参见SSLConnectionSocketFactory.java的源代码).

解决此问题的一种方法是关闭主机名验证:

CloseableHttpClient httpClient = HttpClients.custom().
   setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
Run Code Online (Sandbox Code Playgroud)

...但我试图理解为什么通配符与客户端不匹配以及为什么它被认为太宽泛(参考).

RFC2818规范说:

名称可以包含通配符
字符*,其被认为是匹配任何单个域名
组件或组件片段.例如,*.a.com匹配foo.a.com但
不匹配bar.foo.a.com.f*.com匹配foo.com但不匹配bar.com.

这是否意味着HttpClient 4.4不符合规范?

ssl apache-httpclient-4.x

7
推荐指数
1
解决办法
6214
查看次数

如何覆盖glassfish中的j_security_check?

我目前正在使用FORMglassfish v2.1中的基于身份验证来登录用户,它工作正常.我想切换到ProgrammaticLogin,我希望能够获取最初请求的URL(即在重定向到登录页面之前)并在我的程序化登录代码中使用它,以便在验证后将用户重定向回请求的页面.

我已经看到了源代码j_security_check- 在我的情况下是FormAuthenticator(catalina codebase)并且它将初始请求保存SavedRequest在会话中的对象中但是该会话是一个StandardSession而不是HttpSession因此没有直接的方式来访问它.

或者我应该将身份验证机制更改FORM为其他内容吗?

谢谢!

java authentication glassfish jsr196

6
推荐指数
1
解决办法
6516
查看次数