Closed coz1 closed 1 month ago
Great question!
This depends on your container. For example if you are building a JAX-RS/Jakarta RESTful Services app, you would need to register your new endpoint (basically add it to the existing list)
And you would need to make sure any components you have created are also available for injection: https://github.com/apache/directory-scimple/blob/2bcacdb6fe6fa885dd4963fd06149f735e64253c/scim-server-examples/scim-server-jersey/src/main/java/org/apache/directory/scim/example/jersey/JerseyApplication.java#L70-L72
If this doesn't help, create a simple example and stick it on GitHub and we can probably provide some more concrete advice!
Hey @bdemers thanks for your answer.
You're right, of course! It's easier for me to understand with a practical example! :) Scimple-CustomResource-Example Repository
Nevertheless, I am a little confused. I have already considered adding my CustomUser to the list via a bean (see code in repo). Unfortunately also without success. But what confuses me is, if you look at RepositoryRegistry from Scim then only the implementer would have to be registered as a repository<..>. Schema, endpoint is all registered. In the debugger the corresponding data is also there, but the ErrorResponse 404 still appears.
public synchronized <T extends ScimResource> void registerRepository(Class<T> clazz, Repository<T> repository) throws InvalidRepositoryException {
List<Class<? extends ScimExtension>> extensionList = repository.getExtensionList();
log.debug("Calling addSchema on the base class: {}", clazz);
schemaRegistry.addSchema(clazz, extensionList); // <--- here
repositoryMap.put(clazz, repository);
}
In addition, if you then look at addSchema() you can also see the registration steps, among other things. Everything looked fine in the debugger.
public <T extends ScimResource> void addSchema(Class<T> clazz, List<Class<? extends ScimExtension>> extensionList) {
....
addSchema(Schemas.schemaFor(clazz));
addScimResourceSchemaUrn(schemaUrn, clazz);
addScimResourceEndPoint(endpoint, clazz);
addResourceType(resourceType);
...
}
Why do you have to add this to the list so complicated if it should actually happen automatically according to the implementation?
Somewhere I have an error in my thinking or am I overlooking something!
Thanks again for your help 🤝
See: https://github.com/coz1/Scimple-CustomResource-Example/pull/1
You were missing the endpoint definition. There are basically two things you need. The model (as you defined), this defines the SCIM schema of your object (and is used the POJO for the related endpoint). And you also need the endpoint itself.
Thinking about this now, in the future SCIMple could probably create the endpoint automatically, as long as you provide the model for the ScimResource
and a Repository<YourScimResource>
(but that depends how common of a use case custom SCIM resources would be) 🤔
Ok! Now I basically understand what is happening. Thanks for your effort, @bdemers
Since I will now be working with scimple for a little longer, there will certainly be one or two PRs from me :)
Stay healthy and best regards from Berlin
Hey, I would like to create my own ScimResource (ScimTest) but not as an extension but next to /Users and Groups.
I have created my new resource but somehow it doesn't find it and throws me the Scim Error Response.
I also created it via the Scim repository.
public ScimTestRepo implements Repository<ScimTest> {...}
Unfortunately without success. How do I register my new resource?