JAASプログラミング・フレームワーク統合
Oracle NoSQL Databaseでは、Java Authentication and Authorization Service (JAAS)プログラミング・フレームワークを使用して、クライアント・アプリケーションをプログラムと統合できます。
oracle.kv.jaas.login.conf.entryName
セキュリティ・プロパティを使用して、JAASログイン構成を指定します。
ノート:
JAASログイン構成ファイルが設定されている場合、セキュリティ・プロパティにキータブまたは資格証明キャッシュを指定することはできません。
これにより、ログイン構成ファイルには、次のようなコンテンツが含まれます。
oraclenosql {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
keyTab=test.keytab
storeKey=true
principal=krbuser
doNotPrompt=false;
};
ここで、oraclenosql
はoracle.kv.jaas.login.conf.entryName
の値です。この構成ファイルは、Kerberosログインに使用できます。
次の例では、クライアント・アプリケーションがOracle NoSQL Databaseへの接続を試みる前に、ユーザーkrbuser
のKerberos資格証明をすでに取得していることを前提としています。ログイン・ファイルにセキュリティ・プロパティを指定する必要はありません。Subject.doAs
メソッドを使用して、資格証明を指定できます。
final LoginContext lc =
new LoginContext("oraclenosql", new TextCallbackHandler());
// Attempt authentication
lc.login();
// Get the authenticated Subject
final Subject subj = lc.getSubject();
// Specify configuration
final KVStoreConfig kvConfig =
new KVStoreConfig("mystore", "nosql1:5000");
// Set security properties SSL needed
final Properties securityProps = new Properties();
securityProps.setProperty(KVSecurityConstants.TRANSPORT_PROPERTY,
KVSecurityConstants.SSL_TRANSPORT_NAME);
securityProps.setProperty(
KVSecurityConstants.SSL_TRUSTSTORE_FILE_PROPERTY,
trustStore);
kvConfig.setSecurityProperties(securityProps);
// Set Kerberos properties
final Properties krbProperties = new Properties();
// Set service principal associated with helper host
krbProperties.setProperty(KVSecurityConstants.AUTH_KRB_SERVICES_PROPERTY,
hostName + ":" + servicePrincipal);
// Set default realm name, because the short name
// for user principal is used.
krbProperties.setProperty(KVSecurityConstants.AUTH_KRB_REALM_PROPERTY,
"EXAMPLE.COM");
// Specify Kerberos principal
final KerberosCredentials krbCreds =
new KerberosCredentials("krbuser", krbProperties);
// Get store using credentials in subject
KVStore kvstore = Subject.doAs(
subj, new PrivilegedExceptionAction<KVStore>() {
@Override
public KVStore run() throws Exception {
return KVStoreFactory.getStore(kvConfig, krbCreds, null);
}
});
この場合、KerberosCredentialsインスタンスは、指定されたユーザー・プリンシパルの資格証明をKDCから取得するのに必要なセキュリティ・プロパティを設定するために使用されます。