com.slideme.slidelock
Class License

java.lang.Object
  extended by com.slideme.slidelock.License

public final class License
extends java.lang.Object


Nested Class Summary
static class License.Rights
          This class will reflect permissions of a software unit, such as validity, type of license, etc.
 
Constructor Summary
License(java.lang.String uniqueAppIdentifier, Context aContext)
          This is the most comfortable constructor
License(java.lang.String name, java.lang.String uniqueAppIdentifier, Context aContext)
           
License(java.lang.String name, java.lang.String uniqueAppIdentifier, TelephonyManager aTelephonyManager, WifiManager aWifiManager, ContentResolver aContentResolver)
           
License(java.lang.String uniqueAppIdentifier, TelephonyManager aTelephonyManager, WifiManager aWifiManager, ContentResolver aContentResolver)
           
 
Method Summary
 void digest(byte[] license)
          Digests the license and adjusts the rights/permissions.
 void digest(java.io.InputStream license)
          Digests the license and adjusts the rights/permissions.
 byte[] fetch()
          Retrieves the binary license data from SlideME License Server
 void fetch(java.io.OutputStream output)
          Retrieves the license data from SlideME License Server
 java.lang.String getDisplayName()
           
 License.Rights getFullRights()
          Checks if this license grants ultimate rights for all features this application offers
 License.Rights getRights(java.lang.String aFeatureKey)
          Checks if this license grants rights for parameter aFeatureKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

License

public License(java.lang.String name,
               java.lang.String uniqueAppIdentifier,
               Context aContext)
Parameters:
name - you may want to name your license
uniqueAppIdentifier - this is the SlideLock Key
aContext - your application's Context, used to pull the device identifier. This could be an activity or the application context.
Throws:
java.lang.Error - if unable to resolve at least one device unique identifier (wifi or mac or buildId)

License

public License(java.lang.String uniqueAppIdentifier,
               Context aContext)
This is the most comfortable constructor

Parameters:
uniqueAppIdentifier - this is the SlideLock Key
aContext - your application's main Context, used to pull the device identifiers (imei, mac, buildId)
Throws:
java.lang.Error - if unable to resolve at least one device unique identifier (wifi or mac or buildId)

License

public License(java.lang.String name,
               java.lang.String uniqueAppIdentifier,
               TelephonyManager aTelephonyManager,
               WifiManager aWifiManager,
               ContentResolver aContentResolver)
Parameters:
name - you may want to name your license
uniqueAppIdentifier - this is the SlideLock Key
aTelephonyManager - required to pull the device unique identifier
aWifiManager - required to pull the device MAC address
aContentResolver - required to pull the device Build ID
Throws:
java.lang.Error - if unable to resolve at least one device unique identifier (wifi or mac or buildId)

License

public License(java.lang.String uniqueAppIdentifier,
               TelephonyManager aTelephonyManager,
               WifiManager aWifiManager,
               ContentResolver aContentResolver)
Parameters:
uniqueAppIdentifier - this is the SlideLock Key
aTelephonyManager - required to pull the device unique identifier
aWifiManager - required to pull the device MAC address
aContentResolver - required to pull the device Build ID
Throws:
java.lang.Error - if unable to resolve at least one device unique identifier (wifi or mac or buildId)
Method Detail

digest

public void digest(byte[] license)
            throws java.io.IOException,
                   java.lang.IllegalArgumentException
Digests the license and adjusts the rights/permissions. Any right/permission that were active prior to this call will be reset.

Parameters:
license - binary representation of the license
Throws:
java.io.IOException
java.lang.IllegalArgumentException - when parameter license is null or its size is 0
See Also:
digest(java.io.InputStream)

digest

public void digest(java.io.InputStream license)
            throws java.io.IOException,
                   java.lang.IllegalArgumentException
Digests the license and adjusts the rights/permissions. Any right/permission that were active prior to this call will be reset.

Parameters:
license - an input stream containing the binary representation of a SlideME license
Throws:
java.io.IOException - when attempting to read from parameter license throws an IOException
java.lang.IllegalArgumentException - when parameter license is null

fetch

public byte[] fetch()
             throws java.io.IOException
Retrieves the binary license data from SlideME License Server

Returns:
License binary data
Throws:
java.io.IOException - when unable to connect to SlideME License Server. You may want to retry.

fetch

public void fetch(java.io.OutputStream output)
           throws java.io.IOException,
                  java.lang.IllegalArgumentException
Retrieves the license data from SlideME License Server

Parameters:
output - data container
Throws:
java.io.IOException - when unable to connect to SlideME License Server. You may want to retry.
java.lang.IllegalArgumentException - when output stream is null

getDisplayName

public java.lang.String getDisplayName()
Returns:
"Default" if unnamed

getFullRights

public License.Rights getFullRights()
Checks if this license grants ultimate rights for all features this application offers

Returns:
rights details, if there is any; null otherwise
See Also:
License.Rights

getRights

public License.Rights getRights(java.lang.String aFeatureKey)
                         throws java.lang.IllegalArgumentException
Checks if this license grants rights for parameter aFeatureKey

Parameters:
aFeatureKey - an identifier for a feature supported by the licensed application
Returns:
rights details, if there is any; null otherwise
Throws:
java.lang.IllegalArgumentException - when parameter aFeatureKey is null or empty string
See Also:
License.Rights