Git Product home page Git Product logo

scim-server's Introduction

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

scim-server's People

Contributors

hotlcc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.