Java WebApp プロジェクトに組み込まれた jetty 7 を使用しています。
SSL をセットアップしました。次のステップは、クライアント証明書認証を処理することです。私が指定したweb.xmlで:
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Test Realm</realm-name>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>EntireApp</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>allAuthenticated</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
以下は、startserver ルーチンのコードです。
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector();
ssl_connector.setPort(Integer.valueOf(httpPort1));
SslContextFactory cf = ssl_connector.getSslContextFactory();
cf.setKeyStore(sslProperties.getKeyStore());
cf.setKeyStorePassword(sslProperties.getKeyPassword());
cf.setTrustStore(sslProperties.getTrustStore());
cf.setTrustStorePassword(sslProperties.getTrustStorePassword());
cf.setNeedClientAuth(true);
server.setConnectors(new Connector[]{ connector0, ssl_connector });
WebAppContext context = new WebAppContext();
context.setDescriptor("WebContent/WEB-INF/web.xml");
context.setResourceBase("WebContent");
context.setContextPath("/");
context.setParentLoaderPriority(true);
SecurityHandler secHandler = new ConstraintSecurityHandler();
//Authenticator authenticator = new ClientCertAuthenticator();
Authenticator authenticator = new DummyAuthenticator();
//probably I need something different, but what ?
LoginService loginService = new HashLoginService("Test Realm", "d:/downloads/test.properties");
secHandler.setRealmName("Test Realm");
secHandler.setLoginService(loginService);
secHandler.setAuthenticator(authenticator);
context.setSecurityHandler(secHandler);
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
私の質問は、 ClientCertAuthenticator と組み合わせてどの loginservice を使用すればよいですか? または、それが不可能な場合、自分の (DummyAuthenticator) を実装する最良の方法は何でしょうか?
上記のコードでは、Authenticator インターフェースを実装するだけの DummyAuthenticator を使用していますが、validateRequest メソッドの servletRequest には、期待する場所に常に空の parameterMap があります。