プライマリ・コンテンツに移動
Oracle® Fusion Middleware Oracle Access Management管理者ガイド
11g リリース2 (11.1.2.3) for All Platforms
E61950-08
目次へ移動
目次

前
次

55.4 アイデンティティ・コンテキストAPI

アイデンティティ・コンテキストAPIは、アイデンティティ・コンテキスト・ディクショナリおよびアイデンティティ・コンテキスト・ランタイムと連動するように設計されたJavaクラスのセットです。

このAPIは、Oracle Java Required Files (JRF)の一部であるIdentityContext.jarとして配布されます。次の例では、アイデンティティ・コンテキスト・ディクショナリと連動するアプリケーションを示します。

例55-1: アイデンティティ・コンテキスト・ディクショナリとの連動

// Display Identity Context Dictionary
try {
  ClaimDictionary idCtxDict = new ClaimDictionary();
  System.out.println
    ("IDC Dictionary :" + idCtxDict.getClaimCount() + "attributes");
  Iterator<String> iterNamespace = idCtxDict.getAllNamespaces();
  while (iterNamespace != null && iterNamespace.hasNext()) {
    String namespace = iterNamespace.next();
    System.out.println("Namespace : " + namespace);
    Iterator<ClaimSchema> 
iterClaimSchema=idCtxDict.getClaimsForNamespace(namespace);
    while (iterClaimSchema != null && iterClaimSchema.hasNext()) {
      out.println(iterClaimSchema.next().getUniqueName());
    }
  }
} catch (Exception e) {
  System.out.println("Unable to acquire IDC Dictionary. " + toString());
}

アプリケーションは、アイデンティティ・コンテキスト・ランタイムと連動し、アプリケーション・インフラストラクチャに現在存在しているアイデンティティ・コンテキストのランタイム状態を取得します。保護されたアプリケーションがアイデンティティ・コンテキスト・ランタイムと連動するには、Oracle Fusion Middleware PS5 (PS5用のOPSS Opatchを適用)またはOracle Fusion Middleware PS6以降で作成されたWebLogic Serverドメインに、そのアプリケーションをデプロイする必要があります。

さらに、アイデンティティ・コンテキスト・ランタイムとの連動は権限付き操作であり、WebLogic Server(必要なアイデンティティ・コンテキスト・サポートがある)で実行されているアプリケーションに適切なソース・コード・グラントがあることを必要とします。WebLogic Serverコンテナ内で実行されている、権限のあるアプリケーションは、OPSS属性サービスに要求することでアイデンティティ・コンテキスト・ランタイムにアクセスできます。次の例では、WLSTを使用してOPSS属性サービスにアプリケーション(この場合はssofilter.jar)へのアクセス権を付与する方法を示します。

属性サービスにアプリケーションへのアクセス権を付与するためのWLSTの使用方法

# sh ../oracle_common/common/bin/wlst.sh
connect ('<username>', '<password>','t3://localhost:7001')
grantPermission(codeBaseURL="file:${common.components.home}/
   modules/oracle.ssofilter_11.1.1/ssofilter.jar", permClass="oracle.security.jps.service.attribute.AttributeAccessPermission",
   permTarget="*", permActions="get, set, remove") 
exit()

次の例では、アイデンティティ・コンテキスト・ランタイムと連動するアプリケーションを示します。

アイデンティティ・コンテキスト・ランタイムとの連動

import java.security.AccessController;
import java.security.PrivilegedAction;
import oracle.security.jps.internal.api.runtime.AppSecurityContext;
import oracle.security.idm.IdentityContext;
 
…
 
// get runtime ID Context from OPSS
private static Object getIDContext() {
  Object idc = AccessController.doPrivileged(new PrivilegedAction<Object>() {
                    public Object run() {return AppSecurityContext.getSecurityContext().getAttribute
  (oracle.security.idm.IdentityContext.Constants.IDC_API_ID); }});
  return idc;
}
 
…
 
// Display runtime ID Context
try {
  Context idCtx = (Context)getIDContext();
  if (idCtx != null) {
    System.out.println("IDC Runtime :" + idCtx.getSize() + "attributes");
    Iterator<Claim> i = idCtx.getClaims();
    while (i != null && i.hasNext()) {
      Claim c = i.next();
      System.out.println(c.getName() + " : " + c.getValue());
    }
  } else {
    System.out.println("Identity Context Runtime is not available");
  }
} catch (Exception e) {
  System.out.println("Unable to acquire Identity Context Runtime. " + e.toString());
}
 
…
 
// Obtain few attributes from Identity Context Runtime
Attr authnLevel = ctx.getAttr (Constants.ATTR_SESSION_AUTHN_LEVEL);
Attr isFirewallEnabled = ctx.getAttr(Constants.ATTR_CLIENT_FIREWALL_ENABLED);
Attr isTrustedDevice = ctx.getAttr(Constants.ATTR_RISK_TRUSTED_DEVICE);
 
// Use user's authentication strength established at login by OAM
int authLevel = new Integer(authnLevel.getValue()).intValue();
if (authLevel < 20) {
    // do something
}