Oracle® Fusion Middleware Oracle Platform Security Servicesによるアプリケーションの保護 12c (12.2.1.3.0) E92000-01 |
|
前 |
次 |
この章の内容は次のとおりです。
次の各項では、component-event.xml
および翻訳ファイルの作成方法について説明します。
component-events.xml
監査定義ファイルを作成する際には、次の点に留意してください。
監査イベント定義を変更する場合は、マイナー番号またはメジャー番号を変更してバージョンIDを変更する必要があります。
アプリケーション属性定義の表とデータベース列は、1対1で対応する必要があります。各カスタム属性には、対応する順序番号が属性定義に含まれている必要があります。
次の各項では、監査へのアプリケーションの登録を可能にする様々なメカニズムについて説明します。
注意:
ドメイン拡張テンプレートを使用した登録が望ましい方法です。テンプレートの詳細は、「監査アーティファクト用ドメイン拡張テンプレートの使用」を参照してください。
この項では、2種類の宣言による監査定義の登録方法を説明します。
デフォルトの監査登録
カスタム監査登録
アプリケーションをデプロイ、再デプロイまたはアンデプロイする際に、次の登録アクティビティがデフォルトで発生します。
デプロイ - アプリケーションがまだ登録されていない場合に、監査イベント定義を監査ストアに登録します。
再デプロイ - コンポーネントがすでに登録されている場合に、コンポーネント・イベント定義をアップグレードします。
アンデプロイ - アプリケーションの監査イベント定義を監査ストアから削除します。
監査レコードを問い合せるための簡易データベース・ビューは、登録時にIAU
スキーマ内に作成されます。これは、Oracle Fusion Middlewareリポジトリ作成ユーティリティによってビューが作成されるコンポーネントを除いたすべてについて発生します。
監査登録をカスタマイズするパラメータは、weblogic-application.xml
WebLogic Serverデプロイメント記述子で設定します。このファイルは、アプリケーションのエンタープライズ・アーカイブ(EAR)ファイルのMETA-INF
ディレクトリでパッケージ化されます。パッケージ化の要件の詳細は、「Java EEアプリケーションの手動によるパッケージ化」を参照してください。
監査レコードを問い合せるための簡易データベース・ビューは、ビューの作成を明示的に無効にしないかぎり、監査登録時にIAU
スキーマ内に作成されます。
表22-1に、パラメータとそのオプションを示します。
表22-1 監査登録のパラメータ
パラメータ | オプション | 説明 |
---|---|---|
opss.audit.registration |
OVERWRITE |
登録されているかどうかにかかわらず、コンポーネント監査定義を登録します。 |
UPGRADE (デフォルト・オプション) |
バージョンのサポートに応じてコンポーネント監査定義を登録します。 |
|
DISABLE |
コンポーネント監査定義を登録しません。 |
|
opss.audit.deregistration |
DELETE(デフォルト・オプション) |
アプリケーションのアンデプロイ時に、コンポーネント監査定義を監査ストアから削除します。 |
DISABLE |
アプリケーションのアンデプロイ時に、コンポーネント監査定義を監査ストアに残します。 |
|
opss.audit.componentType |
- |
カスタム・コンポーネント・タイプを設定します。(オプション) |
opss.audit.iauview |
SIMPLE INDEXABLE DISABLE |
|
次の例では、登録オプションと登録解除オプションの使用方法を示します。
<wls:application-param> <wls:param-name>opss.audit.registration</wls:param-name> <wls:param-value>DISABLE</wls:param-value> </wls:application-param> <wls:application-param> <wls:param-name>opss.audit.registration</wls:param-name> <wls:param-value>OVERWRITE</wls:param-value> </wls:application-param> <wls:application-param> <wls:param-name>opss.audit.unregistration</wls:param-name> <wls:param-value>DELETE</wls:param-value> </wls:application-param> <wls:application-param> <wls:param-name>opss.audit.unregistration</wls:param-name> <wls:param-value>DISABLE</wls:param-value> </wls:application-param>
次の例では、プログラムでアプリケーションを監査に登録する方法を示しています。
AuditService auditService = JpsServiceLocator.getServiceLocator().lookup(AuditService.class); AuditRegistration auditReg = <instance of AuditRegistration implementation>; AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws AuditException, IOException { auditService.register(auditReg); return null; } });
auditService.register
メソッドをコールするには、作成およびアップグレードのアクションに関してAuditStoreAccessPermission
パーミッションがアプリケーションに付与されている必要があります。権限の指定の詳細は、「システム権限の設定」を参照してください。
次に、プログラムによる登録例を示します。
JpsContextFactory ctxFactory = JpsContextFactory.getContextFactory(); JpsContext ctx = ctxFactory.getContext(); //get audit service final AuditService auditService = ctx.getServiceInstance(AuditService.class); //create an audit registration instance final AuditRegistration auditReg = new SampleRegistration(); //call API to register audit event definition AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws AuditException, IOException { auditService.register(auditReg); return null; } });
登録により、データベースから監査レコードを問い合せるためのデータベース・ビューが作成されます。ビューの作成を管理するロジックまたはその機能を無効にするロジックを追加するには、AuditRegistration
を拡張するoracle.security.jps.service.audit.AuditRegistrationExt
インタフェースを実装します。
SampleRegistration.java class SampleRegistration implements AuditRegistrationExt { /* methods from Audit Registration go here */ public AuditRegistrationExt.TYPE getIAUViewSupportType() { // add app specific logic here to determine the type return AuditRegistrationExt.TYPE.<type>; // where type is SIMPLE, INDEXABLE, DISABLE } }
アプリケーションを監査に登録するには、registerAudit
WebLogic Scripting Tool (WLST)コマンドを使用します。このコマンドでは、登録を使用して監査ビューを作成することもできます。
registerAudit(xmlFile, [xlfFile], componentType, [mode=OVERWRITE|UPGRADE], [createView=SIMPLE|INDEXABLE|DISABLE])
SIMPLE
は、createView
に値が入力されなかった場合のデフォルトです。
『インフラストラクチャ・セキュリティWLSTコマンド・リファレンス』のregisterAuditを参照してください。
ドメインの作成時または拡張時、アプリケーションではセキュリティ・ストア内のアプリケーション固有のセキュリティ・データのシードを指定できます。アーティファクトのシードの詳細は、「セキュリティ・アーティファクトのシード方法」を参照してください。
Java EEアプリケーションは、component_events.xml
ファイルとcomponent_events_xlf.jar
ファイルを含むドメイン拡張テンプレートを使用して監査に登録できます。アプリケーションのデプロイ時に、監査登録によってファイルは自動的に処理されます。テンプレートに含まれるファイルの詳細は、「階層型コンポーネントのセキュリティ・アーティファクト」を参照してください。
監査フレームワークでは、監査データの問合せ、プログラムによる監査ポリシーの取得および設定が可能です。まず、次のメソッドを使用してAuditService
インスタンスを取得します。
AuditService auditService = JpsContextFactory.getContextFactory().getContext().getServiceInstance(AuditService.class); AuditAdminService auditAdminService = auditService.getAdminService();
次の各項では、このインスタンスを使用した監査データの問合せ方法と表示方法について説明します。
監査データを問い合せるには、次のメソッドのいずれかを使用します。
Set<String> getComponentNames() throws AuditException; Map<String, ? extends AttributeGroup> getGenericAttributeGroups() throws AuditException; Collection<? extends EventCategory> getSystemEvents() throws AuditException; ComponentDefinition getComponentDef(String componentType) throws AuditException; AttributesDatabaseMap getAttributesMap(String componentType) throws AuditException; AttributesDatabaseMap getSystemAttributesMap() throws AuditException;
次の例では、監査データを問い合せる方法を示しています。
//search events and attributes for a component Set<String> components = auditAdminService.getComponentNames(); for (String componentType : components) { ComponentDefinition componentDef = auditAdminService.getComponentDef(componentType); //get attributes of a component AttributeGroup attrGroup = componentDef.getAttributes(); for (AuditAttribute attr : attrGroup.getAttributes()) { AuditAttribute.DataType type = attr.getAttributeType(); String attrName = attr.getName(); } //get events of a component Collection<? extends EventCategory> events = componentDef.getEvents(); for (EventCategory category : events) { if (category.isComponentSpecific()) { // isComponentSpecific() is true means the category is belong to a component, otherwise is system category Collection<? extends Event> categoryEvents = category.getAllEvents(); } } }
監査ポリシーを取得して設定するには、次のメソッドを使用します。
AuditPolicy getAuditPolicy(String componentType) throws AuditException; void setAuditPolicy(String componentType, AuditPolicy auditPolicy) throws AuditException;
次の例では、これらのメソッドを使用してコンポーネントの監査ポリシーを取得して設定する方法を示します。
//get runtime policy for component JPS final String componentType = "JPS"; AuditPolicy policy = auditAdminService.getAuditPolicy(componentType); String filterLevel = policy.getFilterLevel(); //set runtim policy for component JPS final AuditPolicy newPolicy = new AuditPolicy("None", null, null); //setAuditPolicy() requires AuditStoreAccessPermission(<componentType>, "modify"); AccessController.doPrivileged(new PrivilegedExceptionAction<Object>(){ public Object run() throws AuditException { auditAdminService.setAuditPolicy(componentType, newPolicy); return null; } });
次の各項では、アプリケーションでOracle Fusion Middleware監査フレームワークを使用してプログラムで監査にアクセスし、独自の監査イベントを生成できる方法を示します。
監査フレームワークには次のクラスおよびインタフェースが用意されています。
Interface AuditService { Auditor getAuditor(String componentType); void register(AuditRegistration auditRegistration); void unregister(AuditRegistration auditRegistration); } Interface Auditor { boolean log(AuditEvent ev); boolean isEnabled(); boolean isEnabled(String categoryName, String eventType, boolean eventStatus, Map<String, Object> properties); } public class oracle.security.jps.service.audit.AuditEvent { public AuditEvent(AuditContext ctx, String eventType, String eventCategory, boolean eventStatus, String messageText); public void setApplicationName(String applicationName) public void setAttribute(String attributeName, Object attributeValue) public void setAttributeBoolean(String attributeName, boolean attributeValue) public void setAttributeBoolean(String attributeName, Boolean attributeValue) public void setAttributeBooleans(String attributeName, boolean[] values) public void setAttributeByteArray(String attributeName, byte[] attributeValue) public void setAttributeDate(String attributeName, Date attributeValue) public void setAttributeDates(String attributeName, Date[] values) public void setAttributeDouble(String attributeName, double attributeValue) public void setAttributeDoubles(String attributeName, double[] values) public void setAttributeFloat(String attributeName, float attributeValue) public void setAttributeFloats(String attributeName, float[] values) public void setAttributeInt(String attributeName, int attributeValue) public void setAttributeInts(String attributeName, int[] values) public void setAttributeLong(String attributeName, long attributeValue) public void setAttributeLongs(String attributeName, long[] values) public void setAttributeString(String attributeName, String attributeValue) public void setAttributeStrings(String attributeName, String[] values) public void setComponentName(String componentName) public void setComponentType(String componentType) public void setContextFields(String contextFields) public void setECID(String ecid) public void setEventCategory(String category) public void setEventDefinition(Object eventDefinition) public void setEventStatus(boolean status) public void setEventTimestamp(long eventTimestamp) public void setEventType(String eventType) public void setFailureCode(String failureCode) public void setHostId(String hostId) public void setHostNetworkAddr(String hostNetworkAddr) public void setInitiator(String initiator) public void setInstanceId(String instanceId) public void setMessageText(String messageText) public void setModuleId(String moduleId) public void setOracleHome(String oracleHome) public void setOracleInstance(String oracleInstance) public void setProcessId(String processId) public void setRemoteIP(String value) public void setResource(String value) public void setRID(String rid) public void setRoles(String value) public void setTarget(String value) public void setTargetComponentType(String targetComponentType) public void setThreadId(String threadId) public void setTransactionId(String transactionId) }
パーミッションを設定し、オーディタ・インスタンスを取得するには、「システム権限の設定」および「オーディタ・インスタンスの取得」を参照してください。
アプリケーションには、監査フレームワークに用意されているメソッドを使用するためのAuditStoreAccessPermission
パーミッションが必要です。この例では、権限付与によりMyApp
アプリケーションのAccessController.doPrivileged
ブロックでauditService.getAuditor
メソッドをコールできます。
<grant> <grantee> <codesource> <url>file:${oracle.deployed.app.dir}/MyApp${oracle.deployed.app.ext}</url> </codesource> </grantee> <permissions> <permission> <class>oracle.security.jps.service.audit.AuditStoreAccessPermission</class> <name>comp1</name> <actions>action1,action2,action3</actions> </permission> </permissions> </grant>
<actions>は、アプリケーションで実行できるアクションのカンマ区切りリストです。次の表に、使用可能なアクションを示します。
アクション | クライアントへの認可 |
---|---|
作成 |
新しい監査コンポーネントを登録するための |
アップグレード |
コンポーネント・イベント定義をアップグレードするための |
削除 |
監査コンポーネントを登録解除するための |
読取り |
コンポーネント・オーディタのインスタンスを取得するための |
変更 |
監査ポリシーを変更するための |
アプリケーションを監査に登録すると、プログラムでオーディタ・インスタンスを取得できます。
//Gets audit service instance final AuditService auditService = JpsServiceLocator.getServiceLocator().lookup(AuditService.class); //Gets Auditor instance for application 'MyApp' Auditor auditor = AccessController.doPrivileged( new PrivilegedExceptionAction<Auditor>() { public Auditor run() throws AuditException { return auditService.getAuditor("MyApp"); } }); final String category = "Transaction"; final String eventName = "deposit"; //Check if event 'deposit' is enabled in filtering. boolean enabled = auditor.isEnabled(category, eventName, "true", null); if (enabled) { AuditContext ctx = new AuditContext(); String message = "deposit transaction"; //Creates an audit event AuditEvent ev = new AuditEvent(ctx, eventName, category, "true", message); //Sets event attributes ev.setInitiator("johnsmith"); ev.setAttributeInt("accounting:AccountNumber", 2134567); ev.setAttributeDate("accounting:Date", new Date()); ev.setAttributeFloat("accounting:Amount", 100.00); //Logs audit event boolean ret = auditor.log(event); }
アプリケーションの監査要件の変化に応じて通常、その変化を反映するように監査定義を更新します。具体的には、次のようにします。
注意:
WebLogic Serverドメインを作成または拡張する際に、ドメイン・テンプレートに監査アーティファクトを指定して、監査定義アップグレードを簡単にすることができます。コンポーネント・テンプレートに含まれるファイルの詳細は、「階層型コンポーネントのセキュリティ・アーティファクト」を参照してください。