[keycloak-dev] What to do about Java admin client

Stian Thorgersen sthorger at redhat.com
Tue Apr 5 04:19:40 EDT 2016


At least personally I think the admin client needs some TLC. For example
creating a user requires:

        UserRepresentation user = new UserRepresentation();
        user.setUsername("user");

        Response response = keycloak.realm("realm").users().create(user);

        // Retrieve created user id
        String path = response.getLocation().getPath();
        String id = path.substring(path.lastIndexOf('/') + 1);

        // Remember to close the response
        response.close();

        // Set password
        CredentialRepresentation credentials = new
CredentialRepresentation();
        credentials.setType(CredentialRepresentation.PASSWORD);
        credentials.setValue("password");

        keycloak.realm("realm").users().get(id).resetPassword(credentials);

        // Add role
        RoleRepresentation role =
keycloak.realm("realm").roles().get("role").toRepresentation();

keycloak.realm("realm").users().get(id).roles().realmLevel().add(Collections.singletonList(role));

That's pretty rubbish right?

In my opinion a lot of the usability issues is caused by directly exposing
interfaces/proxies from RestEasy Client and it would be much better if we
introduced a wrapper around it.

So my questions are:

1) What do we do with regards to admin client? Do we just wrap what we
have, keep it or create a brand new one from scratch?
2) Is it an issue that we require a specific RestEasy version to use the
admin client? This seems a heavy dependency to me, which could conflict
with other JAX-RS libraries. Using JAX-RS 2 Client would be an improvement
as it should in theory work with any JAX-RS 2 provider.
3) What do we do with current fixes for admin client? Do we merge to master
and 1.9.x or just merge to master?

At least from my POV the answers are:
1) Create wrappers around interfaces/proxies from RestEasy client and not
expose JAX-RS directly through the API as that should be an implementation
detail
2) Use JAX-RS 2 client
3) Merge fixes to both master and 1.9.x (admin client is not supported in
product for now, so it's less risky)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20160405/b4fd6b2a/attachment.html 


More information about the keycloak-dev mailing list