Java SDK

Summary

In this topic you will get an overview how to use the Java SDK to connect to The Identity Hub.

Contents

  • Installing the Java SDK
  • Configuring the Java SDK
  • Initialization in application
  • Authenticate
  • Getting Profile Information
  • Getting information on the current user roles
  • Getting information on the current user's friends
  • Getting information on the current user's accounts

Installing the SDK

  • Navigate to the detail page of the App.

  • Open the Java Apps section by clicking on the arrow.

  • Click the SDK link to download the SDK for the App.

  • To integrate the com.theidentityhub with your Java Project in Eclipse extract it into your workspace folder and import it in Eclipse (File | Import… | General | Existing Projects into Workspace | Select root directory: [FOLDER WHERE YOU HAVE EXTRACTED] | Finish).

  • After you have imported Project Explorer will show imported project under the name TheIdentityHubLibrary. Make sure you keep open TheIdentityHubLibrary.

  • To start using TheIdentityHubLibrary in your Java Application project you have to modify properties in your Java Application project. Select your Android Application project in Project Explorer. Open the properties (File | Properties). On the left tree select Android. In the right panel in a Library frame click Add… Select TheIdentityHubLibrary project and then click OK. Click OK the Properties dialog. Your Java Application project is ready to use TheIdentityHubLibrary.

Initialize the Identity Service

A demo application is available on the App detail page in the “Java Apps” section.

Inside the activity in some of your event triggered methods set configuration parameters:

// Your ClientId
String CLIENT_ID = "[ClientId]";
// Your base URL
String BASE_URL = "https://www.theidentityhub.com/[Tenant URL segment]";
// Initialize
IdentityService is = new IdentityService (CLIENT_ID, BASE_URL);
        

Authenticate


if (is.tryAuthenticate()) {
    loadData();
}
        

Getting Profile Information


Profile profile = is.getProfile();
            

Getting information on the current user's friends


ArrayList<Friend> friends = is.getFriends();
            

Getting information on the current user's accounts


ArrayList<AccountProvider> accountProviders = is.getAccounts();
            

Getting information on the current user's roles


ArrayList<Role> roles = is.getRoles();
            

Api

com.theidentityhub.model.Account

Represents an account belonging to an identity.

Name Value Description
getAccountId() String Gets the account identifier
getDisplayName() String Gets the display name.
getEmailAddress() String Gets the email address.
getPictureUrl() String Gets the picture URL.

com.theidentityhub.model.AccountProvider

Represents an account provider.

Name Value Description
getAccountProviderId() String Gets the account provider identifier
getAccounts() com.theidentityhub.model.Account[] Gets the accounts.
getDisplayName() String Gets the display name.
getProviderImageUrl() String Gets the provider image URL.

com.theidentityhub.model.Friend

Represents a friend.

Name Value Description
getDisplayName() String Gets the display name of the friend.
getIdentityId() String Gets the identifier of the friend.
getLargePictures() String[] Gets the large pictures of the friend.
getMediumPictures() String[] Gets the medium pictures of the friend.
getSmallPicture() String Gets the first small picture of the friend.
getSmallPictures() String[] Gets the small pictures of the friend.

com.theidentityhub.model.Profile

Represents an identity.

Name Value Description
getDisplayName() String Gets the display name of the identity.
getEmailAddress() String Gets the email address of the identity.
isEmailAddressVerified() Boolean Gets a value indicating whether the email address of the identity has been verified.
getGivenName() String Gets the name of the given of the identity.
getIdentityId() String Gets the identifier of the identity.
getLargePictures() String[] Gets the large pictures of the identity.
getMediumPictures() String[] Gets the medium pictures of the identity.
getPicture() String Gets the primary picture of the identity.
getSmallPictures() String[] Gets the small pictures of the identity.
getSurname() String Gets the surname of the identity.

com.theidentityhub.model.Role

Represents a role.

Name Value Description
getName() String Gets the name of the role.

com.theidentityhub.service.IdentityService

Provides methods to query an identity's profile.

Name Description
IdentityService(String clientId, String baseUrl) Initializes a new instance of the com.theidentityhub.model.IdentityService class
Name Description
getAccounts() Gets the account providers.
getFriends() Gets the friends.
getProfile() Gets the profile.
getRoles() Gets the roles.
signOut() Revokes a token and signs the current user out.