この章では、アプリケーション(監査クライアントとも呼ばれます)がどのようにOracle Fusion Middleware監査フレームワークを使用して監査機能を提供するかを説明します。11gリリース1(11.1.1.6.0)では、監査サービスが導入されています。このサービスは、アプリケーションをプログラム的に監査フレームワークに統合することにより、Oracleコンポーネントで使用可能な機能を使用して、監査イベントをログに記録し、コンプライアンス・レポートを生成することを可能にします。
監査サービスを使用して、アプリケーションは次のことを行えます:
カスタム表を使用せずにイベント定義を作成する
アプリケーションのデプロイ時に監査サービスに登録する
アプリケーションの再デプロイ時にイベント定義を変更する
実行時に監査構成設定を変更する
この章の内容は次のとおりです。
図28-1に示すように、Oracle WebLogic Server上で動作するJava EEアプリケーションは、シームレスに監査フレームワークに統合でき、それを活用できます。
アプリケーションのデプロイメント時または監査サービスの起動時に、Java EEアプリケーションまたはOracleコンポーネントなどのクライアントが監査サービスに登録されます。登録サービスは、component_events.xmlおよび関連ファイルに含まれる最新の監査定義でメタデータ・ストアを更新します。
この章の残りの項では、アプリケーションを監査フローに統合することにより監査イベントを記録して監査レポートを作成する方法について説明します。
アプリケーションを監査フレームワークに統合するには、次の手順を実行します。
監査定義ファイルcomponent_events.xml
を作成します。
アプリケーションのEAR
ファイルにcomponent_events.xml
ファイルおよびcomponent_events_xlf.jarをパッケージ化します。
監査イベントを記録できるように、監査イベントAPIをアプリケーション・コードに追加します。
レポート用にOracle Business Intelligence Publisherなどのレポート作成ツールを統合します。
監査イベント定義を更新し、必要に応じて再デプロイします。
次の各項では、これらのタスクについて詳しく説明します。
このタスクでは、次のファイルを作成します。
component_events.xml定義ファイル
翻訳ファイル
component_events.xmlファイル
アプリケーションで使用する監査定義component_events.xmlファイルを作成します。
component_events.xmlファイル作成の詳細およびファイルの例は、第12.5.1項を参照してください。
監査定義ファイルの作成時には、アプリケーションに対する監査メタデータの作成時に登録サービスが使用する特定のルールについて理解する必要があります。次のものがあります。
バージョン番号。監査イベント定義を変更した場合は、マイナーまたはメジャー番号あるいはその両方を変更することによりバージョンIDを変更する必要があります。
バージョニングの詳細は、第12.5.3.1項を参照してください。
アプリケーションの属性定義とデータベース列間で一意なマッピングを行うための属性マッピング表。各カスタム属性定義には、マッピング順序番号が含まれている必要があります。
属性マッピングの詳細は、第12.5.3.2項を参照してください。
翻訳ファイル
アプリケーションに必要な翻訳ファイルを作成します。
ファイルはXLIFF形式で生成し、component_events_xlf.jarに保管します。登録時に、この情報はコンポーネント監査イベント定義とともに監査メタデータ・ストアに格納されます。
Java EEアプリケーションは、component_events.xml
とcomponent_events_xlf.jar
を、アプリケーションEARファイルのMETA-INF
フォルダにパッケージ化することにより登録できます。監査登録サービスはアプリケーションのデプロイ時にそれらを自動的に処理します。
注意: ファイル名はそれぞれ、 |
このセクションでは、アプリケーションの監査サービスへの登録を可能にする、次の様々なメカニズムについて説明します。
アプリケーションをデプロイ、再デプロイまたはアンデプロイする際に、次の登録アクティビティがデフォルトで発生します。
デプロイ - アプリケーションがまだ登録されていなければ、監査イベント定義を監査メタデータ・ストアに登録します。
再デプロイ - コンポーネントがすでに登録済であれば、コンポーネントの監査イベント定義をアップグレードします。詳細は12.5.3.1項を参照してください。
アンデプロイ - アプリケーションの監査イベント定義を監査メタデータ・ストアから削除します。
カスタム監査登録パラメータは、WebLogicデプロイメント・ディスクリプタweblogic-application.xml
で設定されます。これもアプリケーションEARファイルのMETA-INFフォルダにパッケージ化されます。
注意: 別のディスクリプタ・ファイルがその他のアプリケーション・サーバーにより使用されます。詳細は、Oracle Fusion Middlewareサード・パーティ・アプリケーション・サーバー・ガイドを参照してください。 |
表28-1に、パラメータとそのオプションを示します。
表28-1 監査登録サービスのパラメータ
パラメータ | オプション | 説明 |
---|---|---|
opss.audit.registration |
OVERWRITE |
登録されているかどうかにかかわらず、コンポーネント監査定義を登録します。 |
UPGRADE |
バージョニングのサポートに応じてコンポーネント監査定義を登録します。 |
|
DISABLE |
コンポーネント監査定義を登録しません。 |
|
opss.audit.deregistration |
DELETE(デフォルト・オプション) |
アプリケーションのアンデプロイ時に、コンポーネント監査定義を監査ストアから削除します。 |
DISABLE |
アプリケーションのアンデプロイ時に、コンポーネント監査定義を監査ストアに残します。 |
|
opss.audit.componentType |
カスタム・コンポーネント・タイプを設定します。(オプション) |
weblogic-application.xmlの例
次のweblogic-application.xmlファイルのサンプルは、登録オプションおよび登録解除オプションの使用を示しています。
<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の作成アクションおよびアップグレード・アクションの権限を付与されていることが必要です。権限付与の設定の詳細は、第28.6.2項を参照してください。
次に、プログラムにより監査サービスを登録する例を示します。
// 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 audit service API to register audit event definition AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws AuditException, IOException { auditService.register(auditReg); return null; } });
監査フレームワークの監査管理サービス(管理サービス)によりAPIのセットが提供され、監査メタデータの問合せおよび監査ランタイム・ポリシーの取得、設定に使用されます。管理サービスは次のように呼び出されます。
AuditService auditService = JpsContextFactory.getContextFactory().getContext().getServiceInstance(AuditService.class); AuditAdminService auditAdminService = auditService.getAdminService();
この項では、管理サービスAPIの使用方法を説明します。
監査メタデータに問合せをするAPIは次のとおりです。
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;
次の例では、監査メタデータの問合せにAPIを使用する方法を示します。
//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(); } } }
監査ランタイム・ポリシーを取得し、設定するAPIは次のとおりです。
AuditPolicy getAuditPolicy(String componentType) throws AuditException; void setAuditPolicy(String componentType, AuditPolicy auditPolicy) throws AuditException;
次の例では、コンポーネントの監査ポリシーを取得してから設定するAPIを使用する方法を示します。
//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("All", null, null); //setAuditPolicy() requires AuditStoreAccessPermission(<componentType>, "modify"); AccessController.doPrivileged(new PrivilegedExceptionAction<Object>(){ public Object run() throws AuditException { auditAdminService.setAuditPolicy(componentType, newPolicy); return null; } });
アプリケーションはプログラムにより実行時監査サービスにアクセスし、クライアントAPIを使用して独自の監査イベントを生成できます。
監査クライアントAPIは次のとおりです。
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) }
次の各項では、パーミッションおよび実行時監査インスタンスの取得方法について説明します。
監査クライアントが監査APIを呼び出すには、AuditStoreAccessPermissionが必要です。この例では、権限によりアプリケーションMyApp
はAccessController.doPrivileged
ブロック内のauditService.getAuditor("MyApp")
をコールできます。
<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,….</actions> </permission> </permissions> </grant>
<actions>は、監査クライアントの呼出しに必要な監査APIに関連する、認可されたアクションのカンマ区切りのリストです。指定可能なアクションは次のとおりです。
アクション | クライアントへの認可 |
---|---|
作成 |
新規監査コンポーネントを登録するためのAuditService.register(AuditRegistration)のコール。 |
アップグレード |
既存の監査コンポーネントのイベント定義をアップグレードするためのAuditService.register(AuditRegistration)のコール。 |
削除 |
監査コンポーネントを登録解除するためのAuditService.unregister(AuditRegistration)のコール。 |
読取り |
コンポーネントの監査インスタンスを取得するためのAuditService.getAuditor(String componentType)のコール。 |
変更 |
監査ポリシーを変更するためのAuditAdminService.setAuditPolicy(String componentType, AuditPolicy auditPolicy)のコール。 |
次のサンプル・コードが示すように、監査サービスへの登録後、アプリケーションはプログラムにより実行時監査インスタンスをOPSS監査サービスから取得できます。
//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); }
監査統合の最終的な目的は、監査データベース表に保管された監査イベントのレポートを作成することです。第13.6.1項で説明されているように、監査イベントは共通属性テーブルiau_common
(第12.4.2.2項)およびカスタム属性テーブルiau_custom_nnn
(第12.4.2.4項)に保存されます。OPSS共通監査フレームワークは、コンポーネントに対してSQLスクリプトを生成し、レポート作成アプリケーションのコンポーネントが監査データベース表の監査イベント・データの問合せに使用できるOracleデータベース・ビューを作成します。
次の手順(一部はすでに実行済)が必要です。
監査ポリシーを構成し、監査データを生成するイベントを、実行時監査サービスがログに記録できるようにします(第28.5項および第28.6項)。
監査ローダーを構成し、バスストップ・ファイルがデータベースに移行されたことを確認します(第13.2項)。
createAuditDBView
コマンドを使用し、監査定義のSQLスクリプトを生成します(第12.5.3.2項の「コンポーネントの監査定義の表示」)。
IAUスキーマ・ユーザーとしてデータベースにログインし、前述の手順のSQLスクリプトを使用したビューを作成します。
ビューに問い合せるレポート作成アプリケーションを構成します。
これは、ApplicationAudit
コンポーネント用createAuditDBView
のサンプル出力です。
-- Audit View for Component CREATE VIEW ApplicationAudit_AUDITVIEW AS SELECT IAU_AUDITSERVICE.IAU_TRANSACTIONID AS AUDITSERVICE_TRANSACTIONID, IAU_COMMON.IAU_COMPONENTTYPE AS ComponentType, IAU_COMMON.IAU_MAJORVERSION AS MajorVersion, IAU_COMMON.IAU_MINORVERSION AS MinorVersion, IAU_COMMON.IAU_INSTANCEID AS InstanceId, IAU_COMMON.IAU_HOSTID AS HostId, IAU_COMMON.IAU_HOSTNWADDR AS HostNwaddr, IAU_COMMON.IAU_MODULEID AS ModuleId, IAU_COMMON.IAU_PROCESSID AS ProcessId, IAU_COMMON.IAU_ORACLEHOME AS OracleHome, IAU_COMMON.IAU_HOMEINSTANCE AS HomeInstance, IAU_COMMON.IAU_ECID AS ECID, IAU_COMMON.IAU_RID AS RID, IAU_COMMON.IAU_CONTEXTFIELDS AS ContextFields, IAU_COMMON.IAU_SESSIONID AS SessionId, IAU_COMMON.IAU_TARGETCOMPONENTTYPE AS TargetComponentType, IAU_COMMON.IAU_APPLICATIONNAME AS ApplicationName, IAU_COMMON.IAU_EVENTTYPE AS EventType, IAU_COMMON.IAU_EVENTCATEGORY AS EventCategory, IAU_COMMON.IAU_EVENTSTATUS AS EventStatus, IAU_COMMON.IAU_TSTZORIGINATING AS TstzOriginating, IAU_COMMON.IAU_THREADID AS ThreadId, IAU_COMMON.IAU_COMPONENTNAME AS ComponentName, IAU_COMMON.IAU_INITIATOR AS Initiator, IAU_COMMON.IAU_MESSAGETEXT AS MessageText, IAU_COMMON.IAU_FAILURECODE AS FailureCode, IAU_COMMON.IAU_REMOTEIP AS RemoteIP, IAU_COMMON.IAU_TARGET AS Target, IAU_COMMON.IAU_RESOURCE AS IAU_RESOURCE, IAU_COMMON.IAU_ROLES AS Roles, IAU_COMMON.IAU_DOMAINNAME AS DomainName, IAU_COMMON.IAU_COMPONENTDATA AS ComponentData, IAU_COMMON.IAU_AUDITUSER AS AuditUser, IAU_COMMON.IAU_TENANTID AS TenantId, IAU_COMMON.IAU_TRANSACTIONID AS TransactionId, IAU_COMMON.IAU_USERTENANTID AS UserTenantId, IAU_CUSTOM.IAU_INT_001 AS AccountNumber, IAU_CUSTOM.IAU_DATETIME_001 AS Date, IAU_CUSTOM.IAU_FLOAT_001 AS Amount, IAU_CUSTOM.IAU_STRING_002 AS Status, IAU_CUSTOM.IAU_FLOAT_002 AS Balance, IAU_USERSESSION.IAU_AUTHENTICATIONMETHOD AS AuthenticationMethod FROM IAU_AUDITSERVICE, IAU_COMMON, IAU_CUSTOM, IAU_USERSESSION WHERE IAU_COMMON.IAU_ID = IAU_AUDITSERVICE.IAU_ID AND IAU_COMMON.IAU_ID = IAU_CUSTOM.IAU_ID AND IAU_COMMON.IAU_ID = IAU_USERSESSION.IAU_ID AND IAU_COMMON.IAU_ComponentType = 'ApplicationAudit';
Oracle Business Intelligence Publisherの使用
Oracle Business Intelligence Publisherを利用することにより、Oracleコンポーネントで使用可能なものと同じレポート機能を使用して、アプリケーションの監査データからレポートを生成できます。
基本手順は次のとおりです。
(createAuditDBView
コマンドを使用して作成された)データベース・ビューを使用し、Oracle BI Publisherレポート・テンプレートを生成します。
Oracle BI Publisherレポート・サービスを設定します。
レポート・テンプレートをOracle BI Publisherにコピーして、コンポーネント監査イベントを表示します。
Oracle BI Publisherでレポートを生成します。
アプリケーションの監査要件の変化に応じて、変化を反映するように統合を更新できます。手順は次のとおりです。
監査ファイル定義を更新します。この手順の実行時にはバージョニング・ルールに注意してください。
更新されたイベント定義ファイルとともにアプリケーションEARファイルを再デプロイします。または、監査登録サービスに新しいバージョンの存在を通知することもできます。
変更を検証します。