banner 728x90

Verify as a service account using the Blackberry workspaces Java SDK

banner 728x90

1x1.trans - Verify as a service account using the Blackberry workspaces Java SDK

BlackBerry offers multiple SDKs that allow you to integrate with BlackBerry Workspaces. The functionality of these SDKs is similar, so you can choose which one best suits the platform for which you are developing. You can choose whether to call BlackBerry Workspaces REST APIs directly from your app or to use the BlackBerry Workspaces Java SDK, BlackBerry Workspaces .NET SDK, or BlackBerry Workspaces Android SDK. This blog post focuses on the BlackBerry Workspaces Java SDK.

A common integration point is an automated system that uses BlackBerry Workspaces to securely store and share files. The first action that an application must perform is authentication. With a service account, the application can be authenticated with public and private keys without user interaction and is ideal for this type of application. Let's see how we can build it.

Make the keys

The Java Workers Java SDK developer's guide contains a section to help us get started on configuring the service account that our application will use. The first step is to create a public and private key. The public key is configured in BlackBerry Workspaces and private key used by our application. The developer manual contains instructions for creating these keys using OpenSSL and the Java Keytool. Let's make one with OpenSSL. In the example below is the name of the file in which the private key is stored. represents the name of the file where the certificate will be stored.

 openssl req -newkey rsa: 2048 nodes-key  -x509-out 

Re-open OpenSSL to display the public key.

 openssl rsa -in  -pubout 

Create the service account

Now that our keys have been made, we are ready to create a service account. If you do not see the options described below, contact your Workspaces administrator to set it up for you. You must use a Workspaces account with the "Organizer" or "Super Administrator" role to add a service account.

Log in to BlackBerry Workspaces as an administrator, click the gear icon in the upper right corner and choose "Admin Console". Find and click on "Service accounts" in the menu on the left and click on the + to add a new service account and enter the following information:

  1. Stick in the public key and make sure that the "BEGIN PUBLIC KEY" and "END PUBLIC KEY" rules are excluded.
  2. Enter the email address of the account to be configured as a system account in the "System Accounts" field.
  3. Select RSA as the algorithm.
  4. Click Add.

Once completed, your account should look something like the following screenshot. Note the issuer ID marked in the red box. This ID is used in our Java application.

1x1.trans - Verify as a service account using the Blackberry workspaces Java SDK

Convert the private key to PKCS8

The PEM format of the private key created in the previous section is not well supported in Java applications. We can use another OpenSSL command to convert the private key to PKCS8 format for use in our Java application. In the following command IN_FILENAME refers to the private key created in the previous step and OUT_FILENAME the file name of the personal PKCS8 key that is created.

 openssl pkcs8 -topk8 -inform PEM -outform DER-in  -out  -nocrypt 

Read the private key in Java

At this point we have completed the configuration steps and are ready to move to a number of Java encodings. The first method we have to make is one that reads the private key that will be used to authenticate with the server. This is stored in the PrivateKey class that is used by the BlackBerry Workspace's APIs.

  private  PrivateKey readKey ()


Log in

We are now ready to use the Java Workspaces Java APIs to log in to BlackBerry Workspaces. The first class to use is APISession:

 APISession apiSession =  new  APISession ("", "workspaces"); 

The APISession constructor requires the URL of your BlackBerry Workspaces server and subdomain. The subdomain is the first part of the URL, these are & # 39; workspaces & # 39; in the example above. We now use apiSession to try to log in:

 Enums.LoginResult result = apiSession.startSessionWithServiceAccount (  EMAIL_ACCOUNT  ,

"com.watchdox.system.431d.2", 10, key, "SHA256withRSA"); 

EMAIL_ACCOUNT is the email address of the service account user we created earlier and the "com.watchdox.system.431d.2" is the publisher. Both values ​​can be referenced through the screenshot above (in the "Creating the service account" section) that the new service account showed in the BlackBerry Workspaces Admin console. You must replace the sample values ​​with the values ​​of your server.

The third parameter – 10 – refers to the time-out value for this session. The next parameter "key" is the private key that is returned by the readKey () method above. SHA256withRSA is the encryption method for private keys.

The startSessionWithServiceAccount method returns the result of our login attempt. Verify that the login is successful and the application is now ready to communicate with BlackBerry Workspaces.

  if  (result == Enums.LoginResult.   Success  )

Listing workspaces

The SDK comes with sample method implementations for many API calls. The code below uses this to display the available workspaces (previously known as rooms).

  if  (result == Enums.LoginResult.   Success  )


You should now have a Java application that can connect to BlackBerry Workspaces by using a service account and listing all available workspaces. For easy reuse, a full copy of the application is included below.

  package  com.blackberry.workspaces.api.sdk.examples;

 import  java.nio.file.Files;

 import  java.nio.file.Paths;




 import  java.util.Iterator;

 import  java.util.List;

 import  com.blackberry.workspaces.api.sdk.APISession;

 import  com.blackberry.workspaces.api.sdk.Enums;

 import  com.blackberry.workspaces.api.sdk.json.ItemListJson;

 import  com.blackberry.workspaces.api.sdk.json.WorkspaceInfoJson;

 public   class  MarksSample {

 private   static   final  Strijker   EMAIL_ACCOUNT   = "";

 private   static   final  Strijker   PRIVATE_KEY_PATH   = "path_to_your_key";

 public   static   void  main (String [] args) 

 public  MarksSample ()

 private  PrivateKey readKey ()

banner 728x90
    Resetting of file changes with git
    Resetting of file changes with git
    There are many different philosophies when it
    DDoS protection by Incapsula (sponsored)
    DDoS protection by Incapsula (sponsored)
    DDoS security is an incredibly important protection
    Long e-mail discussions: Be Gone !!
    Long e-mail discussions: Be Gone !!
    We've all been working on those long
    Changes to permissions for AWS Mobile Hub
    Changes to permissions for AWS Mobile Hub
    Until recently, when you first created an

    Leave a reply "Verify as a service account using the Blackberry workspaces Java SDK"

    Must read×