io.keen.client.java
Class ScopedKeys

java.lang.Object
  extended by io.keen.client.java.ScopedKeys

public class ScopedKeys
extends java.lang.Object

ScopedKeys is a utility class for dealing with Keen IO Scoped Keys. You'll probably only ever need the encrypt method. However, for completeness, there's also a decrypt method.

Example usage:

     String apiKey = "YOUR_API_KEY_HERE";

     //Filters to apply to the key
     Map<String, Object> filter = new HashMap<String, Object>();
     List<Map<String, Object>> filters = new ArrayList<Map<String, Object>>();

     //Create and add a filter
     filter.put("property_name", "user_id");
     filter.put("operator", "eq");
     filter.put("property_value", "123");

     filters.add(filter);

     // create the options we'll use
     Map<String, Object> options = new HashMap<String, Object>();
     options.put("allowed_operations", Arrays.asList("write"));
     options.put("filters", filters);

     // do the encryption
     String scopedKey = ScopedKeys.encrypt(apiKey, options);
     
 

Since:
1.0.3

Constructor Summary
ScopedKeys()
           
 
Method Summary
static java.util.Map<java.lang.String,java.lang.Object> decrypt(KeenClient client, java.lang.String apiKey, java.lang.String scopedKey)
          Decrypts the given Keen IO Scoped Key with an API Key and returns the decrypted Scoped Key Options.
static java.util.Map<java.lang.String,java.lang.Object> decrypt(java.lang.String apiKey, java.lang.String scopedKey)
          Decrypts the given Keen IO Scoped Key with an API Key and returns the decrypted Scoped Key Options.
static java.util.Map<java.lang.String,java.lang.Object> decrypt32CharacterKey(KeenClient client, java.lang.String apiKey, java.lang.String scopedKey)
          Decrypts the given Keen IO Scoped Key with an API Key and returns the decrypted Scoped Key Options.
static java.lang.String encrypt(KeenClient client, java.lang.String apiKey, java.util.Map<java.lang.String,java.lang.Object> options)
          Encrypts the given options with a Keen IO API Key and creates a Scoped Key.
static java.lang.String encrypt(java.lang.String apiKey, java.util.Map<java.lang.String,java.lang.Object> options)
          Encrypts the given options with a Keen IO API Key and creates a Scoped Key.
static java.lang.String encrypt32CharacterKey(KeenClient client, java.lang.String apiKey, java.util.Map<java.lang.String,java.lang.Object> options)
          Encrypts the given options with a Keen IO API Key and creates a Scoped Key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScopedKeys

public ScopedKeys()
Method Detail

encrypt

public static java.lang.String encrypt(java.lang.String apiKey,
                                       java.util.Map<java.lang.String,java.lang.Object> options)
                                throws ScopedKeyException
Encrypts the given options with a Keen IO API Key and creates a Scoped Key.

Parameters:
apiKey - Your Keen IO API Key.
options - The options you want to encrypt.
Returns:
A Keen IO Scoped Key.
Throws:
ScopedKeyException - an error occurred while attempting to encrypt a Scoped Key.

encrypt

public static java.lang.String encrypt(KeenClient client,
                                       java.lang.String apiKey,
                                       java.util.Map<java.lang.String,java.lang.Object> options)
                                throws ScopedKeyException
Encrypts the given options with a Keen IO API Key and creates a Scoped Key.

Parameters:
client - The KeenClient to use for JSON handling.
apiKey - Your Keen IO API Key.
options - The options you want to encrypt.
Returns:
A Keen IO Scoped Key.
Throws:
ScopedKeyException - an error occurred while attempting to encrypt a Scoped Key.

encrypt32CharacterKey

public static java.lang.String encrypt32CharacterKey(KeenClient client,
                                                     java.lang.String apiKey,
                                                     java.util.Map<java.lang.String,java.lang.Object> options)
                                              throws ScopedKeyException
Encrypts the given options with a Keen IO API Key and creates a Scoped Key.

Parameters:
client - The KeenClient to use for JSON handling.
apiKey - Your Keen IO API Key.
options - The options you want to encrypt.
Returns:
A Keen IO Scoped Key.
Throws:
ScopedKeyException - an error occurred while attempting to encrypt a Scoped Key.

decrypt

public static java.util.Map<java.lang.String,java.lang.Object> decrypt(java.lang.String apiKey,
                                                                       java.lang.String scopedKey)
                                                                throws ScopedKeyException
Decrypts the given Keen IO Scoped Key with an API Key and returns the decrypted Scoped Key Options.

Parameters:
apiKey - Your Keen IO API Key.
scopedKey - The Scoped Key you want to decrypt.
Returns:
The decrypted Scoped Key Options.
Throws:
ScopedKeyException - an error occurred while attempting to decrypt a Scoped Key.

decrypt

public static java.util.Map<java.lang.String,java.lang.Object> decrypt(KeenClient client,
                                                                       java.lang.String apiKey,
                                                                       java.lang.String scopedKey)
                                                                throws ScopedKeyException
Decrypts the given Keen IO Scoped Key with an API Key and returns the decrypted Scoped Key Options.

Parameters:
client - The KeenClient to use for JSON handling.
apiKey - Your Keen IO API Key.
scopedKey - The Scoped Key you want to decrypt.
Returns:
The decrypted Scoped Key Options.
Throws:
ScopedKeyException - an error occurred while attempting to decrypt a Scoped Key.

decrypt32CharacterKey

public static java.util.Map<java.lang.String,java.lang.Object> decrypt32CharacterKey(KeenClient client,
                                                                                     java.lang.String apiKey,
                                                                                     java.lang.String scopedKey)
                                                                              throws ScopedKeyException
Decrypts the given Keen IO Scoped Key with an API Key and returns the decrypted Scoped Key Options.

Parameters:
client - The KeenClient to use for JSON handling.
apiKey - Your Keen IO API Key.
scopedKey - The Scoped Key you want to decrypt.
Returns:
The decrypted Scoped Key Options.
Throws:
ScopedKeyException - an error occurred while attempting to decrypt a Scoped Key.