Newer Version Available
ConnectedAppPlugin クラス
名前空間
使用方法
このクラスは、接続アプリケーションの現在のユーザに代わって実行されます。プラグインが動作するには、このユ���ザに接続アプリケーションの使用権限が必要です。
例
この例では、コンテキストが SAML でユーザがカスタム項目で追跡される目標に達した場合、接続アプリケーションを使用する権限をユーザに付与します。ユーザの権限セットの割り当てが返されます。InvocationContext を使用して、サービスプロバイダに送信される前に SAML アサーションを変更します。
1@TestConnectedAppPluginClass
2 global class ConnectedAppPluginExample extends Auth.ConnectedAppPlugin{
3
4 //Authorize the app if the user has achieved quota tracked in a custom field
5 global override boolean authorize(Id userId, Id connectedAppId, boolean isAdminApproved) {
6
7 User u = [select id, HasAchievedQuota__c from User where id =: userId].get(0);
8 return u.HasAchievedQuota__c;
9
10 }
11
12 //Call a flow during refresh
13 global override void refresh(Id userId, Id connectedAppId) {
14
15 {
16 Map<String, Object> inputVariables = new Map<String, Object>();
17 inputVariables.put('userId', userId);
18 inputVariables.put('connectedAppId', connectedAppId);
19 Flow.Interview.MyCustomFlow interview = new Flow.Interview.MyCustomFlow(inputVariables);
20 interview.start();
21 } catch ( Exception e ) {
22 System.debug('FLOW Exception:' + e);
23 }
24
25 }
26
27 //Return a user’s permission set assignments
28 global override Map<String,String> customAttributes(Id userId, Map<String,String> formulaDefinedAttributes)
29 {
30 List<PermissionSetAssignment> psas = [SELECT id, PermissionSet.Name FROM PermissionSetAssignment WHERE PermissionSet.IsOwnedByProfile = false AND (AssigneeId = :userId)];
31 String permsets = '[';
32 for (PermissionSetAssignment psa :psas)
33 {
34 permsets += psa.PermissionSet.Name + ';';
35 }
36 permsets += ']';
37 formulaDefinedAttributes.put('PermissionSets', permsets);
38 return formulaDefinedAttributes;
39
40 }
41
42 }ConnectedAppPlugin メソッド
ConnectedAppPlugin のメソッドは次のとおりです。
authorize(userId, connectedAppId, isAdminApproved)
署名
public Boolean authorize(Id userId, Id connectedAppId, Boolean 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)
署名
public Map<String,String> customAttributes(Id userId, Id connectedAppId, Map<String,String> 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