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

Newer Version Available

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

ConnectedAppPlugin クラス

接続アプリケーションの動作を拡張します。このクラスによって、Salesforce と接続アプリケーション間のインタラクションの制御を強化できます。使用するプロトコルに応じて接続アプリケーションが呼び出される方法をカスタマイズできます。Salesforce ID プロバイダによって生成される SAML XML をインターセプトし、カスタムコードを追加してから対象のサービスプロバイダに渡すことができます。

名前空間

Auth

使用方法

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

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

非推奨。代わりに 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)

非推奨。代わりに 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)

非推奨。代わりに 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