<div dir="ltr">We have something working here, we&#39;re about to start using it, although it still isn&#39;t finished, <div><br></div><div>I had some conversations with my superior, and he asked me to do some alterations, and as soon as we have it tested better, I&#39;ll request him to make the github repo public. I would really like to be able to contribute to Keycloak with this, so please let me know of any alterations you see fit as soon as you can see the code.</div>
<div><br></div><div>But just so you can have a better feel (and maybe suggest something), this is an example of usage:</div><div><br></div><div><div><font face="courier new, monospace">Keycloak keycloak = Keycloak.getInstance(SERVER_URL, REALM, USERNAME, PASSWORD, CLIENT_ID, CLIENT_SECRET);</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">// Create a new user</font></div><div><font face="courier new, monospace">UserRepresentation stian = new UserRepresentation();</font></div>
<div><font face="courier new, monospace">stian.setUsername(&quot;stian&quot;);</font></div><div><font face="courier new, monospace">keycloak.userService().create(stian);</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">// Grant roles to user</font></div><div><font face="courier new, monospace">keycloak.userService().grantRoles(&quot;stian&quot;, roles);</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">// Find  all users</font></div><div><font face="courier new, monospace">List&lt;UserRepresentation&gt; users = keycloak.userService().findAll();</font></div></div><div>
<font face="courier new, monospace"><br></font></div><div>My superior thought it was confusing to extend the representation, because some methods would only alter the values in the class, while others would actually access the REST API, so he suggested that we do it like the examples above.<font face="courier new, monospace"><br>
</font></div><div><br></div><div>Any thoughts?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 3, 2014 at 5:36 AM, Stian Thorgersen <span dir="ltr">&lt;<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">How are you getting along with this?<br>
<br>
BTW Don&#39;t use the model API as I suggested, that&#39;s an internal API so wouldn&#39;t make much sense. Extending the *Representation classes sounds like a good option.<br>
<div class="HOEnZb"><div class="h5"><br>
----- Original Message -----<br>
&gt; From: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; To: &quot;Rodrigo Sasaki&quot; &lt;<a href="mailto:rodrigopsasaki@gmail.com">rodrigopsasaki@gmail.com</a>&gt;<br>
&gt; Cc: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; Sent: Monday, 23 June, 2014 9:42:44 AM<br>
&gt; Subject: Re: [keycloak-user] Java Keycloak REST API Wrapper<br>
&gt;<br>
&gt; That&#39;s great! Absolutely something we want. Once it&#39;s in a usable state I&#39;d<br>
&gt; like to pull it in to our main Keycloak repo and include it as part of our<br>
&gt; build and release.<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; &gt; From: &quot;Rodrigo Sasaki&quot; &lt;<a href="mailto:rodrigopsasaki@gmail.com">rodrigopsasaki@gmail.com</a>&gt;<br>
&gt; &gt; To: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; Sent: Friday, 20 June, 2014 9:00:57 PM<br>
&gt; &gt; Subject: [keycloak-user] Java Keycloak REST API Wrapper<br>
&gt; &gt;<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; I&#39;m working on a Java-based wrapper for the REST API, to make it look more<br>
&gt; &gt; OO, abstracting the access to servers.<br>
&gt; &gt;<br>
&gt; &gt; It uses methods such as<br>
&gt; &gt;<br>
&gt; &gt; User bill = realm.getUser(&quot;bburke&quot;)<br>
&gt; &gt; List&lt;RoleRepresentation&gt; roles =<br>
&gt; &gt; bill.getApplicationRoleMappings(&quot;customer-portal&quot;);<br>
&gt; &gt;<br>
&gt; &gt; It&#39;s still in it&#39;s early stages, but if you find it interesting, I&#39;d be<br>
&gt; &gt; happy<br>
&gt; &gt; to create a repo for other Java users to use it, and adapt it based on<br>
&gt; &gt; suggestions aswell.<br>
&gt; &gt;<br>
&gt; &gt; Best regards,<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Rodrigo Sasaki<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; keycloak-user mailing list<br>
&gt; &gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt; _______________________________________________<br>
&gt; keycloak-user mailing list<br>
&gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font face="Times New Roman">Rodrigo Sasaki</font><div></div></div>
</div>