この演習では、Oracle Coherence*Extendクライアントにセキュリティを適用する方法について説明します。ここでは、Coherence APIのSecurityHelper、PofPrincipal、IdentityTransformer、IdentityAsserterおよびWrapperCacheServiceの使用について取り上げます。
Coherence*Extendでは、Coherenceキャッシュに対する広範なアクセスが許可されます。これには、デスクトップ・アプリケーション、リモート・サーバーおよびWide Area Network (WAN)接続を介して配置されているマシンが含まれます。
この章には次の項が含まれます:
Coherence*Extendは、クラスタの外部で実行されるExtendクライアントと、1台以上のキャッシュ・サーバーでホストされ、クラスタ内で実行されるプロキシ・サービスで構成されます。クライアントAPIにより、すべてのリクエストがプロキシにルーティングされます。プロキシは、パーティション化またはレプリケートされたキャッシュ・サービス、起動サービスなどのCoherenceのクラスタ化されたサービスに委任することによって、クライアント・リクエストに応答します。
Extendクライアントはクラスタの外部に存在するため、クラスタへのアクセス保護の問題が非常に重要になります。この章では、クライアントとクラスタ間のアクセス保護に使用可能な3つの技術を説明します。その技術とは、IDトークンベース・パスワード、資格が付与されるキャッシュ・サービスおよび起動サービスの使用などです。
これらのセキュリティ技術およびExtendクライアントの詳細な解説は、このチュートリアルの対象範囲ではありません。これらのトピックの詳細は、『Oracle Fusion Middleware Oracle Coherenceの保護』を参照してください。
トークンベースのセキュリティを実装すると、Extendクライアントとクラスタ内の拡張プロキシ間のアクセスを有効化できます。一般に、Extendクライアントと拡張プロキシ間のアクセスを有効化するには、次のファイルが必要です。
クライアント・アプリケーション・ファイル。クラスタにアクセスする機能を記述します。
キャッシュ構成ファイル。Extendクライアントと拡張プロキシのそれぞれに独自のキャッシュ構成がある場合。
オペレーション・オーバーライド・ファイル。デフォルトのオペレーショナル・デプロイメント・ディスクリプタの操作時および実行時の設定をオーバーライドします。
サーバー起動ファイル。拡張プロキシおよびクラスタ内のキャッシュ・サーバーに対して起動ファイルが存在する場合。
POF構成デプロイメント・ディスクリプタ。POFを使用してオブジェクトをシリアライズする際にカスタム・データ型を指定します。
トークンベース・セキュリティを追加するには、IDトランスフォーマおよびアサータの実装を指定する必要があります。このトランスフォーマは、クライアント側でトークンを生成し、アサータはクラスタ側でそれを検証します。
トークンベース・セキュリティを使用してクラスタにアクセスするExtendクライアントのアプリケーションを作成し、実行する手順は次のとおりです。
この章の例では、ロールベース・セキュリティ・ポリシーおよびキャッシュへのアクセス制御を定義するヘルパー・ファイルを参照します。これらの例に使用するための簡略マッピングのファイルが用意されています。
キャッシュ・アクセスはユーザーのロールによって決定されます。セキュリティ・ヘルパー・ファイルによっていくつかのロール(role_reader、role_writerおよびrole_admin)が定義されます。BuckarooBanzaiをROLE_ADMINにマッピングするなど、様々なユーザーのロールへのマッピングが定義されます。ROLE_ADMINを9にマッピングするなど、ロールの整数IDへのマッピングが定義されます。また、ヘルパー・ファイルでは、例で使用されるキャッシュ名および起動サービス名も定義されます。
このファイルの主要機能は、loginおよびcheckAccessのメソッドです。loginメソッドは、ユーザー名を取得して、簡略化された識別名(DN)を構成します。その後、ロールを名前と関連付けます。PofPrincipalは、Principal実装を提供します。
checkAccessメソッドは、認可コードが配置されている場所を示します。これによって、提供されたユーザー・ロールに基づいてユーザーがキャッシュにアクセス可能であるかどうかが判定されます。
新規のプロジェクトおよびセキュリティ・ヘルパー・ファイルを作成するには:
Eclipse IDEで、Java EEパースペクティブを選択してSecurityという名前の新規アプリケーション・クライアント・プロジェクトを作成します。「Configuration」ドロップダウン・リストから「CoherenceConfig」を選択します。「Application Client」モジュール・ページで、「Create a default main」が選択されていないことを確認します。
「Coherence」ページで、「Coherence12.1.2」のみを選択します。
プロジェクト作成の詳細は、「Eclipse IDEでの新規プロジェクトの作成」を参照してください。
SecurityExampleHelper.javaという名前で新規Javaファイルを作成します。パッケージ・パスがcom.oracle.handsonであることを確認します。
Javaクラスの作成の詳細は、「Javaクラスの作成」を参照してください。
例10-1に示されたコードをファイルにコピーします。
例10-1 セキュリティ・ヘルパー・ファイル
package com.oracle.handson;
import com.tangosol.io.pof.PofPrincipal;
import com.tangosol.net.security.SecurityHelper;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.security.Principal;
import javax.security.auth.Subject;
/**
* This class provides extremely simplified role based policies and access control.
*
*/
public class SecurityExampleHelper
{
// ----- static methods -------------------------------------------------
/**
* Login the user.
*
* @param sName the user name
*
* @return the authenticated user
*/
public static Subject login(String sName)
{
// For simplicity, just create a Subject. Normally, this would be
// done using JAAS.
String sUserDN = "CN=" + sName + ",OU=Yoyodyne";
Set setPrincipalUser = new HashSet();
setPrincipalUser.add(new PofPrincipal(sUserDN));
// Map the user to a role
setPrincipalUser.add(new PofPrincipal((String) s_mapUserToRole.get(sName)));
return new Subject(true, setPrincipalUser, new HashSet(), new HashSet());
}
/**
* Assert that a Subject is associated with the calling thread with a
* Principal representing the required role.
*
* @param sRoleRequired the role required for the operation
*
* @throws SecurityException if a Subject is not associated with the
* calling thread or does not have the specified role Principal
*/
public static void checkAccess(String sRoleRequired)
{
checkAccess(sRoleRequired, SecurityHelper.getCurrentSubject());
}
/**
* Assert that a Subject contains a Principal representing the required
* role.
*
* @param sRoleRequired the role required for the operation
*
* @param subject the Subject requesting access
*
* @throws SecurityException if a Subject is null or does not have the
* specified role Principal
*/
public static void checkAccess(String sRoleRequired, Subject subject)
{
if (subject == null)
{
throw new SecurityException("Access denied, authentication required");
}
Map mapRoleToId = s_mapRoleToId;
Integer nRoleRequired = (Integer) mapRoleToId.get(sRoleRequired);
for (Iterator iter = subject.getPrincipals().iterator(); iter.hasNext();)
{
Principal principal = (Principal) iter.next();
String sName = principal.getName();
if (sName.startsWith("role_"))
{
Integer nRolePrincipal = (Integer) mapRoleToId.get(sName);
if (nRolePrincipal == null)
{
// invalid role
break;
}
if (nRolePrincipal.intValue() >= nRoleRequired.intValue())
{
return;
}
}
}
throw new SecurityException("Access denied, insufficient privileges");
}
// ----- constants -----------------------------------------------------
public static final String ROLE_READER = "role_reader";
public static final String ROLE_WRITER = "role_writer";
public static final String ROLE_ADMIN = "role_admin";
/**
* The cache name for security examples
*/
public static final String SECURITY_CACHE_NAME = "security";
/**
* The name of the InvocationService used by security examples.
*/
public static String INVOCATION_SERVICE_NAME = "ExtendTcpInvocationService";
// ----- static data ---------------------------------------------------
/**
* The map keyed by user name with the value being the user's role.
* Represents which user is in which role.
*/
private static Map s_mapUserToRole = new HashMap();
/**
* The map keyed by role name with the value the role id.
* Represents the numeric role identifier.
*/
private static Map s_mapRoleToId = new HashMap();
// ----- static initializer ---------------------------------------------
static
{
// User to role mapping
s_mapUserToRole.put("BuckarooBanzai", ROLE_ADMIN);
s_mapUserToRole.put("JohnWhorfin", ROLE_WRITER);
s_mapUserToRole.put("JohnBigboote", ROLE_READER);
// Role to Id mapping
s_mapRoleToId.put(ROLE_ADMIN, Integer.valueOf(9));
s_mapRoleToId.put(ROLE_WRITER, Integer.valueOf(2));
s_mapRoleToId.put(ROLE_READER, Integer.valueOf(1));
}
}
IDトランスフォーマ(com.tangosol.net.security.IdentityTransformer)は、クライアント側のコンポーネントで、サブジェクトまたはプリンシパルをIDトークンに変換します。このトークンは、Coherenceでシリアライズ可能なデータ型である必要があります。Coherenceは、実行時にこのトークンを自動的にシリアライズして、接続リクエストの一部としてプロキシに送信します。
IDトランスフォーマの実装を作成するには:
Securityプロジェクトに、PasswordIdentityTransformerという名前のJavaクラスを新規作成します。
詳細は、「Javaクラスの作成」を参照してください。
IdentityTransformerインタフェースをインポートします。PasswordIdentityTransformerクラスがIdentityTransformerインタフェースを実装することを確認します。
transformIdentityメソッドを実装して、次のタスクを実行するようにします。
サブジェクトが存在し、完全であるかどうかのテスト
サブジェクトからのプリンシパル名の取得およびString配列への保存
POFデータ型としてシリアライズ可能な、パスワードとプリンシパル名の組合せによるトークンの構成
例10-2は、考えられるPasswordIdentityTransformerクラスの実装を示しています。
例10-2 IDトランスフォーマの実装例
package com.oracle.handson;
import com.tangosol.net.security.IdentityTransformer;
import java.security.Principal;
import java.util.Iterator;
import java.util.Set;
import javax.security.auth.Subject;
import com.tangosol.net.Service;
/**
* PasswordIdentityTransformer creates a security token that contains the
* required password and then adds a list of Principal names.
*
*/
public class PasswordIdentityTransformer
implements IdentityTransformer
{
// ----- IdentityTransformer interface ----------------------------------
/**
* Transform a Subject to a token that asserts an identity.
*
* @param subject the Subject representing a user.
*
* @return the token that asserts identity.
*
* @throws SecurityException if the identity transformation fails.
*/
public Object transformIdentity(Subject subject, Service service)
throws SecurityException
{
// The service is not needed so the service argument is being ignored.
// It could be used, for example, if there were different token types
// required per service.
if (subject == null)
{
throw new SecurityException("Incomplete Subject");
}
Set setPrincipals = subject.getPrincipals();
if (setPrincipals.isEmpty())
{
throw new SecurityException("Incomplete Subject");
}
String[] asPrincipalName = new String[setPrincipals.size() + 1];
int i = 0;
asPrincipalName[i++] = System.getProperty("coherence.password",
"secret-password");
for (Iterator iter = setPrincipals.iterator(); iter.hasNext();)
{
asPrincipalName[i++] = ((Principal) iter.next()).getName();
}
// The token consists of the password plus the principal names as an
// array of pof-able types, in this case strings.
return asPrincipalName;
}
}
IDアサータ(com.tangosol.net.security.IdentityAsserter)は、拡張プロキシ・サービスをホストするキャッシュ・サーバー上のクラスタ側のコンポーネントです。アサータは、ExtendクライアントでIDトランスフォーマによって作成されたトークンに、クラスタへのアクセスに必要な資格証明が格納されているかを検証します。
IDアサータの実装を作成するには:
Securityプロジェクトに、PasswordIdentityAsserterという名前のJavaクラスを新規作成します。
詳細は、「Javaクラスの作成」を参照してください。
IdentityAsserterインタフェースをインポートします。PasswordIdentityAsserterクラスがIdentityAsserterインタフェースを実装することを確認します。
次のタスクが実行されるように、assertIdentityメソッドを実装します。
トークンに正しいパスワードが格納されていることおよびパスワードがトークン内の最初の名前であることを検証します。
例10-3は、考えられるPasswordIdentityAsserterクラスの実装を示しています。
例10-3 IDアサータの実装例
package com.oracle.handson;
import com.tangosol.io.pof.PofPrincipal;
import com.tangosol.net.security.IdentityAsserter;
import java.util.HashSet;
import java.util.Set;
import javax.security.auth.Subject;
import com.tangosol.net.Service;
/**
* PasswordIdentityAsserter asserts that the security token contains the
* required password and then constructs a Subject based on a list of
* Principal names.
*
*/
public class PasswordIdentityAsserter
implements IdentityAsserter
{
// ----- IdentityAsserter interface -------------------------------------
/**
* Asserts an identity based on a token-based identity assertion.
*
* @param oToken the token that asserts identity.
*
* @return a Subject representing the identity.
*
* @throws SecurityException if the identity assertion fails.
*/
public Subject assertIdentity(Object oToken, Service service)
throws SecurityException
{
// The service is not needed so the service argument is being ignored.
// It could be used, for example, if there were different token types
// required per service.
if (oToken instanceof Object[])
{
String sPassword = System.getProperty(
"coherence.password", "secret-password");
Set setPrincipalUser = new HashSet();
Object[] asName = (Object[]) oToken;
// first name must be password
if (((String) asName[0]).equals(sPassword))
{
// prints the user name to server shell to ensure we are
// communicating with it and to ensure user is validated
System.out.println("Password validated for user: " + asName[1]);
for (int i = 1, len = asName.length; i < len; i++)
{
setPrincipalUser.add(new PofPrincipal((String)asName[i]));
}
return new Subject(true, setPrincipalUser, new HashSet(),
new HashSet());
}
}
throw new SecurityException("Access denied");
}
}
キャッシュの参照の取得時にパスワードを必要とするJavaファイルを作成します。SecurityExampleHelper.login("BuckarooBanzai")を使用して、トークンを生成するSecurityExampleHelperファイルのloginメソッドをコールします。実行時に、ユーザー名がSecurityExampleHelperクラスで定義されたサブジェクトと関連付けられます。トークンは、PasswordIdentityTransformerクラスによってこのサブジェクトから生成され、PasswordIdentityAsserterクラスによって接続リクエストの一部として検証されます。検証が成功すると、プロキシへの接続およびキャッシュの参照の権限が付与されます。Subject.doasメソッドを使用して、セキュリティ・コンテキストでサブジェクトを利用できるようにします。
PasswordExampleという名前のSecurityプロジェクトに、mainメソッドを使用して新たなJavaクラスを作成します。
詳細は、「Javaクラスの作成」を参照してください。
キャッシュの参照を取得するmainメソッドを実装します。
SecurityExampleHelper.loginメソッドを使用して、ユーザーBuckarooBanzaiのサブジェクトを取得します。
doAsメソッドを実装して、Javaセキュリティ・コンテキストのサブジェクト・パートを作成します。このサブジェクトは、後続のいずれのコードでも利用できます。この例では、定義されたロールを基準にして、ユーザーがキャッシュにアクセスできるかどうかを検証するためにdoAsメソッドが実装されます。
例10-4は、考えられるPasswordExampleの実装を示しています。
例10-4 パスワード・サンプルを実行する実装例
package com.oracle.handson;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;
import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import javax.security.auth.Subject;
import com.tangosol.net.Service;
/**
* This class shows how a Coherence Proxy can require a password to get a
* reference to a cache.
* <p>
* The PasswordIdentityTransformer will generate a security token that
* contains the password. The PasswordIdentityAsserter will validate the
* security token to enforce the password. The token generation and
* validation occurs automatically when a connection to the proxy is made.
*
*/
public class PasswordExample
{
// ----- static methods -------------------------------------------------
/**
* Get a reference to the cache. Password will be required.
*/
public static void main (String[] args){
getCache();
}
public static void getCache()
{
System.out.println("------password example begins------");
Subject subject = SecurityExampleHelper.login("BuckarooBanzai");
try
{
NamedCache cache = (NamedCache) Subject.doAs(
subject, new PrivilegedExceptionAction()
{
public Object run()
throws Exception
{
NamedCache cache;
cache = CacheFactory.getCache(
SecurityExampleHelper.SECURITY_CACHE_NAME);
System.out.println("------password example succeeded------");
return cache;
}
});
}
catch (Exception e)
{
// get exception if the password is invalid
System.out.println("Unable to connect to proxy");
e.printStackTrace();
}
System.out.println("------password example completed------");
}
}
IDトランスフォーマ(Extendクライアント上でSubjectをトークンに変換するクラス)およびIDアサータ(クラスタ上でトークンを検証するクラス)を定義するクラスを識別する、オペレーション・オーバーライド・ファイル(tangosol-coherence-override.xml)を構成します。
「Project Explorer」ウィンドウから、tangosol-coherence-override.xmlファイルを開きます。ファイルはSecurity/appClientModuleディレクトリの下位にあります。
security-configスタンザ内のidentity-transformer要素とidentity-asserter要素を使用して、PasswordIdentityTransformerとPasswordIdentityAsserterのそれぞれの実装クラスへのフルパスを識別します。subject-scopeパラメータをtrueに設定して、現在のセキュリティ・コンテキストのIDをキャッシュおよびクライアントに返されるリモート起動サービス参照に関連付けます。
例10-5は、考えられるtangosol-coherence-override.xmlファイルの実装を示しています。
例10-5 IDトランスフォーマとアサータの指定
<?xml version="1.0" encoding="UTF-8"?>
<coherence xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config http://xmlns.oracle.com/coherence/coherence-operational-config/1.2/coherence-operational-config.xsd">
<!--coherence-version:12.1.2-->
<security-config>
<identity-asserter>
<class-name>com.oracle.handson.PasswordIdentityAsserter</class-name>
</identity-asserter>
<identity-transformer>
<class-name>com.oracle.handson.PasswordIdentityTransformer</class-name>
</identity-transformer>
<subject-scope>true</subject-scope>
</security-config>
</coherence>
Extendクライアントのキャッシュ構成ファイルは、キャッシュ操作をクラスタ内の拡張プロキシにルーティングします。実行時に、キャッシュ操作はローカルで実行されるのではなく、拡張プロキシ・サービスに送信されます。
Extendクライアントのキャッシュ構成ファイルを作成するには:
「Project explorer」ウィンドウから、coherence-cache-config.xmlファイルを開きます。ファイルはSecurity/appClientModuleディレクトリの下位にあります。
ファイルをclient-cache-config.xmlという名前で保存します。
Extendクライアント・キャッシュ構成を作成します。次のリストは、主な要素の一部を取り上げています。
cache-name要素を使用して、キャッシュの名前としてsecurityを定義します。クラスタ側のキャッシュ構成でもsecurityという名前のキャッシュが定義されている必要があります。
remote-cache-schemeタンザを使用して、リモート・キャッシュに関する詳細を定義します。
tcp-initiatorスタンザのaddress要素とport要素を使用して、ポート9099でlocalhostアドレスのリスニングを行う拡張プロキシ・サービスを識別します。
defaultsと値pofのserializerを使用して、カスタムPOF構成ファイルのシリアライザ(この章の後述部分で作成します)をコールします。
例10-6は、考えられるclient-cache-config.xmlファイルの実装を示しています。
例10-6 Extendクライアント・キャッシュ構成ファイルのサンプル
<?xml version="1.0"?>
<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
<defaults>
<serializer>pof</serializer>
</defaults>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>security</cache-name>
<scheme-name>examples-remote</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<remote-cache-scheme>
<scheme-name>examples-remote</scheme-name>
<service-name>ExtendTcpCacheService</service-name>
<initiator-config>
<tcp-initiator>
<remote-addresses>
<socket-address>
<address system-property="tangosol.coherence.proxy.address">localhost</address>
<port system-property="tangosol.coherence.proxy.port">9099</port>
</socket-address>
</remote-addresses>
</tcp-initiator>
</initiator-config>
</remote-cache-scheme>
<remote-invocation-scheme>
<scheme-name>remote-invocation-scheme</scheme-name>
<service-name>ExtendTcpInvocationService</service-name>
<initiator-config>
<connect-timeout>2s</connect-timeout>
<tcp-initiator>
<remote-addresses>
<socket-address>
<address system-property="tangosol.coherence.proxy.address">localhost</address>
<port system-property="tangosol.coherence.proxy.port">9099</port>
</socket-address>
</remote-addresses>
</tcp-initiator>
<outgoing-message-handler>
<request-timeout>5s</request-timeout>
</outgoing-message-handler>
</initiator-config>
</remote-invocation-scheme>
</caching-schemes>
</cache-config>
拡張プロキシ・サービスのキャッシュ構成ファイルを作成するには:
「Project explorer」ウィンドウから、coherence-cache-config.xmlファイルを開きます。ファイルはSecurity/appClientModuleディレクトリの下位にあります。
ファイルをexamples-cache-config.xmlという名前で保存します。
拡張プロキシ・キャッシュ構成ファイルを構成します。次のリストは、主な要素の一部を取り上げています。
cache-name要素を使用して、キャッシュの名前としてsecurityを定義します。Extendクライアントのキャッシュ構成でもsecurityという名前のキャッシュが定義されている必要があります。
acceptor-configスタンザのaddress要素とport要素を使用して、ポート9099でlocalhostアドレスのリスニングを行う拡張プロキシ・サービスを識別します。
システム・プロパティtangosol.coherence.extend.enabledのautostart要素を使用して、キャッシュ・サーバーでのプロキシ・サービスの実行を防止します。
defaultsと値pofのserializerを使用して、カスタムPOF構成ファイルのシリアライザ(この章の後述部分で作成します)をコールします。
例10-7は、考えられるexamples-cache-config.xmlファイルの実装を示しています。
例10-7 プロキシ・サーバーのキャッシュ構成ファイルのサンプル
<?xml version="1.0"?>
<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
<defaults>
<serializer>pof</serializer>
</defaults>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>security</cache-name>
<scheme-name>ExamplesPartitionedPofScheme</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<distributed-scheme>
<scheme-name>ExamplesPartitionedPofScheme</scheme-name>
<service-name>PartitionedPofCache</service-name>
<backing-map-scheme>
<local-scheme>
<!-- each node will be limited to 32MB -->
<high-units>32M</high-units>
<unit-calculator>binary</unit-calculator>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
<!--
Proxy Service scheme that allows remote clients to connect to the
cluster over TCP/IP.
-->
<proxy-scheme>
<scheme-name>secure-proxy</scheme-name>
<service-name>ProxyService</service-name>
<thread-count system-property="tangosol.coherence.extend.threads">2</thread-count>
<acceptor-config>
<tcp-acceptor>
<local-address>
<address system-property="tangosol.coherence.extend.address">localhost</address>
<port system-property="tangosol.coherence.extend.port">9099</port>
</local-address>
</tcp-acceptor>
</acceptor-config>
<autostart system-property="tangosol.coherence.extend.enabled">false</autostart>
</proxy-scheme>
</caching-schemes>
</cache-config>
キャッシュ・サーバー・クラスタ・ノードの起動構成を作成します。この構成には、プロキシ・サービスおよびクラスタ側のキャッシュ構成ファイルを指定するシステム・プロパティを含める必要があります。また、クラス・パス上のアプリケーション・クラス・ファイルおよびXML構成ファイルも含める必要があります。
キャッシュ・サーバーの起動ファイルを作成するには:
Eclipseで、起動構成を作成します。Securityプロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Name」フィールドにSecurityCacheServerと入力します。
「Main」タブの「Project」フィールドで「Browse」をクリックして「Security」プロジェクトを選択します。「Include system libraries when searching for a main class」を選択して、「Main class」フィールドの「Search」ボタンをクリックします。「Select Main Type」ダイアログ・ボックスの「Select type」フィールドにDefaultCacheServerを入力します。「DefaultCacheServer - com.tangosol.net」を選択して「OK」をクリックします。「Apply」をクリックします。
「Coherence」タブに、クラスタ側のキャッシュ構成ファイルの名前と絶対パスを入力します(この例ではC:\home\oracle\workspace\Security\appClientModule\examples-cache-config.xml)。「Local storage」フィールドで、「Enabled (cache server)」を選択します。「Cluster port」フィールドに3155などの一意の値を入力します。「Apply」をクリックします。
「Classpath」タブが図10-1のように表示されます。
「Common」タブの「Shared file」フィールドで、「Browse」をクリックしてSecurityプロジェクトを選択します。「Apply」をクリックします。
クラスタ内のキャッシュ・サーバー上で拡張プロキシサービスを起動する構成を作成します。Extendクライアントはこのサービスに接続します。この構成には、プロキシ・サービスおよびクラスタ側のキャッシュ構成ファイルを指定するシステム・プロパティを含める必要があります。また、クラス・パス上のアプリケーション・クラス・ファイルおよびXML構成ファイルも含める必要があります。
この例の場合、プロキシ・サービスの起動が構成されるキャッシュ・サーバーの構成は、キャッシュ・サーバーの起動構成と同じですが、拡張プロキシを有効にするシステム・プロパティが含まれます。
プロキシ・サービスを含むキャッシュ・サーバーの起動ファイルを作成するには:
Eclipseで、起動構成を作成します。Securityプロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Name」フィールドにSecurityRunProxyと入力します。
「Main」タブの「Project」フィールドで「Browse」をクリックして「Security」プロジェクトを選択します。「Include system libraries when searching for a main class」を選択して、「Main class」フィールドの「Search」ボタンをクリックします。「Select Main Type」ダイアログ・ボックスの「Select type」フィールドにDefaultCacheServerを入力します。「DefaultCacheServer - com.tangosol.net」を選択して「OK」をクリックします。「Apply」をクリックします。
「Coherence」タブに、クラスタ側のキャッシュ構成ファイルの名前と絶対パスを入力します(この例ではC:\home\oracle\workspace\Security\appClientModule\examples-cache-config.xml)。「Local storage」フィールドで、「Enabled (cache server)」を選択します。「Cluster port」フィールドに3155などの一意の値を入力します。「Apply」をクリックします。
「Arguments」タブで、システム・プロパティ-Dtangosol.coherence.extend.enabled=trueを入力して、「VM arguments」フィールドのプロキシ・サービスを指定します。
「Classpath」タブが図10-3のように表示されます。
「Common」タブの「Shared file」フィールドで、「Browse」をクリックしてSecurityプロジェクトを選択します。「Apply」をクリックします。
パスワード・サンプルを実行して、トークンの生成、検証、プロキシ・サービスへの引渡しを行います。
PasswordExample.javaファイルの実行構成を作成します。
「Project Explorer」でPasswordExample.javaを右クリックして、「Run As」→「Run Configurations」を選択します。
「New launch configuration」アイコンをクリックします。PasswordExampleが「Name」フィールドに、Securityが「Project」フィールドに、com.oracle.handson.PasswordExampleが「Main class」フィールドに表示されていることを確認します。「Apply」をクリックします。
「Coherence」タブの「Cache configuration descriptor」フィールドにクライアント・キャッシュ構成ファイルへのパスC:\home\oracle\workspace\Security\appClientModule\client-cache-config.xmlを入力します「Local cache」フィールドで、「Disabled (cache client)」を選択します。「Cluster port」フィールドに3155などの一意の値を入力します。
「Classpath」タブが図10-4のように表示されます。
実行中のキャッシュ・サーバーがあれば停止します。詳細は、「キャッシュ・サーバーの停止」を参照してください。
セキュリティ・プロキシ・サーバー、セキュリティ・キャッシュ・サーバー、続いてPasswordExample.javaプログラムを実行します。
プロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスから、SecurityRunProxy構成を実行します。
プロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスから、SecurityCacheServer構成を実行します。
「Project Explorer」でPasswordExample.javaファイルを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスでPasswordExampleを選択し、「Run」をクリックします。
Eclipseコンソールに、PasswordExampleプログラムの出力が例10-8のように表示されます。これにはパスワード・サンプルの開始、プロキシ・サーバーへのソケットのオープンおよびこの例の完了が示されます。
例10-8 Eclipseコンソールでのパスワード・サンプルの出力
------password example begins------2012-08-21 17:58:37.081/0.390 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence.xml" 2012-08-21 17:58:37.128/0.437 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml" 2012-08-21 17:58:37.175/0.484 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "file:/C:/home/oracle/workspace/Security/build/classes/tangosol-coherence-override.xml" 2012-08-21 17:58:37.175/0.484 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-config.xml" is not specified 2012-08-21 17:58:37.191/0.500 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-builder-config.xml" is not specified 2012-08-21 17:58:37.191/0.500 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified Oracle Coherence Version 12.1.2.0 Build 36845 Grid Edition: Development mode Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 2012-08-21 17:58:37.425/0.734 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/C:/home/oracle/workspace/Security/appClientModule/client-cache-config.xml" 2012-08-21 17:58:37.769/1.078 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory 2012-08-21 17:58:37.878/1.187 Oracle Coherence GE 12.1.2.0 <D5> (thread=ExtendTcpCacheService:TcpInitiator, member=n/a): Started: TcpInitiator{Name=ExtendTcpCacheService:TcpInitiator, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), Serializer=com.tangosol.io.DefaultSerializer, PingInterval=0, PingTimeout=0, RequestTimeout=0, ConnectTimeout=0, SocketProvider=com.oracle.common.internal.net.MultiplexedSocketProvider@10713de, RemoteAddresses=WrapperSocketAddressProvider{Providers=[[tpfaeffl-lap7/130.35.99.202:9099]]}, SocketOptions{LingerTimeout=0, KeepAliveEnabled=true, TcpDelayEnabled=false}} 2012-08-21 17:58:37.894/1.203 Oracle Coherence GE 12.1.2.0 <D5> (thread=main, member=n/a): Connecting Socket to 130.35.99.202:9099 2012-08-21 17:58:37.894/1.203 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Connected Socket to 130.35.99.202:9099------password example succeeded------------password example completed------
プロキシ・サーバー・シェルの応答は、例10-9のように表示されます。これには、識別名からのCNおよびOUの値およびパスワードが検証されたかどうかがリスト表示されます。
例10-9 プロキシ・サービス・シェルを実行するキャッシュ・サーバーからの応答
2012-08-21 17:57:44.941/1.750 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence.xml"
2012-08-21 17:57:44.987/1.796 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2012-08-21 17:57:45.034/1.843 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "file:/C:/home/oracle/workspace/Security/build/classes/tangosol-coherence-override.xml"
2012-08-21 17:57:45.034/1.843 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-config.xml" is not specified
2012-08-21 17:57:45.050/1.859 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-builder-config.xml" is not specified
2012-08-21 17:57:45.050/1.859 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
Oracle Coherence Version 12.1.2.0 Build 36845
Grid Edition: Development mode
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2012-08-21 17:57:45.534/2.343 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/C:/home/oracle/workspace/Security/appClientModule/examples-cache-config.xml"
2012-08-21 17:57:47.066/3.875 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory
2012-08-21 17:57:48.097/4.906 Oracle Coherence GE 12.1.2.0 <D4> (thread=main, member=n/a): TCMP bound to /130.35.99.202:8088 using SystemDatagramSocketProvider
2012-08-21 17:57:51.550/8.359 Oracle Coherence GE 12.1.2.0 <Info> (thread=Cluster, member=n/a): Created a new cluster "cluster:0x47DB" with Member(Id=1, Timestamp=2012-08-21 17:57:48.222, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:1500, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1)
2012-08-21 17:57:51.566/8.375 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Started cluster Name=cluster:0x47DB
Group{Address=224.12.1.0, Port=3155, TTL=4}
MasterMemberSet(
ThisMember=Member(Id=1, Timestamp=2012-08-21 17:57:48.222, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:1500, Role=CoherenceServer)
OldestMember=Member(Id=1, Timestamp=2012-08-21 17:57:48.222, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:1500, Role=CoherenceServer)
ActualMemberSet=MemberSet(Size=1
Member(Id=1, Timestamp=2012-08-21 17:57:48.222, Address=130.35.99.202:8088, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:1500, Role=CoherenceServer)
)
MemberId|ServiceVersion|ServiceJoined|MemberState
1|12.1.2|2012-08-21 17:57:48.222|JOINED
RecycleMillis=1200000
RecycleSet=MemberSet(Size=0
)
)
TcpRing{Connections=[]}
IpMonitor{Addresses=0}
2012-08-21 17:57:51.706/8.515 Oracle Coherence GE 12.1.2.0 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
2012-08-21 17:57:51.800/8.609 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=1): Loaded Reporter configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/reports/report-group.xml"
2012-08-21 17:57:52.144/8.953 Oracle Coherence GE 12.1.2.0 <D5> (thread=DistributedCache:PartitionedPofCache, member=1): Service PartitionedPofCache joined the cluster with senior service member 1
2012-08-21 17:57:52.378/9.187 Oracle Coherence GE 12.1.2.0 <Info> (thread=Proxy:ProxyService:TcpAcceptor, member=1): TcpAcceptor now listening for connections on 130.35.99.202:9099
2012-08-21 17:57:52.394/9.203 Oracle Coherence GE 12.1.2.0 <D5> (thread=Proxy:ProxyService:TcpAcceptor, member=1): Started: TcpAcceptor{Name=Proxy:ProxyService:TcpAcceptor, State=(SERVICE_STARTED), ThreadCount=2, HungThreshold=0, TaskTimeout=0, Codec=Codec(Format=POF), Serializer=com.tangosol.io.DefaultSerializer, PingInterval=0, PingTimeout=0, RequestTimeout=0, SocketProvider=com.oracle.common.internal.net.MultiplexedSocketProvider@fe8610, LocalAddress=WrapperSocketAddressProvider{Providers=[[tpfaeffl-lap7/130.35.99.202:9099]]}, SocketOptions{LingerTimeout=0, KeepAliveEnabled=true, TcpDelayEnabled=false}, ListenBacklog=0, BufferPoolIn=BufferPool(BufferSize=2KB, BufferType=DIRECT, Capacity=Unlimited), BufferPoolOut=BufferPool(BufferSize=2KB, BufferType=DIRECT, Capacity=Unlimited)}
2012-08-21 17:57:52.394/9.203 Oracle Coherence GE 12.1.2.0 <D5> (thread=Proxy:ProxyService, member=1): Service ProxyService joined the cluster with senior service member 1
2012-08-21 17:57:52.409/9.218 Oracle Coherence GE 12.1.2.0 <Info> (thread=NameService:TcpAcceptor, member=1): TcpAcceptor now listening for connections on 130.35.99.202:8088.3
2012-08-21 17:57:52.409/9.218 Oracle Coherence GE 12.1.2.0 <D5> (thread=NameService:TcpAcceptor, member=1): Started: TcpAcceptor{Name=NameService:TcpAcceptor, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), Serializer=com.tangosol.net.internal.NameServicePofContext, PingInterval=0, PingTimeout=0, RequestTimeout=0, SocketProvider=com.oracle.common.internal.net.MultiplexedSocketProvider@fe8610, LocalAddress=WrapperSocketAddressProvider{Providers=[WrapperSocketAddressProvider{Providers=[Address=130.35.99.202:8088]}]}, SocketOptions{LingerTimeout=0, KeepAliveEnabled=true, TcpDelayEnabled=false}, ListenBacklog=0, BufferPoolIn=BufferPool(BufferSize=2KB, BufferType=DIRECT, Capacity=Unlimited), BufferPoolOut=BufferPool(BufferSize=2KB, BufferType=DIRECT, Capacity=Unlimited)}
2012-08-21 17:57:52.409/9.218 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=1):
Services
(
ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=12.1.2, OldestMemberId=1}
InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=12.1.2, OldestMemberId=1}
PartitionedCache{Name=PartitionedPofCache, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
ProxyService{Name=ProxyService, State=(SERVICE_STARTED), Id=3, Version=12.1.2, OldestMemberId=1}
)
Started DefaultCacheServer...
2012-08-21 17:58:14.222/31.031 Oracle Coherence GE 12.1.2.0 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2012-08-21 17:58:14.066, Address=130.35.99.202:8090, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:2212, Role=CoherenceServer) joined Cluster with senior member 1
2012-08-21 17:58:14.269/31.078 Oracle Coherence GE 12.1.2.0 <D5> (thread=Cluster, member=1): Member 2 joined Service Management with senior member 1
2012-08-21 17:58:14.425/31.234 Oracle Coherence GE 12.1.2.0 <D5> (thread=Cluster, member=1): Member 2 joined Service PartitionedPofCache with senior member 1
2012-08-21 17:58:14.534/31.343 Oracle Coherence GE 12.1.2.0 <D5> (thread=DistributedCache:PartitionedPofCache, member=1): Transferring 0KB of backup[1] for PartitionSet{128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256} to member 2
2012-08-21 17:58:14.737/31.546 Oracle Coherence GE 12.1.2.0 <D5> (thread=DistributedCache:PartitionedPofCache, member=1): Transferring primary PartitionSet{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127} to member 2 requesting 128
Password validated for user: CN=BuckarooBanzai,OU=Yoyodyne
Password validated for user: CN=BuckarooBanzai,OU=Yoyodyne
Password validated for user: CN=BuckarooBanzai,OU=Yoyodyne
この項では、クラスタへのアクセスにロールベースのポリシーを使用するサンプルを作成する方法を説明します。このコードは、特定のロールに割り当てられたユーザーIDを使用して、ログインし、サブジェクトを取得します。そのサブジェクトのコンテキストで実行中のキャッシュ参照を取得して、様々なキャッシュ操作を試行します。ユーザーに付与されたロールに応じて、キャッシュ操作が許可または拒否されます。このサンプルのロールのマッピングおよびロールベースの認可は簡略化されており、実際のセキュリティ保護での使用は想定していません。
たとえば、ライター・ロールのユーザーは、putとgetのメソッドを使用できます。リーダー・ロールのユーザーは、getメソッドを使用できますが、putメソッドは使用できません。ライター・ロールのユーザーは、キャッシュを破棄できませんが、管理ロールのユーザーはできます。
サブジェクトのコンテキストでキャッシュ参照が作成されると、IDが永続的にその参照と関連付けられることに注意してください。キャッシュ参照の使用すべてがそのIDの代理として行われます。
この例では、前の項で作成したPasswordIdentityTransformerクラスとPasswordIdentityAsserterクラスを使用します。PasswordIdentityTransformerクラスは、パスワード、ユーザーIDおよびロールを格納するセキュリティ・トークンを生成します。PasswordIdentityAsserterクラス(プロキシで実行)は、セキュリティ・トークンを検証してパスワードを強制し、適切なユーザーIDとロールでサブジェクトを構成します。セキュリティ・トークンの生成とアサーションは自動的に実行されます。
サンプルを作成するには:
ユーザー・ロールを基準にして、キャッシュ・メソッドへのアクセスを可能にするJavaファイルを作成します。これを行うには、Coherence*Extendを使用し、クライアントから渡されたSubjectオブジェクトを使用して、ラップされたNamedCacheにアクセス権を適用できます。この実装では、指定されたロールのクライアントのみに、ラップされたNamedCacheへのアクセスが許可されます。
この項で作成するクラスは、com.tangosol.net.cache.WrapperNamedCacheクラスを拡張します。このクラスは、NamedCacheインタフェースのメソッドの保護を可能にする便利なファンクションです。
キャッシュ・メソッドへのアクセスが可能なユーザー・ロールを決定するため、キャッシュ・メソッドの実装のそれぞれにSecurityExampleHelper.checkAccessメソッドのコールをインクルードします。checkAccessに対する引数として、メソッドへのアクセスを許可するユーザー・ロールを指定します。superのコールによって実装を終了します。
たとえば、次のコードでは、adminロールのユーザーがキャッシュを破棄できることが指定されます。
public void destroy()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_ADMIN);
super.destroy();
}
このサンプルでは、readerロールのユーザーにaggregateメソッドのコールが許可されます。
public Object aggregate(Filter filter, EntryAggregator agent)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.aggregate(filter, agent);
}
キャッシュ・メソッドをコールできるユーザーを決定するファイルを作成するには:
SecurityプロジェクトにEntitledNamedCacheという名前のJavaクラスを新規作成します。
詳細を確認する場合は、「Javaクラスの作成」を参照してください。
このクラスがWrapperNamedCacheをインポートして拡張することを確認します。
Filter、MapListener、ValueExtractor、Collection、Comparator、Map、ServiceおよびSetの各クラスをインポートします。WrapperNamedCache内のメソッド(および拡張によるEntitledNamedCache)ではこれらのデータ型の引数が使用されます。
特定のロールのユーザーのみにメソッドのコールが許可されるようにして、EntitledNamedCacheにメソッドを実装します。
例10-10は、考えられるEntitledNamedCacheの実装を示しています。
例10-10 資格が付与される名前付きキャッシュ
package com.oracle.handson;
import com.tangosol.net.NamedCache;
import com.tangosol.net.security.SecurityHelper;
import com.tangosol.net.Service;
import com.tangosol.net.cache.WrapperNamedCache;
import com.tangosol.util.Filter;
import com.tangosol.util.MapEvent;
import com.tangosol.util.MapListener;
import com.tangosol.util.ValueExtractor;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import javax.security.auth.Subject;
/**
* Example WrapperNamedCache that demonstrates how entitlements can be applied
* to a wrapped NamedCache using the Subject passed from the client through
* Coherence*Extend. This implementation only allows clients with a specified
* role to access the wrapped NamedCache.
*
*/
public class EntitledNamedCache
extends WrapperNamedCache
{
/**
* Create a new EntitledNamedCache.
*
* @param cache the wrapped NamedCache
*/
public EntitledNamedCache(NamedCache cache)
{
super(cache, cache.getCacheName());
}
// ----- NamedCache interface -------------------------------------------
/**
* {@inheritDoc}
*/
public void release()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
super.release();
}
/**
* {@inheritDoc}
*/
public void destroy()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_ADMIN);
super.destroy();
}
/**
* {@inheritDoc}
*/
public Object put(Object oKey, Object oValue, long cMillis)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.put(oKey, oValue, cMillis);
}
/**
* {@inheritDoc}
*/
public void addMapListener(MapListener listener)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
super.addMapListener(new EntitledMapListener(listener));
}
/**
* {@inheritDoc}
*/
public void removeMapListener(MapListener listener)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.removeMapListener(listener);
}
/**
* {@inheritDoc}
*/
public void addMapListener(MapListener listener, Object oKey, boolean fLite)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
super.addMapListener(new EntitledMapListener(listener), oKey, fLite);
}
/**
* {@inheritDoc}
*/
public void removeMapListener(MapListener listener, Object oKey)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.removeMapListener(listener, oKey);
}
/**
* {@inheritDoc}
*/
public void addMapListener(MapListener listener, Filter filter, boolean fLite)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
super.addMapListener(new EntitledMapListener(listener), filter, fLite);
}
/**
* {@inheritDoc}
*/
public void removeMapListener(MapListener listener, Filter filter)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.removeMapListener(listener, filter);
}
/**
* {@inheritDoc}
*/
public int size()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.size();
}
/**
* {@inheritDoc}
*/
public void clear()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.clear();
}
/**
* {@inheritDoc}
*/
public boolean isEmpty()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.isEmpty();
}
/**
* {@inheritDoc}
*/
public boolean containsKey(Object oKey)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.containsKey(oKey);
}
/**
* {@inheritDoc}
*/
public boolean containsValue(Object oValue)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.containsValue(oValue);
}
/**
* {@inheritDoc}
*/
public Collection values()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.values();
}
/**
* {@inheritDoc}
*/
public void putAll(Map map)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.putAll(map);
}
/**
* {@inheritDoc}
*/
public Set entrySet()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.entrySet();
}
/**
* {@inheritDoc}
*/
public Set keySet()
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.keySet();
}
/**
* {@inheritDoc}
*/
public Object get(Object oKey)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.get(oKey);
}
/**
* {@inheritDoc}
*/
public Object remove(Object oKey)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.remove(oKey);
}
/**
* {@inheritDoc}
*/
public Object put(Object oKey, Object oValue)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.put(oKey, oValue);
}
/**
* {@inheritDoc}
*/
public Map getAll(Collection colKeys)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.getAll(colKeys);
}
/**
* {@inheritDoc}
*/
public boolean lock(Object oKey, long cWait)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.lock(oKey, cWait);
}
/**
* {@inheritDoc}
*/
public boolean lock(Object oKey)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.lock(oKey);
}
/**
* {@inheritDoc}
*/
public boolean unlock(Object oKey)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.unlock(oKey);
}
/**
* {@inheritDoc}
*/
public Set keySet(Filter filter)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.keySet(filter);
}
/**
* {@inheritDoc}
*/
public Set entrySet(Filter filter)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.entrySet(filter);
}
/**
* {@inheritDoc}
*/
public Set entrySet(Filter filter, Comparator comparator)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.entrySet(filter, comparator);
}
/**
* {@inheritDoc}
*/
public void addIndex(ValueExtractor extractor, boolean fOrdered, Comparator comparator)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.addIndex(extractor, fOrdered, comparator);
}
/**
* {@inheritDoc}
*/
public void removeIndex(ValueExtractor extractor)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.removeIndex(extractor);
}
/**
* {@inheritDoc}
*/
public Object invoke(Object oKey, EntryProcessor agent)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.invoke(oKey, agent);
}
/**
* {@inheritDoc}
*/
public Map invokeAll(Collection collKeys, EntryProcessor agent)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.invokeAll(collKeys, agent);
}
/**
* {@inheritDoc}
*/
public Map invokeAll(Filter filter, EntryProcessor agent)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.invokeAll(filter, agent);
}
/**
* {@inheritDoc}
*/
public Object aggregate(Collection collKeys, EntryAggregator agent)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.aggregate(collKeys, agent);
}
/**
* {@inheritDoc}
*/
public Object aggregate(Filter filter, EntryAggregator agent)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return super.aggregate(filter, agent);
}
// ----- inner class ----------------------------------------------------
/**
* Example MapListener that adds authorization to map events.
*/
public class EntitledMapListener
implements MapListener
{
// ----- constructors -------------------------------------------
/**
* Construct an EntitledMapListener with the current subject.
* The subject will not be available in the security context
* when events are received by the proxy at runtime.
*
* @param listener the MapListener
*/
public EntitledMapListener(MapListener listener)
{
m_listener = listener;
m_subject = SecurityHelper.getCurrentSubject();
}
// ----- MapListener interface ----------------------------------
/**
* {@inheritDoc}
*/
public void entryInserted(MapEvent mapEvent)
{
try
{
SecurityExampleHelper.checkAccess(
SecurityExampleHelper.ROLE_WRITER, m_subject);
}
catch (SecurityException e)
{
System.out.println("Access denied for entryInserted");
return;
}
m_listener.entryInserted(mapEvent);
}
/**
* {@inheritDoc}
*/
public void entryUpdated(MapEvent mapEvent)
{
try
{
SecurityExampleHelper.checkAccess(
SecurityExampleHelper.ROLE_WRITER, m_subject);
}
catch (SecurityException e)
{
System.out.println("Access denied for entryUpdated");
return;
}
m_listener.entryUpdated(mapEvent);
}
/**
* {@inheritDoc}
*/
public void entryDeleted(MapEvent mapEvent)
{
try
{
SecurityExampleHelper.checkAccess(
SecurityExampleHelper.ROLE_WRITER, m_subject);
}
catch (SecurityException e)
{
System.out.println("Access denied for entryDeleted");
return;
}
m_listener.entryDeleted(mapEvent);
}
// ----- data members ------------------------------------------
/**
* Subject from security context when the MapListener was registered
*/
private Subject m_subject;
/**
* Registered listener
*/
private MapListener m_listener;
}
// ----- helper methods -------------------------------------------------
/**
* Return the wrapped NamedCache.
*
* @return the wrapped CacheService
*/
public NamedCache getNamedCache()
{
return (NamedCache) getMap();
}
}
Coherence*Extendを使用し、クライアントから渡されたSubjectを使用して、ラップされたCacheServiceにアクセス資格を適用する方法を示すファイルを作成します。この実装は、前の項で作成したEntitledNamedCacheにキャッシュ操作のアクセス制御を委譲します。
作成するクラスは、com.tangosol.net.WrapperCacheServiceクラスを拡張します。これは、CacheServiceのメソッドの保護を可能にする便利なファンクションです。また、プロキシ上のキャッシュ・サービスとクライアントのリクエスト間で委譲を行うメカニズムも提供します。
メソッドensureCache、releaseCacheおよびdestroyCacheを実装して、これらの使用が特定ロールのユーザーのみに許可されるように保証します。実装には、特定のユーザー・ロールを引数としてSecurityExampleHelper.checkAccessメソッドのコールをインクルードします。たとえば、次のコードでは、adminロールのユーザーのみにキャッシュの破棄が許可されることが保証されます。
public void destroyCache(NamedCache map)
{
if (map instanceof EntitledNamedCache)
{
EntitledNamedCache cache = (EntitledNamedCache) map;
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_ADMIN);
map = cache.getNamedCache();
}
super.destroyCache(map);
}
キャッシュ・サービスへのアクセスに資格を適用するファイルを作成するには:
SecurityプロジェクトにEntitledCacheServiceという名前のJavaクラスを新規作成します。
このクラスがWrapperCacheServiceクラスをインポートして拡張することを確認します。
ensureCache、releaseCacheおよびdestroyCacheのメソッドを実装して、これらの使用が特定ロールのユーザーのみに許可されるように保証します。
例10-11は、考えられるEntitledCacheServiceの実装を示しています。
例10-11 資格が付与されるキャッシュ・サービス
package com.oracle.handson;
import com.tangosol.net.CacheService;
import com.tangosol.net.NamedCache;
import com.tangosol.net.WrapperCacheService;
/**
* Example WrapperCacheService that demonstrates how entitlements can be
* applied to a wrapped CacheService using the Subject passed from the
* client through Coherence*Extend. This implementation delegates access control
* for cache operations to the EntitledNamedCache.
*
*/
public class EntitledCacheService
extends WrapperCacheService
{
/**
* Create a new EntitledCacheService.
*
* @param service the wrapped CacheService
*/
public EntitledCacheService(CacheService service)
{
super(service);
}
// ----- CacheService interface -----------------------------------------
/**
* {@inheritDoc}
*/
public NamedCache ensureCache(String sName, ClassLoader loader)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
return new EntitledNamedCache(super.ensureCache(sName, loader));
}
/**
* {@inheritDoc}
*/
public void releaseCache(NamedCache map)
{
if (map instanceof EntitledNamedCache)
{
EntitledNamedCache cache = (EntitledNamedCache) map;
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_READER);
map = cache.getNamedCache();
}
super.releaseCache(map);
}
/**
* {@inheritDoc}
*/
public void destroyCache(NamedCache map)
{
if (map instanceof EntitledNamedCache)
{
EntitledNamedCache cache = (EntitledNamedCache) map;
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_ADMIN);
map = cache.getNamedCache();
}
super.destroyCache(map);
}
}
アクセス制御のサンプルを実行するファイルを作成します。ロール・ポリシーは、SecurityExampleHelperクラスで定義されます。EntitledCacheServiceクラスとEntitledNamedCacheクラスによってポリシーが強制されます。
このプログラムは、SecurityHelperFile.loginメソッドに対する引数として様々なユーザーを指定して、キャッシュの読取り、書込みおよび破棄の操作の実行を試行する必要があります。EntitledCacheServiceクラスとEntitledNamedCacheクラスで定義された資格ポリシーに従って、操作の成功、または失敗が決まります。
AccessControlExampleという名前のSecurityプロジェクトに、mainメソッドを使用して新たなJavaクラスを作成します。
詳細は、「Javaクラスの作成」を参照してください。
キャッシュにアクセスするmainメソッドを実装します。
SecurityExampleHelperファイルで定義されたユーザーをloginメソッドの引数として指定します。
ユーザーごとに、キャッシュに対する読取り(get)、書込み(put)および destroy操作を実行し、応答とする成功または失敗のメッセージを指定します。
例10-12は、考えられるAccessControlExample.javaクラスの実装を示しています。
例10-12 アクセス制御のサンプルを実行するサンプル・プログラム
package com.oracle.handson;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.InvocationService;
import com.tangosol.net.NamedCache;
import com.tangosol.net.Service;
import com.tangosol.util.MapEvent;
import com.tangosol.util.MapListener;
import java.security.PrivilegedExceptionAction;
import javax.security.auth.Subject;
/**
* This class demonstrates simplified role based access control.
* <p>
* The role policies are defined in SecurityExampleHelper. Enforcmenent
* is done by EntitledCacheService and EntitledNamedCache.
*
*/
public class AccessControlExample
{
// ----- static methods -------------------------------------------------
public static void main (String[] args){
accessCache();
}
/**
* Demonstrate role based access to the cache.
*/
public static void accessCache()
{
System.out.println("------cache access control example begins------");
Subject subject = SecurityExampleHelper.login("JohnWhorfin");
// Someone with writer role can write and read
try
{
NamedCache cache = (NamedCache) Subject.doAs(
subject, new PrivilegedExceptionAction()
{
public Object run()
throws Exception
{
return CacheFactory.getCache(SecurityExampleHelper.SECURITY_CACHE_NAME);
}
});
cache.put("myKey", "myValue");
cache.get("myKey");
System.out.println(" Success: read and write allowed");
}
catch (Exception e)
{
// get exception if not allowed to perform the operation
e.printStackTrace();
}
// Someone with reader role can read but not write
subject = SecurityExampleHelper.login("JohnBigboote");
try
{
NamedCache cache = (NamedCache) Subject.doAs(
subject, new PrivilegedExceptionAction()
{
public Object run()
throws Exception
{
return CacheFactory.getCache(SecurityExampleHelper.SECURITY_CACHE_NAME);
}
});
cache.get("myKey");
System.out.println(" Success: read allowed");
cache.put("anotherKey", "anotherValue");
}
catch (Exception e)
{
// get exception if not allowed to perform the operation
System.out.println(" Success: Correctly cannot write");
}
// Someone with writer role cannot call destroy
subject = SecurityExampleHelper.login("JohnWhorfin");
try
{
NamedCache cache = (NamedCache) Subject.doAs(
subject, new PrivilegedExceptionAction()
{
public Object run()
throws Exception
{
return CacheFactory.getCache(SecurityExampleHelper.SECURITY_CACHE_NAME);
}
});
cache.destroy();
}
catch (Exception e)
{
// get exception if not allowed to perform the operation
System.out.println(" Success: Correctly cannot " +
"destroy the cache");
}
// Someone with admin role can call destroy
subject = SecurityExampleHelper.login("BuckarooBanzai");
try
{
NamedCache cache = (NamedCache) Subject.doAs(
subject, new PrivilegedExceptionAction()
{
public Object run()
throws Exception
{
return CacheFactory.getCache(SecurityExampleHelper.SECURITY_CACHE_NAME);
}
});
cache.destroy();
System.out.println(" Success: Correctly allowed to " +
"destroy the cache");
}
catch (Exception e)
{
// get exception if not allowed to perform the operation
e.printStackTrace();
}
System.out.println("------cache access control example completed------");
}
}
クラスタ側のキャッシュ構成ファイルexamples-cache-config.xmlを編集します。cache-service-proxyスタンザのproxy-configで、キャッシュ・サービスのクラス名のフルパスを指定します。cache-service-proxyスタンザには、プロキシ・サービスによって管理されるキャッシュ・サービス・プロキシの構成情報が格納されます。
この例のキャッシュ・サービス・クラス名はcom.oracle.handson.EntitledCacheServiceプロキシで、param-typeは、com.tangosol.net.CacheServiceです。
例10-13は、構成に追加するXMLコードを示しています。
例10-13 クラスタ側のキャッシュ構成のキャッシュ・サービス・プロキシ構成
...
<proxy-config>
<cache-service-proxy>
<class-name>com.oracle.handson.EntitledCacheService</class-name>
<init-params>
<init-param>
<param-type>com.tangosol.net.CacheService</param-type>
<param-value>{service}</param-value>
</init-param>
</init-params>
</cache-service-proxy>
</proxy-config>
...
アクセス制御サンプルを実行し、ユーザーのロールを基準にしてキャッシュへのアクセスがどのように許可または拒否されるかを示します。
AccessControlExample.javaの実行構成を作成します。
「Project Explorer」で、AccessControlExampleを右クリックします。「Run As」→「Run Configurations」を選択します。
「Oracle Coherence」→「New launch configuration」アイコンを選択します。AccessControlExampleが「Name」フィールドに、Securityが「Project」フィールドに、com.oracle.handson.AccessControlExampleが「Main class」フィールドに表示されていることを確認します。「Apply」をクリックします。
「Coherence」タブの「Cache configuration descriptor」フィールドにclient-cache-config.xmlファイルへのパスを入力します。「Local cache」フィールドで、「Disabled (cache client)」を選択します。「Cluster port」フィールドに3155と入力します。
「Classpath」タブで、図10-5のように「User Entries」が表示されていることを確認します。「Apply」→「Close」をクリックします。
実行中のキャッシュ・サーバーがあれば停止します。詳細は、「キャッシュ・サーバーの停止」を参照してください。
セキュリティ・プロキシ・サーバー、セキュリティ・キャッシュ・サーバー、続いてAccessControlExample.javaプログラムを実行します。
プロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスから、SecurityRunProxy構成を実行します。
プロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスから、SecurityCacheServer構成を実行します。
「Project Explorer」でAccessControlExample.javaファイルを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスから、AccessControlExample構成を実行します。
Eclipseコンソールに、例10-14のような出力が表示されます。メッセージは、AccessControlExampleで指定され、キャッシュの読取り、書込みおよび破棄操作を実行する様々なユーザーに対応します。
メッセージ「Success: read and write allowed」は、キャッシュの読取りおよび書込みを試行するロールwriterのユーザーに対応します。
メッセージ「Success: read allowed」は、キャッシュの読取りを試行するロールreaderのユーザーに対応します。
メッセージ「Success: Correctly cannot write」は、キャッシュへの書込みを試行するロールreaderのユーザーに対応します。
メッセージ「Success: Correctly cannot destroy the cache」は、キャッシュの破棄を試行するロールwriterのユーザーに対応します。
メッセージ「Success: Correctly allowed to destroy the cache」は、キャッシュの破棄を試行するロールadminのユーザーに対応します。
例10-14 Eclipseコンソールのアクセス制御サンプルの出力
------cache access control example begins------2012-08-22 11:32:24.329/0.609 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence.xml" 2012-08-22 11:32:24.407/0.687 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml" 2012-08-22 11:32:24.454/0.734 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "file:/C:/home/oracle/workspace/Security/build/classes/tangosol-coherence-override.xml" 2012-08-22 11:32:24.470/0.750 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-config.xml" is not specified 2012-08-22 11:32:24.470/0.750 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "cache-factory-builder-config.xml" is not specified 2012-08-22 11:32:24.470/0.750 Oracle Coherence 12.1.2.0 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified Oracle Coherence Version 12.1.2.0 Build 36845 Grid Edition: Development mode Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 2012-08-22 11:32:24.688/0.968 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/C:/home/oracle/workspace/Security/appClientModule/client-cache-config.xml" 2012-08-22 11:32:25.220/1.500 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory 2012-08-22 11:32:26.001/2.281 Oracle Coherence GE 12.1.2.0 <D5> (thread=ExtendTcpCacheService:TcpInitiator, member=n/a): Started: TcpInitiator{Name=ExtendTcpCacheService:TcpInitiator, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), Serializer=com.tangosol.io.DefaultSerializer, PingInterval=0, PingTimeout=0, RequestTimeout=0, ConnectTimeout=0, SocketProvider=com.oracle.common.internal.net.MultiplexedSocketProvider@1739f, RemoteAddresses=WrapperSocketAddressProvider{Providers=[[tpfaeffl-lap7/130.35.99.202:9099]]}, SocketOptions{LingerTimeout=0, KeepAliveEnabled=true, TcpDelayEnabled=false}} 2012-08-22 11:32:26.141/2.421 Oracle Coherence GE 12.1.2.0 <D5> (thread=main, member=n/a): Connecting Socket to 130.35.99.202:9099 2012-08-22 11:32:26.173/2.453 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Connected Socket to 130.35.99.202:9099Success: read and write allowed2012-08-22 11:32:27.157/3.437 Oracle Coherence GE 12.1.2.0 <D5> (thread=ExtendTcpCacheService:TcpInitiator, member=n/a): Started: TcpInitiator{Name=ExtendTcpCacheService:TcpInitiator, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), Serializer=com.tangosol.io.DefaultSerializer, PingInterval=0, PingTimeout=0, RequestTimeout=0, ConnectTimeout=0, SocketProvider=com.oracle.common.internal.net.MultiplexedSocketProvider@1739f, RemoteAddresses=WrapperSocketAddressProvider{Providers=[[tpfaeffl-lap7/130.35.99.202:9099]]}, SocketOptions{LingerTimeout=0, KeepAliveEnabled=true, TcpDelayEnabled=false}} 2012-08-22 11:32:27.204/3.484 Oracle Coherence GE 12.1.2.0 <D5> (thread=main, member=n/a): Connecting Socket to 130.35.99.202:9099 2012-08-22 11:32:27.204/3.484 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Connected Socket to 130.35.99.202:9099Success: read allowedSuccess: Correctly cannot writeSuccess: Correctly cannot destroy the cache2012-08-22 11:32:27.470/3.750 Oracle Coherence GE 12.1.2.0 <D5> (thread=ExtendTcpCacheService:TcpInitiator, member=n/a): Started: TcpInitiator{Name=ExtendTcpCacheService:TcpInitiator, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), Serializer=com.tangosol.io.DefaultSerializer, PingInterval=0, PingTimeout=0, RequestTimeout=0, ConnectTimeout=0, SocketProvider=com.oracle.common.internal.net.MultiplexedSocketProvider@1739f, RemoteAddresses=WrapperSocketAddressProvider{Providers=[[tpfaeffl-lap7/130.35.99.202:9099]]}, SocketOptions{LingerTimeout=0, KeepAliveEnabled=true, TcpDelayEnabled=false}} 2012-08-22 11:32:27.501/3.781 Oracle Coherence GE 12.1.2.0 <D5> (thread=main, member=n/a): Connecting Socket to 130.35.99.202:9099 2012-08-22 11:32:27.501/3.781 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Connected Socket to 130.35.99.202:9099Success: Correctly allowed to destroy the cache------cache access control example completed------
例10-15は、キャッシュ・サーバーでプロキシ・サービスが実行される場合のシェルの出力をリストしています。出力内のセキュリティの例外は、Eclipseコンソールのメッセージ「Success: Correctly cannot write」および「Success: Correctly cannot destroy the cache」に対応することに注意します。
例10-15 プロキシ・サービスを実行中のキャッシュ・サーバーの出力
Started DefaultCacheServer...
2012-08-22 11:32:02.985/93.234 Oracle Coherence GE 12.1.2.0 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2012-08-22 11:32:02.837, Address=130.35.99.202:8090, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:4180, Role=CoherenceServer) joined Cluster with senior member 1
2012-08-22 11:32:03.048/93.297 Oracle Coherence GE 12.1.2.0 <D5> (thread=Cluster, member=1): Member 2 joined Service Management with senior member 1
2012-08-22 11:32:03.220/93.469 Oracle Coherence GE 12.1.2.0 <D5> (thread=Cluster, member=1): Member 2 joined Service PartitionedPofCache with senior member 1
2012-08-22 11:32:03.298/93.547 Oracle Coherence GE 12.1.2.0 <D5> (thread=DistributedCache:PartitionedPofCache, member=1): Transferring 0KB of backup[1] for PartitionSet{128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
...
... 123, 124, 125, 126, 127} to member 2 requesting 128
Password validated for user: role_writer
Password validated for user: role_writer
Password validated for user: role_writer
Password validated for user: role_reader
Password validated for user: role_reader
Password validated for user: role_reader
2012-08-22 11:32:27.235/117.484 Oracle Coherence GE 12.1.2.0 <D5> (thread=Proxy:ProxyService:TcpAcceptorWorker:1, member=1): An exception occurred while processing a PutRequest for Service=Proxy:ProxyService:TcpAcceptor: java.lang.SecurityException: Access denied, insufficient privileges
at com.oracle.handson.SecurityExampleHelper.checkAccess(SecurityExampleHelper.java:105)
at com.oracle.handson.SecurityExampleHelper.checkAccess(SecurityExampleHelper.java:59)
at com.oracle.handson.EntitledNamedCache.put(EntitledNamedCache.java:68)
at com.tangosol.coherence.component.net.extend.proxy.NamedCacheProxy.put$Router(NamedCacheProxy.CDB:1)
at com.tangosol.coherence.component.net.extend.proxy.NamedCacheProxy.put(NamedCacheProxy.CDB:2)
at com.tangosol.coherence.component.net.extend.messageFactory.NamedCacheFactory$PutRequest.onRun(NamedCacheFactory.CDB:6)
at com.tangosol.coherence.component.net.extend.message.Request.run(Request.CDB:4)
at com.tangosol.coherence.component.net.extend.proxy.NamedCacheProxy.onMessage(NamedCacheProxy.CDB:11)
at com.tangosol.coherence.component.net.extend.Channel$MessageAction.run(Channel.CDB:13)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.tangosol.coherence.component.net.extend.Channel.execute(Channel.CDB:48)
at com.tangosol.coherence.component.net.extend.Channel.receive(Channel.CDB:26)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Peer$DaemonPool$WrapperTask.run(Peer.CDB:9)
at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32)
at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB:66)
at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:51)
at java.lang.Thread.run(Thread.java:722)
2012-08-22 11:32:27.391/117.640 Oracle Coherence GE 12.1.2.0 <D5> (thread=Proxy:ProxyService:TcpAcceptorWorker:0, member=1): An exception occurred while processing a DestroyCacheRequest for Service=Proxy:ProxyService:TcpAcceptor: java.lang.SecurityException: Access denied, insufficient privileges
at com.oracle.handson.SecurityExampleHelper.checkAccess(SecurityExampleHelper.java:105)
at com.oracle.handson.SecurityExampleHelper.checkAccess(SecurityExampleHelper.java:59)
at com.oracle.handson.EntitledCacheService.destroyCache(EntitledCacheService.java:61)
at com.tangosol.coherence.component.net.extend.messageFactory.CacheServiceFactory$DestroyCacheRequest.onRun(CacheServiceFactory.CDB:6)
at com.tangosol.coherence.component.net.extend.message.Request.run(Request.CDB:4)
at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.CacheServiceProxy.onMessage(CacheServiceProxy.CDB:9)
at com.tangosol.coherence.component.net.extend.Channel$MessageAction.run(Channel.CDB:13)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.tangosol.coherence.component.net.extend.Channel.execute(Channel.CDB:48)
at com.tangosol.coherence.component.net.extend.Channel.receive(Channel.CDB:26)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Peer$DaemonPool$WrapperTask.run(Peer.CDB:9)
at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32)
at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB:66)
at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:51)
at java.lang.Thread.run(Thread.java:722)
Password validated for user: CN=BuckarooBanzai,OU=Yoyodyne
Password validated for user: CN=BuckarooBanzai,OU=Yoyodyne
Password validated for user: CN=BuckarooBanzai,OU=Yoyodyne
起動サービス・クラスタ・サービスを使用すると、Extendクライアントによるクラスタ上の起動可能オブジェクトの実行が可能になります。このサンプルは、ロールベース・ポリシーを使用して起動可能オブジェクトの実行が可能なユーザーをどのように決定できるかを示しています。
たとえば、ライター・ロールのユーザーは、起動可能オブジェクトを実行できます。リーダー・ロールのユーザーはできません。
このサンプルでは、クライアント・プログラムからコールできる起動可能オブジェクトを作成します。起動可能オブジェクトはシリアライズ可能であるため、POF構成ファイルにこれをリストする必要もあります。また、ユーザーのロールを基準にして、特定のユーザーがサービス上のメソッドを実行できるかどうかをテストする起動サービス・プログラムも作成します。
前出のサンプルと同様、この例でもPasswordIdentityTransformerクラスを使用して、パスワード、ユーザーIDおよびロールが格納されるセキュリティ・トークンを使用します。パスワードを強制し、適正なユーザーIDとロールでサブジェクトを構成するセキュリティ・トークンの検証には、PasswordIdentityAsserter(プロキシで実行)が使用されます。セキュリティ・トークンの生成とアサーションは自動的に実行されます。
サンプルを作成するには:
資格が付与された起動サービスによって使用される簡略な起動可能オブジェクトの実装を作成します。たとえば、整数の増分および戻りを実行する起動可能オブジェクトを作成できます。
起動可能オブジェクトを作成するには:
SecurityプロジェクトにExampleInvocableという名前のJavaクラスを新規作成します。
詳細は、「Javaクラスの作成」を参照してください。
InvocableインタフェースとInvocationServiceインタフェースをインポートします。このクラスはシリアライズ可能オブジェクトを処理するため、PortableObject、PofReaderおよびPofWriterのクラスをインポートします。
ExampleInvocableクラスがInvocableおよびPortableObjectを実装することを保証します。
ExampleInvocableクラスを実装して、整数を増分し、結果を返します。
PofReader.readExternalメソッドとPofWriter.writeExternalメソッドを実装します。
例10-16は、考えられるExampleInvocable.javaの実装を示しています。
例10-16 起動可能オブジェクトのサンプル
package com.oracle.handson;
import com.tangosol.io.pof.PortableObject;
import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import com.tangosol.net.Invocable;
import com.tangosol.net.InvocationService;
import java.io.IOException;
/**
* Invocable implementation that increments and returns a given integer.
*/
public class ExampleInvocable
implements Invocable, PortableObject
{
// ----- constructors ---------------------------------------------
/** * */ private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public ExampleInvocable()
{
}
// ----- Invocable interface --------------------------------------
/**
* {@inheritDoc}
*/
public void init(InvocationService service)
{
m_service = service;
}
/**
* {@inheritDoc}
*/
public void run()
{
if (m_service != null)
{
m_nValue++;
}
}
/**
* {@inheritDoc}
*/
public Object getResult()
{
return new Integer(m_nValue);
}
// ----- PortableObject interface ---------------------------------
/**
* {@inheritDoc}
*/
public void readExternal(PofReader in)
throws IOException
{
m_nValue = in.readInt(0);
}
/**
* {@inheritDoc}
*/
public void writeExternal(PofWriter out)
throws IOException
{
out.writeInt(0, m_nValue);
}
// ----- data members ---------------------------------------------
/**
* The integer value to increment.
*/
private int m_nValue;
/**
* The InvocationService that is executing this Invocable.
*/
private transient InvocationService m_service;
}
この例は、アクセス制御が提供されるようにリモート起動サービスをラップする方法を示しています。Coherence*Extendを使用すると、クライアントから渡されるSubjectを使用して、ラップされるInvocationServiceにアクセス資格を適用できます。この実装では、ラップされた起動サービスへのアクセスが指定されたロールのクライアントのみに許可されます。
作成するクラスは、com.tangosol.net.WrapperInvocationServiceクラスを拡張します。これは、InvocationServiceのメソッドの保護を可能にする便利なファンクションです。また、プロキシ上の起動サービスとクライアントのリクエスト間で委譲を行うメカニズムも提供します。
資格が付与される起動サービスを作成するには:
SecurityプロジェクトにEntitledInvocationServiceという名前のJavaクラスを新規作成します。
Invocable、InvocationObserver、InvocationService、WrapperInvocationService、MapおよびSetのインタフェースをインポートします。EntitledInvocationServiceクラスがWrapperInvocationServiceクラスを拡張することを確認します。
queryメソッドとexecuteメソッドを実装します。指定されたユーザー・ロール(このサンプルではROLE_WRITER)がこれらの操作にアクセスできるかどうかを判別するため、この実装に、SecurityExampleHelper.checkAccessメソッドのコールをインクルードします。
例10-17は、考えられるEntitledInvocationService.javaの実装を示しています。
例10-17 資格が付与される起動サービスのサンプル
package com.oracle.handson;
import com.tangosol.net.Invocable;
import com.tangosol.net.InvocationObserver;
import com.tangosol.net.InvocationService;
import com.tangosol.net.WrapperInvocationService;
import java.util.Map;
import java.util.Set;
/**
* Example WrapperInvocationService that demonstrates how entitlements can be
* applied to a wrapped InvocationService using the Subject passed from the
* client through Coherence*Extend. This implementation only allows clients with a
* specified role to access the wrapped InvocationService.
*
*/
public class EntitledInvocationService
extends WrapperInvocationService
{
/**
* Create a new EntitledInvocationService.
*
* @param service the wrapped InvocationService
*/
public EntitledInvocationService(InvocationService service)
{
super(service);
}
// ----- InvocationService interface ------------------------------------
/**
* {@inheritDoc}
*/
public void execute(Invocable task, Set setMembers, InvocationObserver observer)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
super.execute(task, setMembers, observer);
}
/**
* {@inheritDoc}
*/
public Map query(Invocable task, Set setMembers)
{
SecurityExampleHelper.checkAccess(SecurityExampleHelper.ROLE_WRITER);
return super.query(task, setMembers);
}
}
アクセス起動サービス・サンプルを実行するプログラムを作成します。このプログラムの目的は、SecurityExampleHelperクラスで定義されている多様なユーザーが起動可能オブジェクトにアクセスして実行できるかどうかをテストすることです。ロールベース・ポリシーの強制は、EntitledInvocationServiceクラスによって指定されます。
アクセス起動サービスのサンプルを実行するプログラムを作成するには:
AccessInvocationServiceExample.javaという名前のSecurityプロジェクトに、mainメソッドを使用してJavaクラスを作成します。
詳細は、「Javaクラスの作成」を参照してください。
クラスの中から、ExampleInvocable、CacheFactoryおよびInvocationServiceをインポートします。
accessInvocationServiceメソッドを起動するmainメソッドを実装します。
accessInvocationServiceクラスを実装して、SecurityExampleHelperクラスで定義された様々なユーザーが、サービスへのログイン、およびExampleInvocableで定義されたオブジェクトの実行を試行できるようにします。SecurityExampleHelper.loginメソッドを使用して、起動可能サービスにそれぞれのユーザーがアクセスできるかどうかをテストします。
例10-18は、考えられるAccessInvocationServiceExample.javaの実装を示しています。
例10-18 アクセス起動サービス・サンプルを実行するサンプル・プログラム
package com.oracle.handson;
import com.oracle.handson.ExampleInvocable;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.InvocationService;
import java.security.PrivilegedExceptionAction;
import javax.security.auth.Subject;
/**
* This class demonstrates simplified role based access control for the
* invocation service.
* <p>
* The role policies are defined in SecurityExampleHelper. Enforcmenent
* is done by EntitledInvocationService.
*
*/
public class AccessInvocationServiceExample
{
/**
* Invoke the example
*
* @param asArg command line arguments (ignored in this example)
*/
public static void main(String[] asArg)
{
accessInvocationService();
}
/**
* Access the invocation service
*/
public static void accessInvocationService()
{
System.out.println("------InvocationService access control example " +
"begins------");
// Someone with writer role can run invocables
Subject subject = SecurityExampleHelper.login("JohnWhorfin");
try
{
InvocationService service = (InvocationService) Subject.doAs(
subject, new PrivilegedExceptionAction()
{
public Object run()
{
return CacheFactory.getService(
SecurityExampleHelper.INVOCATION_SERVICE_NAME);
}
});
service.query(new ExampleInvocable(), null);
System.out.println(" Success: Correctly allowed to " +
"use the invocation service");
}
catch (Exception e)
{
// get exception if not allowed to perform the operation
e.printStackTrace();
}
// Someone with reader role cannot cannot run invocables
subject = SecurityExampleHelper.login("JohnBigboote");
try
{
InvocationService service = (InvocationService) Subject.doAs(
subject, new PrivilegedExceptionAction()
{
public Object run()
{
return CacheFactory.getService(
SecurityExampleHelper.INVOCATION_SERVICE_NAME);
}
});
service.query(new ExampleInvocable(), null);
}
catch (Exception ee)
{
System.out.println(" Success: Correctly unable to " +
"use the invocation service");
}
System.out.println("------InvocationService access control example " +
"completed------");
}
}
examples-cache-config.xmlファイルを編集して、起動サービスへのフルパスをinvocation-service-proxyスタンザのproxy-configに追加します。invocation-service-proxyスタンザには、プロキシ・サービスによって管理される起動サービス・プロキシの構成情報が格納されます。
このサンプルの起動サービス・クラス名はcom.oracle.handson.EntitledInvocationServiceで、そのparam-typeは、com.tangosol.net.InvocationServiceです。
例10-19 クラスタ側キャッシュの起動サービス・プロキシ構成
...
<proxy-config>
...
<invocation-service-proxy>
<class-name>com.oracle.handson.EntitledInvocationService</class-name>
<init-params>
<init-param>
<param-type>com.tangosol.net.InvocationService</param-type>
<param-value>{service}</param-value>
</init-param>
</init-params>
</invocation-service-proxy>
</proxy-config>
...
ユーザー定義型としてExampleInvocableを宣言するPOFファイルを作成します。
「Project Explorer」で、Security\appClientModuleのpof-config.xmlファイルを探し、Eclipse IDEで開きます。
ユーザー定義型としてExampleInvocableを宣言するコードを入力して、ファイルを保存します。
このファイルの内容は、例10-20のようになります。このファイルは、C:\home\oracle\workspace\Security\appClientModuleフォルダに保存されます。
例10-20 ExampleInvocableユーザー定義型のPOF構成ファイル
<?xml version="1.0"?>
<pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config http://xmlns.oracle.com/coherence/coherence-pof-config/1.1/coherence-pof-config.xsd">
<user-type-list>
<!-- include all "standard" Coherence POF user types -->
<include>coherence-pof-config.xml</include>
<!-- com.tangosol.examples package -->
<user-type>
<type-id>1007</type-id>
<class-name>com.oracle.handson.ExampleInvocable</class-name>
</user-type>
</user-type-list>
<allow-interfaces>true</allow-interfaces>
<allow-subclasses>true</allow-subclasses>
</pof-config>
クラスローダーは、coherence.jarファイル内での参照前に、カスタムPOF構成ファイルpof-config.xmlを検出する必要があります。このようにされないと、カスタムPOF構成ファイルが無視され、coherence.jarファイル内のデフォルト・ファイルが使用されることになります。
アプリケーションにC:\home\oracle\workspace\Security\appModuleのXML構成ファイルを使用させるには、サーバーのクラス・パスの「Bootstrap Entries」セクションにCoherence12.1.2ライブラリが表示されていないことを確認します。また、coherence.jarファイルをUser EntriesセクションのSecurityフォルダの後に配置します。
サーバーのクラスパスの「Bootstrap Entries」セクションにCoherence12.1.2ライブラリが表示されている場合は、次の手順に従ってそのライブラリを削除します。
「Project Explorer」でプロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。
SecurityRunProxyを選択します。「Classpath」タブで「Coherence12.1.2」が表示されている場合は、「Bootstrap Entries」のリストからそれを削除します。「Add External Jars」をクリックして、Oracle_Home\coherence\libフォルダからcoherence.jarファイルを選択します。「Apply」をクリックします。
SecurityCacheServerを選択します。「Classpath」タブで「Coherence12.1.2」が表示されている場合は、「Bootstrap Entries」のリストからそれを削除します。「Add External Jars」をクリックして、Oracle_Home\coherence\libフォルダからcoherence.jarファイルを選択します。「Apply」をクリックします。
|
注意: クラス・パス上の |
終了すると、SecurityRunProxyおよびSecurityCacheServerの「Classpath」タブが図10-6のように表示されます。
アクセス起動サービス・サンプルを実行し、ユーザーのロールを基準にして起動可能オブジェクトへのアクセスがどのように許可または拒否されるかを示します。
AccessInvocationServiceExample.javaファイルの実行構成を作成します。
「Project Explorer」でAccessInvocationServiceExample.javaを右クリックして、「Run As」→「Run Configurations」を選択します。
「Oracle Coherence」→「New launch configuration」アイコンをクリックします。AccessInvocationServiceExampleが「Name」フィールドに、Securityが「Project」フィールドに、com.oracle.handson.AccessInvocationServiceExample.javaが「Main class」フィールドに表示されていることを確認します。「Apply」をクリックします。
「Coherence」タブの「Cache configuration descriptor」フィールドにclient-cache-config.xmlファイルへのパスを入力します。「Local cache」フィールドで、「Disabled (cache client)」を選択します。
「Classpath」タブで「Coherence12.1.2」が表示されている場合は、「Bootstrap Entries」リストからそれを削除します。「Add External Jars」をクリックして、coherence.jarファイルを「User Entries」に追加します。Securityフォルダを「User Entries」の先頭に移動して、coherence.jarファイルを移動します(表示されていない場合)。終了すると、「Classpath」タブが図10-7のように表示されます。「Apply」→「Close」をクリックします。
図10-7 AccessInvocationServiceExampleプログラムの「Classpath」タブ

実行中のキャッシュ・サーバーがあれば停止します。詳細は、「キャッシュ・サーバーの停止」を参照してください。
セキュリティ・プロキシ・サーバー、セキュリティ・キャッシュ・サーバー、続いてAccessInvocationServiceExample.javaプログラムを実行します。
プロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスから、SecurityRunProxy構成を実行します。
プロジェクトを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスから、SecurityCacheServer構成を実行します。
「Project Explorer」でAccessInvocationServiceExample.javaファイルを右クリックして、「Run As」→「Run Configurations」を選択します。「Run Configurations」ダイアログ・ボックスでAccessControlExampleを選択し、「Run」をクリックします。
Eclipseコンソールに、例10-21のような出力が表示されます。このメッセージは、AccessInvocationServiceExampleクラスで指定され、起動可能オブジェクトExampleInvocableを実行しようとするユーザーに対応します。
メッセージ「Success: Correctly allowed to use the invocation service」は、ExampleInvocableを実行しようとするロールwriterのユーザーに対応します。
メッセージ「Success: Correctly unable to use the invocation service」は、ExampleInvocableを実行しようとするロールreaderのユーザーに対応します。
例10-21 Eclipseコンソールのクライアント・プログラムの応答
------InvocationService access control example begins------2012-08-22 12:32:55.548/0.516 Oracle Coherence 12.1.2.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar!/tangosol-coherence.xml" ... ... Oracle Coherence Version 12.1.2.0 Build 36845 Grid Edition: Development mode Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. ... ... 2012-08-22 12:32:56.501/1.469 Oracle Coherence GE 12.1.2.0 <D5> (thread=main, member=n/a): Connecting Socket to 130.35.99.202:9099 2012-08-22 12:32:56.501/1.469 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Connected Socket to 130.35.99.202:9099Success: Correctly allowed to use the invocation service... ... 2012-08-22 12:32:56.595/1.563 Oracle Coherence GE 12.1.2.0 <Info> (thread=main, member=n/a): Connected Socket to 130.35.99.202:9099Success: Correctly unable to use the invocation service------InvocationService access control example completed------
例10-22は、キャッシュ・サーバーでプロキシ・サービスが実行される場合のシェルの出力をリストしています。出力のセキュリティの例外は、ロールreaderのユーザーがExampleInvocableを実行しようとした場合のEclipseコンソールのメッセージ「Success: Correctly unable to use the invocation service」に対応することに注意します。
例10-22 Eclipseコンソールのプロキシ・サービスの応答
... Started DefaultCacheServer... 2012-08-22 12:32:31.782/23.766 Oracle Coherence GE 12.1.2.0 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2012-08-22 12:32:31.595, Address=130.35.99.202:8090, MachineId=18578, Location=site:,machine:tpfaeffl-lap7,process:4144, Role=CoherenceServer) joined Cluster with senior member 1 ... ... 121, 122, 123, 124, 125, 126, 127} to member 2 requesting 128Password validated for user: role_writerPassword validated for user: role_writerPassword validated for user: role_readerPassword validated for user: role_reader2012-08-22 12:32:56.610/48.594 Oracle Coherence GE 12.1.2.0 <D5> (thread=Proxy:ProxyService:TcpAcceptorWorker:0, member=1): An exception occurred while processing a InvocationRequest for Service=Proxy:ProxyService:TcpAcceptor: java.lang.SecurityException: Access denied, insufficient privilegesat com.oracle.handson.SecurityExampleHelper.checkAccess(SecurityExampleHelper.java:105) at com.oracle.handson.SecurityExampleHelper.checkAccess(SecurityExampleHelper.java:59) at com.oracle.handson.EntitledInvocationService.query(EntitledInvocationService.java:50) at com.tangosol.coherence.component.net.extend.messageFactory.InvocationServiceFactory$InvocationRequest.onRun(InvocationServiceFactory.CDB:12) at com.tangosol.coherence.component.net.extend.message.Request.run(Request.CDB:4) at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.InvocationServiceProxy.onMessage(InvocationServiceProxy.CDB:9) at com.tangosol.coherence.component.net.extend.Channel$MessageAction.run(Channel.CDB:13) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:356) at com.tangosol.coherence.component.net.extend.Channel.execute(Channel.CDB:48) at com.tangosol.coherence.component.net.extend.Channel.receive(Channel.CDB:26) at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Peer$DaemonPool$WrapperTask.run(Peer.CDB:9) at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32) at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB:66) at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:51) at java.lang.Thread.run(Thread.java:722)