ConnectedAppPlugin クラス
名前空間
使用方法
このクラスは、接続アプリケーションの現在のユーザに代わって実行されます。プラグインが動作するには、このユーザに接続アプリケーションの使用権限が必要です。
例
この例では、コンテキストが SAML でユーザがカスタム項目で追跡される目標に達した場合、接続アプリケーションを使用する権限をユーザに付与します。ユーザの権限セットの割り当てが返されます。InvocationContext を使用して、サービスプロバイダに送信される前に SAML アサーションを変更します。
1global class ConnectedAppPluginExample extends Auth.ConnectedAppPlugin{
2
3 // Authorize the app if the user has achieved quota tracked in a custom field
4 global override boolean authorize(Id userId, Id connectedAppId, boolean isAdminApproved) {
5 // Create a custom boolean field HasAchievedQuota__c on the user record
6 // and then uncomment the block below
7
8 // User u = [select id, HasAchievedQuota__c from User where id =: userId].get(0);
9 // return u.HasAchievedQuota__c;
10
11 return isAdminApproved;
12 }
13
14 // Call a flow during refresh
15 global override void refresh(Id userId, Id connectedAppId) {
16 try
17 {
18 Map<String, Object> inputVariables = new Map<String, Object>();
19 inputVariables.put('userId', userId);
20 inputVariables.put('connectedAppId', connectedAppId);
21
22 // Create a custom trigger ready flow and uncomment the block below
23 // Flow.Interview.MyCustomFlow interview = new Flow.Interview.MyCustomFlow(inputVariables);
24 // interview.start();
25 } catch ( Exception e ) {
26 System.debug('FLOW Exception:' + e);
27 }
28
29 }
30
31 // Return a user’s permission set assignments
32 global override Map<String,String> customAttributes(Id userId, Map<String,String> formulaDefinedAttributes)
33 {
34 List<PermissionSetAssignment> psas = [SELECT id, PermissionSet.Name FROM PermissionSetAssignment
35 WHERE PermissionSet.IsOwnedByProfile = false AND (AssigneeId = :userId)];
36 String permsets = '[';
37 for (PermissionSetAssignment psa :psas)
38 {
39 permsets += psa.PermissionSet.Name + ';';
40 }
41 permsets += ']';
42 formulaDefinedAttributes.put('PermissionSets', permsets);
43 return formulaDefinedAttributes;
44
45 }
46
47 }ConnectedAppPlugin のメソッド
ConnectedAppPlugin のメソッドは次のとおりです。
authorize(userId, connectedAppId, isAdminApproved)
authorize(userId, connectedAppId, isAdminApproved, context)
署名
public Boolean authorize(Id userId, Id connectedAppId, Boolean isAdminApproved, Auth.InvocationContext context)
パラメータ
- userId
- 型: Id
- 接続アプリケーションの使用を試みているユーザの 15 文字の ID。
- connectedAppId
- 型: Id
- 接続アプリケーションの 15 文字の ID。
- isAdminApproved
- 型: Boolean
- 接続アプリケーションで承認が必要な場合の指定されたユーザの承認状態。
- context
- 型: InvocationContext
- 接続アプリケーションが呼び出されるコンテキスト。
customAttributes(userId, connectedAppId, formulaDefinedAttributes)
customAttributes(userId, connectedAppId, formulaDefinedAttributes, context)
署名
public Map<String,String> customAttributes(Id userId, Id connectedAppId, Map<String,String> formulaDefinedAttributes, Auth.InvocationContext context)
パラメータ
- userId
- 型: Id
- 接続アプリケーションの使用を試みているユーザの 15 文字の ID。
- connectedAppId
- 型: Id
- 接続アプリケーションの 15 文字の ID。
- formulaDefinedAttributes
- 型: Map<String, String>
- UserInfo エンドポイント (OAuth) から、または SAML アサーションからの現在の属性セットの対応付け。詳細は、オンラインヘルプの「UserInfo エンドポイント」を参照してください。
- 型: InvocationContext
- 接続アプリケーションが呼び出されるコンテキスト。
modifySAMLResponse(authSession, connectedAppId, samlResponse)
署名
public dom.XmlNode modifySAMLResponse(Map<String,String> authSession, Id connectedAppId, dom.XmlNode samlResponse)
パラメータ
- authSession
- 型: Map<String, String>
- 承認されたユーザのセッションの属性。対応付けには、接続アプリケーションにアクセスしている、承認されたユーザの 15 文字の ID が含まれます。
- connectedAppId
- 型: Id
- 接続アプリケーションの 15 文字の ID。
- samlResponse
- 型: Dom.XmlNode
- IDP によって生成された SAML XML 応答が含まれます。
使用方法
このメソッドを使用して XML SAML 応答を変更し、検証、署名、および対象サービスプロバイダへの送信前に SAML 要求のコンテキストに基づいてアクションを実行できます。このメソッドにより、開発者は特定のニーズに合わせて接続アプリケーションプラグインを拡張できます。
開発者は、接続アプリケーションプラグイン内で行われる変更の全責任を負います。プラグインには、検証とエラー処理を含める必要があります。プラグインで例外が発生したら、キャッチしてログに記録し、プロセスを停止します。対象サービスプロバイダには何も送信しないでください。
refresh(userId, connectedAppId, context)
署名
public void refresh(Id userId, Id connectedAppId, Auth.InvocationContext context)
パラメータ
- userId
- 型: Id
- 更新トークンを要求しているユーザの 15 文字の ID。
- connectedAppId
- 型: Id
- 接続アプリケーションの 15 文字の ID。
- context
- 型: InvocationContext
- 接続アプリケーションが呼び出されるコンテキスト。
戻り値
型: void