チュートリアルの残りの部分は、eXtreme Scale サーバーに接続する前にクライアント認証を有効にする方法を示しています。 このチュートリアルの次のステップに備えるために、SecureSimpleApp.java プログラムを JAR にパッケージ化し、構成ファイルのセットを作成します。これらの構成ファイルは、security.xml ファイルと 2 つの JAAS 構成ファイルを含みます。 security.xml ファイルは、認証を環境に書き込めるようにします。JAAS 構成ファイルは、サーバーへの接続時に認証メカニズムを提供します。
SecureSimpleApp.java
package com.ibm.websphere.objectgrid.security.sample.guide;
import com.ibm.websphere.objectgrid.ClientClusterContext;
import com.ibm.websphere.objectgrid.ObjectGrid;
import com.ibm.websphere.objectgrid.ObjectGridManager;
import com.ibm.websphere.objectgrid.ObjectGridManagerFactory;
import com.ibm.websphere.objectgrid.security.config.ClientSecurityConfiguration;
import com.ibm.websphere.objectgrid.security.config.ClientSecurityConfigurationFactory;
import com.ibm.websphere.objectgrid.security.plugins.CredentialGenerator;
import com.ibm.websphere.objectgrid.security.plugins.builtins.UserPasswordCredentialGenerator;
public class SecureSimpleApp extends SimpleApp {
public static void main(String[] args) throws Exception {
SecureSimpleApp app = new SecureSimpleApp();
app.run(args);
}
/**
* Get the ObjectGrid
* @return an ObjectGrid instance
* @throws Exception
*/
protected ObjectGrid getObjectGrid(String[] args) throws Exception {
ObjectGridManager ogManager = ObjectGridManagerFactory.getObjectGridManager();
ogManager.setTraceFileName("logs/client.log");
ogManager.setTraceSpecification("ObjectGrid*=all=enabled:ORBRas=all=enabled");
// Creates a ClientSecurityConfiguration object using the specified file
ClientSecurityConfiguration clientSC = ClientSecurityConfigurationFactory
.getClientSecurityConfiguration(args[0]);
// Creates a CredentialGenerator using the passed-in user and password.
CredentialGenerator credGen = new UserPasswordCredentialGenerator(args[1], args[2]);
clientSC.setCredentialGenerator(credGen);
// Create an ObjectGrid by connecting to the catalog server
ClientClusterContext ccContext = ogManager.connect("localhost:2809", clientSC, null);
ObjectGrid og = ogManager.getObjectGrid(ccContext, "accounting");
return og;
}
}
security.xml
<?xml version="1.0" encoding="UTF-8"?>
<securityConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ibm.com/ws/objectgrid/config/security ../objectGridSecurity.xsd"
xmlns="http://ibm.com/ws/objectgrid/config/security">
<security securityEnabled="true" loginSessionExpirationTime="300" >
<authenticator className ="com.ibm.websphere.objectgrid.security.plugins.builtins.
KeyStoreLoginAuthenticator">
</authenticator>
</security>
</securityConfig>