Crowd 2.0 : Creating a Crowd Client using Crowd Integration Libraries
This page last changed on Feb 15, 2009 by smaddox.
Crowd ships with Java integration libraries that allow you to create a Crowd client (also known as a Crowd-connected application) with minimal effort. This page gives a small demo of a stand-alone Crowd client to help you get started with using these libraries.
For further help and questions on Crowd development support, please post to our Crowd Development forum. On this page: Creating a Crowd Client using Crowd Integration LibrariesCreate an Application in Crowd Console for your ClientIf you do not yet have an application defined in Crowd, go ahead and create one via the Crowd Administration Console under 'Applications'.
Prepare your Crowd ClientCopy the files from your Crowd installation folder CROWD_INSTALL/client for your project. These are the contents from a Crowd 1.6 installation: - crowd-integration-client-X.X.jar (Crowd Integration Library) + lib (libraries you will need to include in your CLASSPATH) + conf -- crowd.properties (Settings for defining where your Crowd Server is, and what the Application you're trying to connect to is) -- crowd-ehcache.xml (Settings for Crowd Client cache) Modify your local copy of crowd.properties such that crowd.server.url, application.name and application.password match the URL of your Crowd server and the application name and password you just defined. Sample Codeimport com.atlassian.crowd.integration.service.soap.client.SecurityServerClientFactory; import com.atlassian.crowd.integration.service.soap.client.SecurityServerClient; import com.atlassian.crowd.integration.authentication.PasswordCredential; import com.atlassian.crowd.integration.soap.SOAPPrincipal; import com.atlassian.crowd.integration.soap.SOAPAttribute; import com.atlassian.crowd.integration.model.RemotePrincipalConstants; public class CrowdClientDemo { public static void main(String[] argv) { SecurityServerClient crowdClient = SecurityServerClientFactory.getSecurityServerClient(); try { crowdClient.authenticate(); SOAPPrincipal principal = new SOAPPrincipal("test-user"); principal.setActive(true); principal.setAttributes(new SOAPAttribute[]{ new SOAPAttribute(RemotePrincipalConstants.EMAIL, "test@example.com"), new SOAPAttribute("givenName","Paul"), new SOAPAttribute("sn","Smith") }); PasswordCredential pwd = new PasswordCredential("secret"); crowdClient.addPrincipal(principal,pwd); } catch (Exception e) { System.err.println(e.toString()); } } } Hints
Creating a Crowd Client using AXIS 1.xIf you prefer not to use the Crowd integration libraries and want to interface via the SOAP service directly, that can be done as well. In fact, the Crowd integration libraries actually use SOAP to communicate to the Crowd Server. One practical reason why you may want to interface via SOAP directly is to avoid the possibility of updating the Crowd Client libraries if they change in the future. Please see the example in the Axis 1.x client stub generation guide that performs the same function as the above example. RELATED TOPICSJava Integration Libraries |
![]() |
Document generated by Confluence on Jul 30, 2009 01:30 |