许可证 | MIT |
发布最后发布 | 2019年10月 |
由Luis Sanches,Rob Weber,James Go,Britton Katnich,Yasmeen Taj,Syed Yusuf,Syed Yusuf维护。
MAS IdentityManagement 是 iOS 移动 SDK 中的用户和组管理框架,属于 CA 移动 API 网关的一部分。它使开发者能够安全地从企业身份提供者(如 LDAP、MSAD 等)中访问用户和组。支持为协作应用动态创建组(称为临时组)。底层协议是 SCIM。
MASIdentityManagement 框架包含以下特性
欢迎并非常欢迎贡献。欲了解更多信息,请参阅贡献指南。
MASIdentityManagement 支持多种方法在项目中安装图书馆。
要使用 CocoaPods 将 MASIdentityManagement 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
pod 'MASIdentityManagement'
然后,使用项目文件夹中的命令提示符运行以下命令
$ pod install
对于手动安装,您需要将移动 SDK 添加到您的 Xcode 项目中。注意,您必须添加 MASFoundation 库。为了完全使用 MAS 功能,请按照以下方式安装所有 MAS 库。
如有必要,则复制项
选项。文件 -> 将文件添加到 '项目名称'
并将项目文件夹中的 msso_config.json 文件添加到项目中。-ObjC
添加到 其他链接器标志
。#import <MASFoundation/MASFoundation.h>
#import <MASIdentityManagement/MASIdentityManagement.h>
//Retrieve a MASUser object that matches the given userName
[MASUser getUserByUserName:sampleUserName completion:^(MASUser *user, NSError *error) {
//your code here
}];
//Retrieve a MASUser object that matches the given objectId
[MASUser getUserByObjectId:sampleUserObjectId completion:^(MASUser *user, NSError *error) {
//your code here
}];
以下代码示例演示了临时组(动态创建)的基本 CRUD 操作。更高级的操作(使用筛选请求)可以在下一节找到。
MASGroup *newGroup = [MASGroup group]; // create new MASGroup object
newGroup.groupName = @"New group's name"; // set the group name
newGroup.owner = [MASUser currentUser].userName; // set the owner of the group to a current user
[newGroup saveInBackgroundWithCompletion:^(MASGroup *group, NSError *error) {
//your code here
}];
//Retrieve all groups in Identity Management system
[MASGroup getAllGroupsWithCompletion:^(NSArray *groupList, NSError *error, NSUInteger totalResults){
//your code here
}];
//Retrieve an MASGroup object that matches the given displayName
[MASGroup getGroupByGroupName:@"groupName" completion:^(MASGroup *group, NSError *error) {
//your code here
}];
//Retrieve an MASGroup object that matches the given objectId
[MASGroup getGroupByObjectId:@"objectId" completion:^(MASGroup *group, NSError *error) {
//your code here
}];
MASGroup *thisGroup = retrieve the group object to add a member;
MASUser *thisUser = retrieve the user object to be added;
//Add the member to the group
[thisGroup addMember:thisUser completion:^(MASGroup *group, NSError *error) {
//your code here
}];
MASGroup *thisGroup = retrieve the group object to remove a member;
MASUser *thisUser = retrieve the user object to be removed;
//Remove the member from the group
[thisGroup removeMember:thisUser completion:^(MASGroup *group, NSError *error) {
//your code here
}];
MASGroup *thisGroup = retrieve the group to delete;
//Delete the group
[thisGroup deleteInBackgroundWithCompletion:^(BOOL success, NSError *error) {
//your code here
}];
MASFilteredRequest类是一个便捷的请求构建器,旨在使与身份管理系统的交互变得极其简单且无错误。身份管理服务可以使用以下条件集来查询用户和组:
包含/排除
要包含或排除属性,您需要在查询中提供一个属性列表,包含以下任一格式:attributes=[以逗号分隔的属性列表],或excludedAttributes=[以逗号分隔的属性列表]。但是,FilteredRequestBuilder可以为您进行URL格式化。
要从MAS身份管理服务中读取用户,使用
getUsersByFilter.api函数与MASFilteredRequest
//
// Create FilteredRequest
//
MASFilteredRequest *filteredRequest = [MASFilteredRequest filteredRequest];
//
// Create Filter object.
// Set the attribute, 'userName' or 'displayName', and the filter. For example, a filter of 'sm'
// would match all users with the userName such as 'Smith', 'Asmil', 'Smeel',
// or all groups with the displayName such as 'Small', 'Smart group'
// etc.
//
MASFilter *filter = [MASFilter filterByAttribute:@"userName" contains:@"sm"];
filteredRequest.filter = filter;
//
// Set the sortOrder, either descending or ascending.
// sortOrder is an enumeration value with MASFilteredRequestSortOrderDescending or
// MASFilteredRequestSortOrderAscending.
//
filteredRequest.sortOrder = MASFilteredRequestSortOrderDescending;
//
// Set the pagination for the request.
//
filteredRequest.paginationRange = NSMakeRange(0, 10);
通过使用上述FilteredRequest,可以轻松检索与过滤器请求相匹配的用户。还有许多其他检索用户的方法,无需创建带有多个过滤器属性组合的FilteredRequest对象。有关文档的更多详细信息,请参阅iOS参考。
MASFilteredRequest *filteredRequest = filteredRequest object;
//
// Retrieve an array of MASUser objects based on the filterRequest
//
[MASUser getUsersByFilteredRequest:filteredRequest completion:^(NSArray *userList, NSError *error, NSUInteger totalResults) {
if (error)
{
// Handle error case here
}
else {
// Handle successful request here
}
}];
使用上述FilteredRequest可以轻松检索与过滤器请求相匹配的组。还有许多其他检索组的方法,无需创建带有多个过滤器属性组合的FilteredRequest对象。有关文档的更多详细信息,请参阅iOS参考。
MASFilteredRequest *filteredRequest = filteredRequest object;
//
// Retrieve an array of MASGroup objects based on the filterRequest
//
[MASGroup getGroupsByFilteredRequest:filteredRequest completion:^(NSArray *groupList, NSError *error, NSUInteger totalResults) {
if (error)
{
// Handle error case here
}
else {
// Handle successful request here
}
}];
版权(c)2016 CA。保留所有权利。
本软件可以根据以下条款进行修改和分发。
MIT许可证。有关详细信息,请参阅LICENSE文件。