この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Newer Version Available

This content describes an older version of this product. View Latest

ConnectedAppPlugin クラス

接続アプリケーションの動作をカスタマイズして、新しい認証プロトコルをサポートしたり、ビジネスプロセスにメリットがある形でユーザ属性に応答したりできます。

名前空間

Auth

使用方法

このクラスは、接続アプリケーションの現在のユーザに代わって実行されます。プラグインが動作するには、このユーザに接続アプリケーションの使用権限が必要です。

次の例では、指定された目標に達した場合に接続アプリケーションを使用する権限をユーザに付与し、ユーザの権限セット割り当てを返します。

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)

パラメータ

userId
型: Id
接続アプリケーションへのアクセス権の付与先となるユーザの 15 文字の ID。
connectedAppId
型: String
接続アプリケーションの 15 文字の ID。
isAdminApproved
型: Boolean
指定されたユーザが接続アプリケーションを使用するための承認状態を示します。

戻り値

型: Boolean

接続アプリケーションでシステム管理者の承認が必要な場合、戻り値 true は現在のユーザが承認されていることを示します。

使用方法

ユーザが自己承認するように接続アプリケーションが設定されている場合、このコールは不要です。

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 エンドポイント」を参照してください。

戻り値

型: Map<String, String>

更新された属性セットの対応付け。

refresh(userId, connectedAppId)

Salesforce は、更新トークンの交換時にこのメソッドをコールします。

署名

public Void refresh(Id userId, Id connectedAppId)

パラメータ

userId
型: Id
更新トークンを取得するユーザの 15 文字の ID。
connectedAppId
型: String
接続アプリケーションの 15 文字の ID。

戻り値

型: Void