プライマリ・コンテンツに移動
Oracle® Fusion Middleware Oracle Platform Security Servicesによるアプリケーションの保護
12c (12.1.3)
E59413-03
  目次へ移動
目次

前
 
次
 

23 監査サービスを使用した開発

この章では、アプリケーションがOracle Fusion Middleware監査フレームワークを使用して監査機能を提供する方法について説明します。

Oracle Fusion Middleware監査フレームワークには、監査サービスが含まれ、このサービスは、アプリケーションをプログラム的に監査フレームワークに統合することにより、Oracleコンポーネントで使用可能な機能を使用して、監査イベントをログに記録し、コンプライアンス・レポートを生成することを可能にします。

監査サービスを使用して、アプリケーション(監査クライアントとも呼ばれます)は次のことを行えます。

この章の内容は次のとおりです。

23.1 アプリケーションと監査フローの統合方法の理解

図23-1に示すように、Oracle WebLogic Server上で動作するJava EEアプリケーションは、シームレスに監査フレームワークに統合でき、それを活用できます。

図23-1 監査フレームワークへのアプリケーションの統合

図23-1については周囲のテキストで説明しています。

アプリケーションのデプロイメント時または監査サービスの起動時に、Java EEアプリケーションまたはOracleコンポーネントなどのクライアントが監査サービスに登録されます。登録サービスは、component_events.xmlおよび関連ファイルに含まれる最新の監査定義でメタデータ・ストアを更新します。


関連項目:

監査フローの詳細は、第13.3項を参照してください。

この章の残りの項では、アプリケーションを監査フレームワークに統合することにより監査イベントを記録して監査レポートを作成する方法について説明します。

23.2 監査フレームワークへのアプリケーションの統合

アプリケーションを監査フレームワークに統合するには、次の手順を実行します。

  1. 次の翻訳作業を完了します。

    1. 監査定義ファイルcomponent_events.xmlを作成します。

    2. サポートされている言語すべての翻訳を取得します。

    3. 翻訳後のファイルをcomponent_events_xlf.jarファイルにパッケージします。

  2. アプリケーションのEARファイルにcomponent_events.xmlファイルおよびcomponent_events_xlf.jarをパッケージ化します。

  3. 監査イベントを記録できるように、監査イベントAPIをアプリケーション・コードに追加します。

  4. IAUスキーマとデータベースが監査データをアップロードして報告するように設定されていることを確認します。

  5. レポート用にOracle Business Intelligence Publisherなどのレポート作成ツールを統合します。

  6. 定期メンテナンスの場合は、監査イベント定義を更新し、必要に応じてデプロイしなおします。

次の各項では、これらのタスクについて詳しく説明します。


関連項目:

監査アーティファクトを処理する代替のテンプレート・モードについては、第7章を参照してください。

23.3 監査定義ファイルの作成

このタスクでは、次のファイルを作成します。

23.3.1 component-events.xmlファイルの作成

アプリケーションで使用する監査定義component_events.xmlファイルを作成します。

component_events.xmlファイル作成の詳細およびファイルの例は、第13.5.1項を参照してください。

監査定義ファイルの作成時には、アプリケーションに対する監査メタデータの作成時に登録サービスが使用する特定のルールについて理解する必要があります。次のものがあります。

  • バージョン番号。監査イベント定義を変更した場合は、マイナーまたはメジャー番号あるいはその両方を変更することによりバージョンIDを変更する必要があります。

    バージョニングの詳細は、第13.5.3.1項を参照してください。

  • アプリケーションの属性定義とデータベース列間で一意なマッピングを行うための属性マッピング表。各カスタム属性定義には、マッピング順序番号が含まれている必要があります。

    属性マッピングの詳細は、第13.5.3.2項を参照してください。

23.3.2 翻訳ファイルの作成

アプリケーションに必要な翻訳ファイルを作成します。

ファイルはXLIFF(XML Localisation Interchange File Format)形式で生成し、component_events_xlf.jarに保管します。登録時に、この情報はコンポーネント監査イベント定義とともに監査メタデータ・ストアに格納されます。

手順は次のとおりです。

  1. 次のようなJavaコマンドを実行して、XLIFFを生成します。

    java -cp $MW_HOME/oracle_common/modules/oracle.jps_12.1.2/jpsaudit.jar:
    $MW_HOME/oracle_common/modules/oracle.jps_12.1.2/jps-api.jar oracle.security.audit.tools.NewXlfGenerator
    -s /tmp/comp_events.xml
    -t /tmp/comp_events.xlf
  2. 生成されたxlfファイルをサポートされている言語に翻訳します。

    生成されたcomp_events.xlfファイルには、すべてのカテゴリ、イベント、属性についての翻訳ユニットとヘルプ・テキストが含まれます。それぞれの翻訳ユニットIDの接頭辞は、Category_、Event_、Attribute_です。

    たとえば、CredentialManagementカテゴリの翻訳ユニットIDはCategory_CredentialManagementになります。ソースには表示名が付けられます。また、ファイルの翻訳後はターゲットには表示名の翻訳が付けられます。

  3. 翻訳が終了したら、翻訳されたファイルをjarファイルにパッケージしてから、監査登録をしてください。詳細は、23.4項を参照してください。

23.4 監査サービスへのアプリケーションの登録

このセクションでは、アプリケーションの監査サービスへの登録を可能にする、次の様々なメカニズムについて説明します。


注意:

登録にはドメイン拡張テンプレートの使用をお薦めします。詳細は、第23.4.4項を参照してください。

23.4.1 宣言による監査登録の実行

この項では、2種類の宣言による監査定義の登録方法を説明します。

  • デフォルトの監査登録

  • カスタム監査登録

アプリケーション監査登録

アプリケーションをデプロイ、再デプロイまたはアンデプロイする際に、次の登録アクティビティがデフォルトで発生します。

  • デプロイ - アプリケーションがまだ登録されていなければ、監査イベント定義を監査メタデータ・ストアに登録します。

  • 再デプロイ - コンポーネントがすでに登録済であれば、コンポーネントの監査イベント定義をアップグレードします。詳細は13.5.3.1項を参照してください。

  • アンデプロイ - アプリケーションの監査イベント定義を監査メタデータ・ストアから削除します。

カスタム・アプリケーション監査登録

カスタム監査登録パラメータはWebLogicデプロイメント記述子weblogic-application.xmlで設定します。このファイルは、アプリケーションのEARファイルのMETA-INFフォルダにパッケージされています。パッケージ化の要件については、第24.5項を参照してください。

表23-1に、パラメータとそのオプションを示します。

表23-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>

23.4.2 登録のプログラムによる呼出し

監査登録サービスをプログラムで呼び出して、アプリケーションを監査サービスに登録できます。登録のロジックは次のとおりです。

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の作成アクションおよびアップグレード・アクションの権限を付与されていることが必要です。権限付与の設定の詳細は、第23.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;
            }
        });

23.4.3 コマンド・ラインでの登録の実行

WLSTを通じ、コマンド・ラインで監査サービスへアプリケーションを登録できます。詳細は、『Oracle Fusion Middlewareインフラストラクチャ・セキュリティWLSTコマンド・リファレンス』のregisterAuditを参照してください。

23.4.4 監査アーティファクト用ドメイン拡張テンプレートの使用

ドメインの作成時または拡張時、第7.1項で説明されているとおり、アプリケーションは、監査構成アーティファクトなどアプリケーション固有のセキュリティ・アーティファクトのシードをドメイン・セキュリティ・ストアに指定できます。

Java EEアプリケーションはcomponent_events.xmlcomponent_events_xlf.jarファイルを含むドメイン拡張テンプレートを使用して、監査サービスに登録できます。監査登録サービスはアプリケーションのデプロイ時にそれらを自動的に処理します。詳細は、7.4項を参照してください。


注意:

ファイル名はそれぞれ、component_events.xmlおよびcomponent_events_xlf.jarとする必要があります

23.5 管理サービスAPIを使用した監査ポリシーの管理

監査フレームワークの監査管理サービス(管理サービス)によりAPIのセットが提供され、監査メタデータの問合せおよび監査ランタイム・ポリシーの取得、設定に使用されます。管理サービスは次のように呼び出されます。

AuditService auditService = JpsContextFactory.getContextFactory().getContext().getServiceInstance(AuditService.class);
    AuditAdminService auditAdminService = auditService.getAdminService();

この項では、管理サービスAPIの使用方法を説明します。

23.5.1 監査メタデータの問合せ

監査メタデータに問合せをする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();
 
            }
        }
    }

23.5.2 監査ランタイム・ポリシーの表示と設定

監査ランタイム・ポリシーを取得し、設定する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("None", null, null);
    //setAuditPolicy() requires AuditStoreAccessPermission(<componentType>, "modify");
    AccessController.doPrivileged(new PrivilegedExceptionAction<Object>(){
        public Object run() throws AuditException {
            auditAdminService.setAuditPolicy(componentType, newPolicy);
            return null;
        }
    });

第23.6項 「監査イベントを記録するためのアプリケーション・コードの追加」

アプリケーションはプログラムにより実行時監査サービスにアクセスし、クライアントAPIを使用して独自の監査イベントを生成できます。

23.6.1 監査クライアントAPIの使用

監査クライアントAPIは次のとおりです。


関連項目:

第23.6.2項getAuditorを使用する前提条件。

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) }

次の各項では、パーミッションおよび実行時監査インスタンスの取得方法について説明します。

23.6.2 システム権限の設定

監査クライアントが監査APIを呼び出すには、AuditStoreAccessPermissionが必要です。この例では、権限によりアプリケーションMyAppAccessController.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)のコール。

23.6.3 監査インスタンスの取得

次のサンプル・コードが示すように、監査サービスへの登録後、アプリケーションはプログラムにより実行時監査インスタンスを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);
}

23.7 監査定義の更新と保守

アプリケーションの監査要件の変化に応じて、変化を反映するように統合を更新できます。手順は次のとおりです。

  1. 監査ファイル定義を更新します。この手順の実行時にはバージョニング・ルールに注意してください。


    関連項目:

    バージョニング・ルールについては第13.5.3項を参照してください。

  2. 更新されたイベント定義ファイルとともにアプリケーションEARファイルを再デプロイします。または、監査登録サービスに新しいバージョンの存在を通知することもできます。

  3. 変更を検証します。


注意:

WebLogicドメインを作成または拡張する場合は、ドメイン・テンプレートに監査アーティファクトを指定して、監査定義をアップグレードしやすくすることができます。詳細は、7.4項を参照してください。