-
Notifications
You must be signed in to change notification settings - Fork 155
Home
The Stormpath Java SDK allows any JVM-based application to easily use the Stormpath cloud Identity Management service for all authentication and access control needs.
When you make SDK method calls, the calls are translated into HTTPS requests to the Stormpath REST+JSON API. The Stormpath Java SDK therefore provides a clean object-oriented paradigm natural to JVM developers and alleviates the need to know how to make REST+JSON requests. Any JVM-based programming language can use the Stormpath Java SDK (e.g. Java, Groovy, Scala, Clojure, Jython, JRuby, etc.)
-
Add the Stormpath Java SDK .jars to your application using Maven, Ant+Ivy, Grails, SBT or whatever maven-compatible tool you prefer:
<dependency> <groupId>com.stormpath.sdk</groupId> <artifactId>stormpath-sdk-api</artifactId> <version>0.3.0</version> </dependency> <dependency> <groupId>com.stormpath.sdk</groupId> <artifactId>stormpath-sdk-httpclient</artifactId> <version>0.3.0</version> <scope>runtime</scope> </dependency>
-
Ensure you have an API Key so your application can communicate with Stormpath. Store your API Key file somewhere secure (readable only by you), for example:
/home/myhomedir/.stormpath/apiKey.properties
This file's contents should contain the following name/value pairs (using your own values of course):
apiKey.id = YOURAPIKEYIDHEREREPLACEME apiKey.secret = YoUrReAlLyLongSecretValueHereReplaceMeWithYourValue
-
Configure your application to create a Stormpath SDK Client instance based on your API Key. The Client instance is your starting point for all operations with the Stormpath service. For example:
import com.stormpath.sdk.client.*; ... String apiKeyFileLocation = System.getProperty("user.home") + "/.stormpath/apiKey.properties"; Client client = new ClientBuilder().setApiKeyFileLocation(location).build();
-
Use the Client instance to interact with your tenant data, such as Applications, Directories, and Accounts:
Tenant tenant = client.getCurrentTenant(); ApplicationList applications = tenant.getApplications(); for (Application application : applications) { System.out.println("Application " + application.getName()); } DirectoryList directories = tenant.getDirectories(); for (Directory directory : directories) { System.out.println("Directory " + directory.getName()); }