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

前
 
次
 

22 Oracle Fusion Middleware監査フレームワークを使用した開発

この章では、Oracle Fusion Middleware監査フレームワーク(OFM監査フレームワーク)を使用してアプリケーション・イベントを監査する方法について説明します。このフレームワークを使用して、イベント定義の作成、デプロイ時のサービスへのアプリケーションの登録、実行時の監査構成の変更およびレポートの生成を行います。

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

22.1 アプリケーションとOFM監査フレームワークの統合

アプリケーションをOFM監査フレームワークと統合するには、次の各項で説明されるタスクを実行します。

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

次の各項では、component-event.xmlおよび翻訳ファイルの作成方法について説明します。

22.2.1 component-events.xmlファイル

component-events.xml監査定義ファイルを作成する際には、次の点に留意してください。

  • 監査イベント定義を変更する場合は、マイナー番号またはメジャー番号を変更してバージョンIDを変更する必要があります。

  • アプリケーション属性定義の表とデータベース列は、1対1で対応する必要があります。各カスタム属性には、対応する順序番号が属性定義に含まれている必要があります。

22.2.2 翻訳ファイル

次の手順では、XLIFF (XML Localization Interchange File Format)翻訳ファイルを生成して、component_events_xlf.jarファイルにパックする方法について説明します。デプロイ時および登録中に、この情報はコンポーネント監査イベント定義とともに監査ストアに格納されます。

  1. 次のようなコマンドを実行してXLIFFファイルを生成します。

    java -cp $MW_HOME/oracle_common/modules/oracle.jps_12.2.1/jpsaudit.jar:
    $MW_HOME/oracle_common/modules/oracle.jps_12.2.1/jps-api.jar oracle.security.audit.tools.NewXlfGenerator
    -s /tmp/comp_events.xml
    -t /tmp/comp_events.xlf
  2. 生成されたxlfファイルをサポートされている言語に翻訳します。このxlfファイルには、すべてのカテゴリ、イベント、属性に関する翻訳ユニットおよびヘルプ・テキストが含まれます。これらの接頭辞は、Category_、Event_およびAttribute_です。

  3. 翻訳済ファイルをJARファイルにパッケージ化します。

22.3 サービスへのアプリケーションの登録

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


注意:

ドメイン拡張テンプレートを使用した登録が望ましい方法です。テンプレートの詳細は、「監査アーティファクト用ドメイン拡張テンプレートの使用」を参照してください。

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

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

  • デフォルトの監査登録

  • カスタム監査登録

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

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

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

  • 再デプロイ - コンポーネントがすでに登録されている場合に、コンポーネント・イベント定義をアップグレードします。

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

監査レコードを問い合せるための簡易データベース・ビューは、登録時にIAUスキーマ内に作成されます。これは、Oracle Fusion Middlewareリポジトリ作成ユーティリティによってビューが作成されるコンポーネントを除いたすべてについて発生します。

22.3.1.2 カスタム監査登録

監査登録をカスタマイズするパラメータは、weblogic-application.xml WebLogicデプロイメント記述子で設定します。このファイルは、アプリケーションのエンタープライズ・アーカイブ(EAR)ファイルのMETA-INFディレクトリでパッケージ化されます。パッケージ化の要件の詳細は、第23.5項を参照してください。

監査レコードを問い合せるための簡易データベース・ビューは、ビューの作成を明示的に無効にしないかぎり、監査登録時に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

  • 簡易IAUビューを作成します(デフォルトの動作)。

  • 索引がcomponent_events.xmlアプリケーション・ファイルで指定されている場合は、索引付け可能IAUビューを作成します。

  • ビューの作成を無効にします。


次の例では、登録オプションと登録解除オプションの使用方法を示します。

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

22.3.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パーミッションがアプリケーションに付与されている必要があります。権限の指定の詳細は、「システム権限の設定」を参照してください。

次に、プログラムによる登録例を示します。

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

22.3.3 WLSTコマンドを使用した登録

アプリケーションを監査に登録するには、registerAudit WebLogic Scripting Tool (WLST)コマンドを使用します。このコマンドでは、登録を使用して監査ビューを作成することもできます。

registerAudit(xmlFile, [xlfFile], componentType, [mode=OVERWRITE|UPGRADE], [createView=SIMPLE|INDEXABLE|DISABLE]) 

SIMPLEは、createViewに値が入力されなかった場合のデフォルトです。

『Oracle Fusion Middlewareインフラストラクチャ・セキュリティWLSTコマンド・リファレンス』のregisterAuditに関する項を参照してください。

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

ドメインの作成時または拡張時、アプリケーションではセキュリティ・ストア内のアプリケーション固有のセキュリティ・データのシードを指定できます。アーティファクトのシードの詳細は、第7.1項「セキュリティ・アーティファクトのシード方法」を参照してください。

Java EEアプリケーションは、component_events.xmlファイルとcomponent_events_xlf.jarファイルを含むドメイン拡張テンプレートを使用して監査に登録できます。アプリケーションのデプロイ時に、監査登録によってファイルは自動的に処理されます。テンプレートに含まれるファイルの詳細は、第7.4項「階層型コンポーネントのセキュリティ・アーティファクト」を参照してください。

22.4 プログラムによるポリシーの管理

OFM監査フレームワークでは、監査データの問合せ、プログラムによる監査ポリシーの取得および設定が可能です。まず、次のメソッドを使用してAuditServiceインスタンスを取得します。

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

次の各項では、このインスタンスを使用した監査データの問合せ方法と表示方法について説明します。

22.4.1 監査データの問合せ

監査データを問い合せるには、次のメソッドのいずれかを使用します。

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

22.4.2 監査ポリシーの表示と設定

監査ポリシーを取得して設定するには、次のメソッドを使用します。

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

22.5 プログラムによる監査イベントのロギング

次の各項では、アプリケーションでOFM監査フレームワークを使用してプログラムで監査にアクセスし、独自の監査イベントを生成できる方法を示します。

22.5.1 OFM監査フレームワークのインタフェース

OFM監査フレームワークには次のクラスおよびインタフェースが用意されています。

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

パーミッションを設定し、オーディタ・インスタンスを取得するには、「システム権限の設定」および「オーディタ・インスタンスの取得」を参照してください。

22.5.2 システム権限の設定

アプリケーションには、OFM監査フレームワークに用意されているメソッドを使用するための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>は、アプリケーションで実行できるアクションのカンマ区切りリストです。次の表に、使用可能なアクションを示します。

アクション クライアントへの認可
作成 新しい監査コンポーネントを登録するためのAuditService.registerのコール。
アップグレード コンポーネント・イベント定義をアップグレードするためのAuditService.registerのコール。
削除 監査コンポーネントを登録解除するためのAuditService.unregisterのコール。
読取り コンポーネント・オーディタのインスタンスを取得するためのAuditService.getAuditorのコール。
変更 監査ポリシーを変更するためのAuditAdminService.setAuditPolicyのコール。

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

アプリケーションを監査に登録すると、プログラムでオーディタ・インスタンスを取得できます。

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

22.6 監査定義の更新と保守

アプリケーションの監査要件の変化に応じて通常、その変化を反映するように監査定義を更新します。具体的には、次のようにします。

  1. 監査ファイル定義を更新します。バージョンの詳細は、第13.7項「マッピングとバージョン・ルールについて」を参照してください。

  2. 更新されたイベント定義ファイルとともにアプリケーションEARファイルを再デプロイします。あるいは、新しいバージョンについて監査登録に通知します。

  3. 変更を検証します。


注意:

WebLogic Serverドメインを作成または拡張する際に、ドメイン・テンプレートに監査アーティファクトを指定して、監査定義アップグレードを簡単にすることができます。コンポーネント・テンプレートに含まれるファイルの詳細は、第7.4項「階層型コンポーネントのセキュリティ・アーティファクト」を参照してください。