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

ConnectedAppPlugin クラス

接続アプリケーションの動作を拡張するためのメソッドが含まれます。たとえば、使用するプロトコルに応じて接続アプリケーションの呼び出し方法をカスタマイズします。このクラスによって、Salesforce と接続アプリケーション間のインタラクションの制御を強化できます。

名前空間

Auth

使用方法

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

この例では、コンテキストが 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)

廃止済みであり、API バージョン 35.0 および 36.0 でのみ使用できます。バージョン 37.0 以降は、代わりに authorize(userId, connectedAppId, isAdminApproved, context) を使用します。

署名

public Boolean authorize(Id userId, Id connectedAppId, Boolean isAdminApproved)

パラメータ

userId
型: Id
接続アプリケーションの使用を試みているユーザの 15 文字の ID。
connectedAppId
型: String
接続アプリケーションの 15 文字の ID。
isAdminApproved
型: Boolean
接続アプリケーションで承認が必要な場合の指定されたユーザの承認状態。

戻り値

型: Boolean

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

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
接続アプリケーションが呼び出されるコンテキスト。

戻り値

型: Boolean

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

customAttributes(userId, connectedAppId, formulaDefinedAttributes)

廃止済みであり、API バージョン 35.0 および 36.0 でのみ使用できます。バージョン 37.0 以降は、代わりに customAttributes(userId, connectedAppId, formulaDefinedAttributes, context) を使用します。

署名

public Map<String,String> customAttributes(Id userId, Id connectedAppId, Map<String,String> formulaDefinedAttributes,)

パラメータ

userId
型: Id
接続アプリケーションの使用を試みているユーザの 15 文字の ID。
connectedAppId
型: Id
接続アプリケーションの 15 文字の ID。
formulaDefinedAttributes
型: Map<String, String>
UserInfo エンドポイント (OAuth) から、または SAML アサーションからの新しい属性セットの対応付け。詳細は、オンラインヘルプの「UserInfo エンドポイント」を参照してください。

戻り値

型: Map<String, String>

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

customAttributes(userId, connectedAppId, formulaDefinedAttributes, context)

指定したユーザに新しい属性を設定します。接続アプリケーションが UserInfo エンドポイントから、または SAML アサーションを使用してユーザの属性を取得する場合は、このメソッドを使用して属性値を更新します。

署名

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
接続アプリケーションが呼び出されるコンテキスト。

戻り値

型: Map<String, String>

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

modifySAMLResponse(authSession, connectedAppId, samlResponse)

Salesforce SAML ID プロバイダ (IDP) によって生成された XML を、サービスプロバイダに送信される前に変更します。

署名

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 応答が含まれます。

戻り値

型: Dom.XmlNode

変更された SAML XML 応答が含まれる Dom.XmlNode のインスタンスを返します。

使用方法

このメソッドを使用して XML SAML 応答を変更し、検証、署名、および対象サービスプロバイダへの送信前に SAML 要求のコンテキストに基づいてアクションを実行できます。このメソッドにより、開発者は特定のニーズに合わせて接続アプリケーションプラグインを拡張できます。

開発者は、接続アプリケーションプラグイン内で行われる変更の全責任を負います。プラグインには、検証とエラー処理を含める必要があります。プラグインで例外が発生したら、キャッチしてログに記録し、プロセスを停止します。対象サービスプロバイダには何も送信しないでください。

refresh(userId, connectedAppId)

廃止済みであり、API バージョン 35.0 および 36.0 でのみ使用できます。バージョン 37.0 以降は、代わりに refresh(userId, connectedAppId, context) を使用します。

署名

public void refresh(Id userId, Id connectedAppId)

パラメータ

userId
型: Id
更新トークンを要求しているユーザの 15 文字の ID。
connectedAppId
型: Id
接続アプリケーションの 15 文字の ID。

戻り値

型: void

refresh(userId, connectedAppId, context)

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

署名

public void refresh(Id userId, Id connectedAppId, Auth.InvocationContext context)

パラメータ

userId
型: Id
更新トークンを要求しているユーザの 15 文字の ID。
connectedAppId
型: Id
接続アプリケーションの 15 文字の ID。
context
型: InvocationContext
接続アプリケーションが呼び出されるコンテキスト。

戻り値

型: void