Newer Version Available
ConnectedAppPlugin クラス
名前空間
使用方法
このクラスは、接続アプリケーションの現在のユーザに代わって実行されます。プラグインが動作するには、このユーザに接続アプリケーションの使用権限が必要です。
例
次の例では、指定された目標に達した場合に接続アプリケーションを使用する権限をユーザに付与し、ユーザの権限セット割り当てを返します。
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
6 User u = [select id, HasAchievedQuota__c from User where id =: userId].get(0);
7 return u.HasAchievedQuota__c;
8
9 }
10
11 //Call a flow during refresh
12 global override void refresh(Id userId, Id connectedAppId) {
13
14 {
15 Map<String, Object> inputVariables = new Map<String, Object>();
16 inputVariables.put('userId', userId);
17 inputVariables.put('connectedAppId', connectedAppId);
18 Flow.Interview.MyCustomFlow interview = new Flow.Interview.MyCustomFlow(inputVariables);
19 interview.start();
20 } catch ( Exception e ) {
21 System.debug('FLOW Exception:' + e);
22 }
23
24 }
25
26 //Return a user’s permission set assignments
27 global override Map<String,String> customAttributes(Id userId, Map<String,String> formulaDefinedAttributes) {
28
29 List<PermissionSetAssignment> psas = [SELECT id, PermissionSet.Name FROM PermissionSetAssignment WHERE PermissionSet.IsOwnedByProfile = false AND (AssigneeId = :userId)];
30 String permsets = '[';
31 for (PermissionSetAssignment psa :psas){
32 permsets += psa.PermissionSet.Name + ';';
33 }
34 permsets += ']';
35 formulaDefinedAttributes.put('PermissionSets', permsets);
36 return formulaDefinedAttributes;
37
38 }
39
40}ConnectedAppPlugin メソッド
ConnectedAppPlugin のメソッドは次のとおりです。
authorize(userId, connectedAppId, isAdminApproved)
署名
public Boolean authorize(Id userId, Id connectedAppId, Boolean isAdminApproved)
パラメータ
使用方法
ユーザが自己承認するように接続アプリケーションが設定されている場合、このコールは不要です。
customAttributes(userId, formulaDefinedAttributes)
指定したユーザに新しい属性を設定します。接続アプリケーションが UserInfo エンドポイントから、または SAML アサーションを使用してユーザの属性を取得する場合は、このメソッドを使用してこれらの属性値を更新します。
署名
public Map<String,String> customAttributes(Id userId, Map<String,String> formulaDefinedAttributes)
パラメータ
- userId
- 型: Id
- 属性に関連付けられたユーザの 15 文字の ID。
- formulaDefinedAttributes
- 型: Map<String, String>
- UserInfo エンドポイント (OAuth) から、または SAML アサーションからの現在の属性セットの対応付け。詳細は、オンラインヘルプの「UserInfo エンドポイント」を参照してください。