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

Newer Version Available

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

SamlJitHandler インターフェース

このインターフェースを使用して、SAML シングルサインオン時にジャストインタイムのユーザプロビジョニングロジックの制御とカスタマイズを行います。

名前空間

Auth

使用方法

SAML シングルサインオン時にユーザプロビジョニングのカスタムロジックを使用するには、Auth.SamlJitHandler を実装するクラスを作成する必要があります。これにより、ユーザがシングルサインオンで Salesforce にログインするときに、組織固有のロジック (カスタム項目の自動入力など) を組み込むことができます。クラスは、関連付けられた取引先レコードと取引先責任者レコードを含め、ユーザデータを作成および更新するロジックを必要に応じて実行する必要があります。

Salesforce で、[SAML シングルサインオン設定] の [SAML JIT ハンドラ] 項目にこのインターフェースを実装するクラスを指定します。クラスを実行するよう指定するユーザに「ユーザの管理」権限があることを確認します。

SamlJitHandler メソッド

SamlJitHandler のメソッドは次のとおりです。

createUser(samlSsoProviderId, communityId, portalId, federationId, attributes, assertion)

指定された統合 ID を使用して User オブジェクトを返します。User オブジェクトはユーザ情報に対応し、データベースに挿入されていない新規ユーザまたはデータベース内の既存のユーザを表す可能性があります。

署名

public User createUser(Id samlSsoProviderId, Id communityId, Id portalId, String federationId, Map<String,String> attributes, String assertion)

パラメータ

samlSsoProviderId
型: Id
SamlSsoConfig 標準オブジェクトの ID。
communityId
型: Id
コミュニティの ID。コミュニティユーザを作成しない場合、このパラメータは null にできます。
portalId
型: Id
ポータルの ID。ポータルユーザを作成しない場合、このパラメータは null にできます。
federationId
型: String
このユーザに使用されると Salesforce が想定する ID。
attributes
型: Map<String, String>
SAML アサーションのうち、デフォルトのアサーションに追加された属性すべて (カスタム属性など)。属性では、大文字と小文字が区別されます。
assertion
型: String
Base-64 エンコードされたデフォルトの SAML アサーション。

戻り値

型: User

User sObject。

使用方法

この組織にコミュニティとポータルが設定されていない場合、communityId および portalId パラメータ値は null または空のキーになる可能性があります。

updateUser(userId, samlSsoProviderId, communityId, portalId, federationId, attributes, assertion)

指定のユーザの情報を更新します。ユーザが以前 SAML シングルサインオンを使用してログインしたことがあり、再度ログインする場合、またはアプリケーションが [既存ユーザをリンクする URL] を使用している場合、このメソッドがコールされます。

署名

public void updateUser(Id userId, Id samlSsoProviderId, Id communityId, Id portalId, String federationId, Map<String,String> attributes, String assertion)

パラメータ

userId
型: Id
Salesforce ユーザの ID。
samlSsoProviderId
型: Id
SamlSsoConfig オブジェクトの ID。
communityId
型: Id
コミュニティの ID。コミュニティユーザを更新しない場合、このパラメータは null にできます。
portalId
型: Id
ポータルの ID。ポータルユーザを更新しない場合、このパラメータは null にできます。
federationId
型: String
このユーザに使用されると Salesforce が想定する ID。
attributes
型: Map<String, String>
SAML アサーションのうち、デフォルトのアサーションに追加された属性すべて (カスタム属性など)。属性では、大文字と小文字が区別されます。
assertion
型: String
Base-64 エンコードされたデフォルトの SAML アサーション。

戻り値

型: void

SamlJitHandler の実装例

これは、Auth.SamlJitHandler インターフェースの実装例です。このコードでは、非公開メソッドを使用して取引先と取引先責任者を処理します (handleContact() と handleAccount() は、この例には含まれていません)。

1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17global class StandardUserHandler implements Auth.SamlJitHandler {
18    private class JitException extends Exception{}
19    private void handleUser(boolean create, User u, Map<String, String> attributes,
20        String federationIdentifier, boolean isStandard) {
21        if(create && attributes.containsKey('User.Username')) {
22            u.Username = attributes.get('User.Username');
23        }
24        if(create) {
25            if(attributes.containsKey('User.FederationIdentifier')) {
26                u.FederationIdentifier = attributes.get('User.FederationIdentifier');
27            } else {
28                u.FederationIdentifier = federationIdentifier;
29            }
30        }
31        if(attributes.containsKey('User.ProfileId')) {
32            String profileId = attributes.get('User.ProfileId');
33            Profile p = [SELECT Id FROM Profile WHERE Id=:profileId];
34            u.ProfileId = p.Id;
35        }
36        if(attributes.containsKey('User.UserRoleId')) {
37            String userRole = attributes.get('User.UserRoleId');
38            UserRole r = [SELECT Id FROM UserRole WHERE Id=:userRole];
39            u.UserRoleId = r.Id;
40        }
41        if(attributes.containsKey('User.Phone')) {
42            u.Phone = attributes.get('User.Phone');
43        }
44        if(attributes.containsKey('User.Email')) {
45            u.Email = attributes.get('User.Email');
46        }
47
48	//More attributes here - removed for length
49
50        //Handle custom fields here
51
52        if(!create) {
53            update(u);
54        }
55    }
56
57    private void handleJit(boolean create, User u, Id samlSsoProviderId, Id communityId, Id portalId,
58        String federationIdentifier, Map<String, String> attributes, String assertion) {
59        if(communityId != null || portalId != null) {
60            String account = handleAccount(create, u, attributes);
61            handleContact(create, account, u, attributes);
62            handleUser(create, u, attributes, federationIdentifier, false);
63        } else {
64            handleUser(create, u, attributes, federationIdentifier, true);
65        }
66    }
67
68    global User createUser(Id samlSsoProviderId, Id communityId, Id portalId,
69        String federationIdentifier, Map<String, String> attributes, String assertion) {
70        User u = new User();
71        handleJit(true, u, samlSsoProviderId, communityId, portalId,
72            federationIdentifier, attributes, assertion);
73        return u;
74    }
75
76    global void updateUser(Id userId, Id samlSsoProviderId, Id communityId, Id portalId,
77        String federationIdentifier, Map<String, String> attributes, String assertion) {
78        User u = [SELECT Id FROM User WHERE Id=:userId];
79        handleJit(false, u, samlSsoProviderId, communityId, portalId,
80            federationIdentifier, attributes, assertion);
81    }
82}