![](/img/trans.png)
[英]How create user in wso2 is via scim2 api with external claims&
[英]How to extend user schema using WSO2 charon scim library
我正在使用 Charon 库创建一个 SCIM 服务器。 如何使用 WSO2 charon scim 库扩展用户模式?
您有两个选项可以使用 charon 库来扩展架构。
选项1:
在文件中定义属性定义并使用该文件构建模式。 编写该文件时,配置文件中的最终配置应该是扩展的定义。
示例 java 代码以使用此方法构建架构:
String schemaFilePath = "<absolute path to the schema defined file>";
SCIMUserSchemaExtensionBuilder.getInstance().buildUserSchemaExtension(schemaFilePath);
AttributeSchema extensionSchema = SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema();
// print the attribute URIs in the built schema
extensionSchema.getSubAttributeSchemas().stream().forEach(e->System.out.print(e.getURI() + "\n"));
文件格式: https://github.com/AnuradhaSK/schema-extension/blob/main/src/main/resources/custom-schema
选项 2:
在 charon 中使用 SCIMCustomSchemaExtensionBuilder。
buildUserCustomSchemaExtension
中的 buildUserCustomSchemaExtension 方法样品 java 代码:
SCIMCustomSchemaExtensionBuilder.getInstance().setURI("urn:scim:custom:extended:schemas");
LOG.info("====Attributes of extended schema using custom attributes===");
// Sub attribute of the schema.
Map<String, String> subAttributeProperties = new HashMap<>();
subAttributeProperties.put("attributeURI","urn:scim:custom:extended:schemas:vehicleNo");
subAttributeProperties.put("attributeName","vehicleNo");
subAttributeProperties.put("dataType","string");
subAttributeProperties.put("multiValued","false");
subAttributeProperties.put("description","User's vehicle number");
subAttributeProperties.put("required","false");
subAttributeProperties.put("caseExact","false");
subAttributeProperties.put("mutability","readWrite");
subAttributeProperties.put("returned","default");
subAttributeProperties.put("uniqueness","none");
subAttributeProperties.put("canonicalValues","[]");
SCIMCustomAttribute scimCustomAttribute = new SCIMCustomAttribute();
scimCustomAttribute.setProperties(subAttributeProperties);
// Schema object.
Map<String, String> schemaObjectProperties = new HashMap<>();
schemaObjectProperties.put("attributeURI","urn:scim:custom:extended:schemas");
schemaObjectProperties.put("attributeName","urn:scim:custom:extended:schemas");
schemaObjectProperties.put("dataType","complex");
schemaObjectProperties.put("multiValued","false");
schemaObjectProperties.put("description","Extended custom schema");
schemaObjectProperties.put("required","false");
schemaObjectProperties.put("caseExact","false");
schemaObjectProperties.put("mutability","readWrite");
schemaObjectProperties.put("returned","default");
schemaObjectProperties.put("uniqueness","none");
schemaObjectProperties.put("subAttributes","vehicleNo");
schemaObjectProperties.put("canonicalValues","[]");
SCIMCustomAttribute schemaAttribute = new SCIMCustomAttribute();
schemaAttribute.setProperties(schemaObjectProperties);
List<SCIMCustomAttribute> attributeList = new ArrayList<>();
attributeList.add(scimCustomAttribute);
attributeList.add(schemaAttribute);
AttributeSchema customExtendedSchema = SCIMCustomSchemaExtensionBuilder.getInstance().buildUserCustomSchemaExtension(attributeList);
customExtendedSchema.getSubAttributeSchemas().stream().forEach(e->System.out.print(e.getURI() + "\n"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.