com.microsoft.aad.adal
Class StorageHelper

java.lang.Object
  extended by com.microsoft.aad.adal.StorageHelper

public class StorageHelper
extends Object

Shared preferences store clear text. This class helps to encrypt/decrypt text to store. API SDK >= 18 has more security with AndroidKeyStore.


Field Summary
static int DATA_KEY_LENGTH
          IV Key length for AES-128.
static int MAC_LENGTH
          256 bits output for signing message.
static String VERSION_ANDROID_KEY_STORE
           
static String VERSION_USER_DEFINED
           
 
Constructor Summary
StorageHelper(android.content.Context ctx)
           
 
Method Summary
 String decrypt(String value)
           
 String encrypt(String clearText)
          encrypt text with current key based on API level
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_KEY_LENGTH

public static final int DATA_KEY_LENGTH
IV Key length for AES-128.

See Also:
Constant Field Values

MAC_LENGTH

public static final int MAC_LENGTH
256 bits output for signing message.

See Also:
Constant Field Values

VERSION_ANDROID_KEY_STORE

public static final String VERSION_ANDROID_KEY_STORE
See Also:
Constant Field Values

VERSION_USER_DEFINED

public static final String VERSION_USER_DEFINED
See Also:
Constant Field Values
Constructor Detail

StorageHelper

public StorageHelper(android.content.Context ctx)
              throws NoSuchAlgorithmException,
                     NoSuchPaddingException
Throws:
NoSuchAlgorithmException
NoSuchPaddingException
Method Detail

encrypt

public String encrypt(String clearText)
               throws NoSuchAlgorithmException,
                      InvalidKeySpecException,
                      InvalidKeyException,
                      InvalidAlgorithmParameterException,
                      IllegalBlockSizeException,
                      BadPaddingException,
                      IOException,
                      NoSuchPaddingException
encrypt text with current key based on API level

Parameters:
clearText -
Returns:
Throws:
NoSuchAlgorithmException
InvalidKeySpecException
InvalidKeyException
InvalidAlgorithmParameterException
IllegalBlockSizeException
BadPaddingException
IOException
NoSuchPaddingException

decrypt

public String decrypt(String value)
               throws NoSuchAlgorithmException,
                      InvalidKeySpecException,
                      NoSuchPaddingException,
                      KeyStoreException,
                      CertificateException,
                      NoSuchProviderException,
                      InvalidAlgorithmParameterException,
                      UnrecoverableEntryException,
                      IOException,
                      InvalidKeyException,
                      DigestException,
                      IllegalBlockSizeException,
                      BadPaddingException
Throws:
NoSuchAlgorithmException
InvalidKeySpecException
NoSuchPaddingException
KeyStoreException
CertificateException
NoSuchProviderException
InvalidAlgorithmParameterException
UnrecoverableEntryException
IOException
InvalidKeyException
DigestException
IllegalBlockSizeException
BadPaddingException


Copyright © 2003–2015. All rights reserved.