0 Star 0 Fork 0

Allen / scim-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

scim-server

scim-server scim-server License

1、介绍

基于 Captain-P-Goldfish/SCIM-SDK 的 Spring 版本。

2、Spring Boot 环境使用说明

<dependency>
  <groupId>com.hotlcc.scim.server</groupId>
  <artifactId>scim-server-spring-boot-starter</artifactId>
  <version>${scim-server.version}</version>
</dependency>

2.1、创建“资源类型”JSON定义

参考 How to use the server implementation 中第1点。

2.2、创建“资源Schema”JSON定义

参考 How to use the server implementation 中第2点。

2.3、创建“BaseResourceNode”实现

类似 How to use the server implementation 中第4点。

示例:

public class PersonResourceNode extends BaseResourceNode {
    private final static String SCHEMA = "urn:hotlcc:params:scim:schemas:demo:2.0:Person";

    public PersonResourceNode() {
        setSchemas(Collections.singleton(SCHEMA));
    }

    public String getPersonCode() {
        return getStringAttribute(FieldNames.PERSON_CODE).orElse(null);
    }

    public void setPersonCode(String personCode) {
        setAttribute(FieldNames.PERSON_CODE, personCode);
    }

    public String getPersonName() {
        return getStringAttribute(FieldNames.PERSON_NAME).orElse(null);
    }

    public void setPersonName(String personName) {
        setAttribute(FieldNames.PERSON_NAME, personName);
    }

    private interface FieldNames {
        String PERSON_CODE = "personCode";
        String PERSON_NAME = "personName";
    }
}

2.4、创建“BaseResourceHandler”实现

类似 How to use the server implementation 中第5点。

示例:

@EndpointDefinition(
    resourceTypePath = "classpath:scim/person-resource-type.json",
    resourceSchemaPath = "classpath:scim/person-resource-schema.json"
)
@Component
public class PersonResourceHandler extends BaseResourceHandler<PersonResourceNode> {
    /**
     * demo
     */
    private PersonResourceNode buildPersonResourceNode() {
        PersonResourceNode resourceNode = new PersonResourceNode();
        resourceNode.setPersonCode("test");
        resourceNode.setPersonName("张三");
        return resourceNode;
    }

    @Override
    public PersonResourceNode createResource(PersonResourceNode resource, Context context) {
        System.out.println("createResource");
        return buildPersonResourceNode();
    }

    @Override
    public PersonResourceNode getResource(String id, List<SchemaAttribute> attributes, List<SchemaAttribute> excludedAttributes, Context context) {
        System.out.println("getResource");
        return buildPersonResourceNode();
    }

    @Override
    public PartialListResponse<PersonResourceNode> listResources(long startIndex, int count, FilterNode filter, SchemaAttribute sortBy, SortOrder sortOrder, List<SchemaAttribute> attributes, List<SchemaAttribute> excludedAttributes, Context context) {
        System.out.println("listResources");
        List<PersonResourceNode> list = Collections.singletonList(buildPersonResourceNode());
        PartialListResponse.PartialListResponseBuilder<PersonResourceNode> builder = PartialListResponse.builder();
        return builder.resources(Collections.singletonList(buildPersonResourceNode())).totalResults(1).build();
    }

    @Override
    public PersonResourceNode updateResource(PersonResourceNode resourceToUpdate, Context context) {
        System.out.println("updateResource");
        return buildPersonResourceNode();
    }

    @Override
    public void deleteResource(String id, Context context) {
        System.out.println("deleteResource");
    }
}

2.5、创建“BasicValidator”实现

如果不需要 Basic 认证可以忽略此步骤。

示例:

@Component
public class SimpleBasicValidator implements BasicValidator {
    @Override
    public boolean validate(String username, String password) {
        return StrUtil.equals(username, "test")
            && StrUtil.equals(password, "123456");
    }
}

2.6、配置“application.yml”

配置项参考:ScimServerProperties

3、Spring 环境使用说明

<dependency>
  <groupId>com.hotlcc.scim.server</groupId>
  <artifactId>scim-server-spring</artifactId>
  <version>${scim-server.version}</version>
</dependency>

Bean 配置参考 ScimServerAutoConfig

BSD 3-Clause License Copyright (c) 2024, Allen All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

基于 Captain-P-Goldfish/SCIM-SDK 的 Spring 版本。 展开 收起
Java
BSD-3-Clause
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/hotlcc/scim-server.git
git@gitee.com:hotlcc/scim-server.git
hotlcc
scim-server
scim-server
master

搜索帮助