Sling Authenticator

Sling Authenticatorは、公開時にアソシエート UI リソースにアクセスするための認証を強制します。

ui.config/src/main/content/jcr_root/apps/<project-name>/osgiconfig/config.publishのファイル org.apache.sling.engine.impl.auth.SlingAuthenticator~saml.cfg.jsonを更新します:

{
  "sling.auth.requirements": ["+/libs/fd/associate/ui.html"],
  "sling.auth.anonymous": false
}

Dispatcher フィルター

次のルールを追加して、インタラクティブ通信APIとアソシエート UIがパブリッシュインスタンスで正しく機能するようにします。

まだ存在しない場合は、次のルールをdispatcher/src/conf.dispatcher.d/filters/filters.any ファイルに追加します。

  # Allow Interactive Communications APIs and Associate UI
  /XXXX { /type "allow" /method '(GET|OPTIONS)' /url "/adobe/communications" }
  /XXXX { /type "allow" /method '(GET|POST|OPTIONS)' /url "/adobe/communications/*" }
  /XXXX { /type "allow" /method "GET" /url "/content/dam/fd:fonts/*" }
  /XXXX { /type "allow" /method '(GET|OPTIONS)' /url "/libs/fd/associate/*" }
メモ
XXXXを、既存のfilters.any ファイルで使用されている適切な数列に置き換えます。

パブリッシュインスタンスでのアソシエイト UIの呼び出し

この節では、独自のアプリケーションからアソシエート UIを起動する方法について説明します。 すぐに使用できるサンプルのHTMLページから始め、自社の環境に合わせて設定するなど、次の手順に従ってすばやく開始できます。

手順1:サンプル HTML ページから始める

Associate UIの統合機能の仕組みをすばやくテストして理解するには、次のサンプル HTML ページを使用します。 このコードをHTML ファイルにコピーし、ブラウザーで開きます。

メモ
このサンプル HTMLには、IC IDと事前入力サービスが必要です。 IC IDとサンプルの事前入力サービス「FdmTestData」を使用してテストできます。

HTML サンプルでは、インタラクティブ通信の詳細を入力し、ワンクリックでアソシエート UIを起動できるシンプルなフォームインターフェイスが用意されています。

<!DOCTYPE html>
<html>
<head>
  <title>Associate UI Integration</title>
  <style>
    body {
      font-family: sans-serif;
      max-width: 600px;
      margin: 50px auto;
      padding: 20px;
    }
    .form-group {
      margin: 20px 0;
    }
    label {
      display: block;
      margin-bottom: 5px;
      font-weight: bold;
    }
    input, textarea {
      width: 100%;
      padding: 8px;
      border: 1px solid #ccc;
      border-radius: 4px;
      box-sizing: border-box;
    }
    textarea {
      height: 80px;
      font-family: monospace;
    }
    button {
      padding: 10px 20px;
      margin: 5px;
      cursor: pointer;
      border-radius: 4px;
    }
    .btn-primary {
      background: #007bff;
      color: white;
      border: none;
    }
    .btn-primary:hover {
      background: #0056b3;
    }
    .error {
      color: red;
      font-size: 12px;
      display: none;
    }
  </style>
</head>
<body>
  <h1>Launch Associate UI</h1>

  <form id="form">
    <div class="form-group">
      <label>IC ID *</label>
      <input type="text" id="icId" placeholder="Enter Interactive Communication ID" required>
    </div>

    <div class="form-group">
      <label>Prefill Service</label>
      <input type="text" id="serviceName" placeholder="e.g., CustomerDataService">
    </div>

    <div class="form-group">
      <label>Service Parameters (JSON)</label>
      <textarea id="serviceParams" placeholder='{"customerId": "12345"}'>{}</textarea>
      <span id="paramsError" class="error">Invalid JSON format</span>
    </div>

    <div class="form-group">
      <label>Options (JSON)</label>
      <textarea id="options" placeholder='{"mode": "edit", "locale": "en_US"}'>{}</textarea>
      <span id="optionsError" class="error">Invalid JSON format</span>
    </div>

    <button type="button" onclick="reset()">Reset</button>
    <button type="button" class="btn-primary" onclick="launch()">Launch Associate UI</button>
  </form>

  <script>
    // Replace with your AEM Publish instance URL
    const AEM_URL = 'https://publish-p{program-id}-e{env-id}.adobeaemcloud.com/libs/fd/associate/ui.html';

    function validateJSON(str, errorId) {
      const err = document.getElementById(errorId);
      try {
        const obj = JSON.parse(str || '{}');
        err.style.display = 'none';
        return obj;
      } catch (e) {
        err.style.display = 'block';
        return null;
      }
    }

    function launch() {
      const icId = document.getElementById('icId').value.trim();
      if (!icId) {
        alert('IC ID is required');
        return;
      }

      const params = validateJSON(document.getElementById('serviceParams').value, 'paramsError');
      const opts = validateJSON(document.getElementById('options').value, 'optionsError');

      if (!params || !opts) {
        alert('Please fix JSON errors before launching');
        return;
      }

      const data = {
        id: icId,
        prefill: {
          serviceName: document.getElementById('serviceName').value.trim(),
          serviceParams: params
        },
        options: opts
      };

      const win = window.open(AEM_URL, '_blank');
      if (!win) {
        alert('Pop-up blocked. Please enable pop-ups for this site.');
        return;
      }

      const handler = (e) => {
        if (e.data && e.data.type === 'READY' && e.data.source === 'APP') {
          win.postMessage({ type: 'INIT', source: 'PORTAL', data }, '*');
          window.removeEventListener('message', handler);
        }
      };

      window.addEventListener('message', handler);

      // Fallback timeout in case READY message is missed
      setTimeout(() => {
        if (win && !win.closed) {
          win.postMessage({ type: 'INIT', source: 'PORTAL', data }, '*');
          window.removeEventListener('message', handler);
        }
      }, 1000);
    }

    function reset() {
      document.getElementById('form').reset();
      document.getElementById('serviceParams').value = '{}';
      document.getElementById('options').value = '{}';
      document.getElementById('paramsError').style.display = 'none';
      document.getElementById('optionsError').style.display = 'none';
    }
  </script>
</body>
</html>

手順2:公開インスタンス URLの設定

関連付けUIを起動する前に、サンプルをAEM Forms Cloud Service パブリッシュインスタンスに向ける必要があります。

上記のHTML サンプルで、<script> セクションで次の行を見つけます。

const AEM_URL = 'https://publish-p{program-id}-e{env-id}.adobeaemcloud.com/libs/fd/associate/ui.html';

プレースホルダーの値を実際の環境の詳細に置き換えます。

  • {program-id}: AEM Cloud Service プログラム ID
  • {env-id}:環境ID

例えば、プログラム IDが12345、環境IDが67890の場合、URLは次のようになります。

const AEM_URL = 'https://publish-p12345`-e67890.adobeaemcloud.com/libs/fd/associate/ui.html';
メモ
セキュリティ上の理由から、インタラクティブ通信ID、事前入力サービス、サービスパラメーターなどのパラメーターはURLを通じて渡されません。 代わりに、これらのパラメーターはJavaScriptのpostMessage APIを使用して安全に渡されます。

手順3:JavaScript統合機能について

サンプル HTMLでは、次のJavaScript関数を使用してアソシエイト UIを起動します。 この関数は、IC IDの検証、データペイロードの作成、新しいブラウザーウィンドウでの関連付けUIの開き、ブラウザーのpostMessage APIを使用したデータの送信を行います。

function launchAssociateUI(icId, prefillService, prefillParams, options) {
  if (!icId) {
    console.error('IC ID required');
    return;
  }

  const data = {
    id: icId,
    prefill: {
      serviceName: prefillService || '',
      serviceParams: prefillParams || {}
    },
    options: options || {}
  };

  const AEM_URL = 'https://your-aem.adobeaemcloud.com/libs/fd/associate/ui.html';
  const win = window.open(AEM_URL, '_blank');

  if (!win) {
    alert('Please enable pop-ups for this site');
    return;
  }

  const readyHandler = (event) => {
    if (event.data && event.data.type === 'READY' && event.data.source === 'APP') {
      win.postMessage({ type: 'INIT', source: 'PORTAL', data: data }, '*');
      window.removeEventListener('message', readyHandler);
    }
  };

  window.addEventListener('message', readyHandler);

  // Fallback timeout in case READY message is missed
  setTimeout(() => {
    if (win && !win.closed) {
      win.postMessage({ type: 'INIT', source: 'PORTAL', data: data }, '*');
      window.removeEventListener('message', readyHandler);
    }
  }, 1000);
}

この関数は、IC ID (必須)、事前入力サービス名、事前入力サービスパラメーター、および追加オプションの4つのパラメーターを受け入れます。 これらのパラメーターは、以下で説明するようにデータペイロードに構造化されます。

手順4:データペイロード構造の理解

ペイロード形式:

const data = {
  id: "your-ic-id",              // Required: Interactive Communication ID
  prefill: {                      // Optional: Data to prefill the IC
    serviceName: "YourService",
    serviceParams: { key: "value" }
  },
  options: {}                     // Optional: Additional configuration options
};

ペイロードコンポーネント:

Component必須説明
idはいロードするインタラクティブ通信(IC)の識別子
prefillオプションデータ事前入力のサービス設定が含まれます
prefill.serviceNameオプションデータの事前入力のために呼び出すフォームデータモデルサービスの名前
prefill.serviceParamsオプション事前入力サービスに渡されるキーと値のペア
optionsオプションPDF レンダリングでサポートされる追加のプロパティ(ロケール、includeAttachments、embedFonts、makeAccessible)

データペイロードの例

最小ペイロード (IC IDのみ)

これは、事前入力データが必要ない場合に使用します。

{
  "id": "12345",
  "prefill": {
    "serviceName": "",
    "serviceParams": {}
  },
  "options": {}
}

事前入力データ​を使用

これを使用して、ICに顧客データを動的に入力します。

{
  "id": "12345",
  "prefill": {
    "serviceName": "IC_FDM",
    "serviceParams": {
      "customerId": "101",
      "accountNumber": "ACC-98765"
    }
  },
  "options": {}
}

PDF レンダリングオプション付き

これを使用して、追加のレンダリングオプションを指定します。

{
  "id": "12345",
  "prefill": {
    "serviceName": "IC_FDM",
    "serviceParams": {
      "customerId": "101",
      "accountNumber": "ACC-98765"
    }
  },
  "options": {
      "locale": "en_US",
      "includeAttachments": "true",
      "webOptimized": "false",
      "embedFonts": "false",
      "makeAccessible": "false"
  }
}

手順5:IC IDを入力し、アソシエイト UIを起動する

これで、サンプル HTML ページを使用してアソシエイト UIを起動する準備が整いました。

  1. IC ID​を入力:IC ID フィールドに、公開したインタラクティブ通信の識別子を入力します。 これが唯一の必須フィールドです。

  2. 事前入力サービスの設定: ICに動的データを事前入力する場合は、事前入力サービス フィールドにフォームデータモデルサービス名を入力します。 例えば、サンプルデータにはFdmTestDataを使用します。

    HTML UIの例

  3. アソシエイト UIの起動​をクリック:「アソシエイト UIの起動」ボタンをクリックします。 新しいブラウザーウィンドウが開き、インタラクティブ通信が事前に読み込まれたアソシエイト UIが表示されます。

データを入力すると、次のように関連付けUIが表示されます。

UIの関連付け

メモ
ウィンドウが開かない場合は、このサイトのポップアップがブラウザーで許可されているか確認してください。

トラブルシューティング

ポップアップをブロックしました

問題:関連付けUI ウィンドウが開きません。

解決策:

  • ブラウザー設定でドメインのポップアップを有効にする
  • window.open()がユーザーアクション (ボタンのクリックなど)から呼び出されていることを確認する
  • 様々なブラウザーを使用してテストし、ブロックの動作を特定します

データが読み込まれていません

問題: インタラクティブ通信が開きますが、データが入力されません。

解決策:

  • IC IDが正しく、ICが公開されていることを確認します
  • ブラウザーコンソールでJavaScript エラーを確認する
  • postMessage構造が仕様と正確に一致していることを確認します
  • フォームデータモデルサービスが正しく設定されていることを確認します

認証エラー

問題:アソシエート UIを開くと、認証エラーが表示されます。

解決策:

  • パブリッシュインスタンスでのSAML 2.0認証の設定
  • ユーザーが​forms-associates グループに属していることを確認します
  • セッションのタイムアウト設定を確認する

CORS エラー

問題: コンソールでクロスオリジン リソース共有エラーが発生しました。

解決策:

  • 開発用:'*'をpostMessageのターゲットオリジンとして使用します
  • 実稼動用:アプリケーションのオリジン URLを正確に指定します
  • パブリッシュインスタンス CORS設定でアプリケーションドメインが許可されていることを確認します

関連トピック

自動翻訳
言語セレクターを使用して、このページの英語版を表示します。
翻訳は役に立ちましたか?

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.