Skip to content

Commit

Permalink
rename CryptoManager to SecureCredentialsManager
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Sep 27, 2017
1 parent a8d169a commit aa2a7ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ manager.clearCredentials();

### Encryption enforced (Min API 21)

This version expands the minimum version and adds encryption to the data storage. In those devices where a Secure LockScreen has been configured it can require the user authentication before letting them obtain the stored credentials. The class is called `CryptoManager`.
This version expands the minimum version and adds encryption to the data storage. In those devices where a Secure LockScreen has been configured it can require the user authentication before letting them obtain the stored credentials. The class is called `SecureCredentialsManager`.


#### Usage
Expand All @@ -516,7 +516,7 @@ The usage is similar to the previous version, with the slight difference that th
```java
AuthenticationAPIClient authentication = new AuthenticationAPIClient(account);
Storage storage = new SharedPreferencesStorage(this);
CryptoManager manager = new CryptoManager(this, authentication, storage);
SecureCredentialsManager manager = new SecureCredentialsManager(this, authentication, storage);
```

#### Requiring Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
*/
@SuppressWarnings({"WeakerAccess", "unused"})
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class CryptoManager {
public class SecureCredentialsManager {

private static final String TAG = CryptoManager.class.getSimpleName();
private static final String TAG = SecureCredentialsManager.class.getSimpleName();

private static final String KEY_CREDENTIALS = "com.auth0.credentials";
private static final String KEY_EXPIRES_AT = "com.auth0.credentials_expires_at";
Expand All @@ -53,7 +53,7 @@ public class CryptoManager {


@VisibleForTesting
CryptoManager(@NonNull AuthenticationAPIClient apiClient, @NonNull Storage storage, @NonNull CryptoUtil crypto) {
SecureCredentialsManager(@NonNull AuthenticationAPIClient apiClient, @NonNull Storage storage, @NonNull CryptoUtil crypto) {
this.apiClient = apiClient;
this.storage = storage;
this.crypto = crypto;
Expand All @@ -62,13 +62,13 @@ public class CryptoManager {
}

/**
* Creates a new CryptoManager to handle Credentials
* Creates a new SecureCredentialsManager to handle Credentials
*
* @param context a valid context
* @param apiClient the Auth0 Authentication API Client to handle token refreshment when needed.
* @param storage the storage implementation to use
*/
public CryptoManager(@NonNull Context context, @NonNull AuthenticationAPIClient apiClient, @NonNull Storage storage) {
public SecureCredentialsManager(@NonNull Context context, @NonNull AuthenticationAPIClient apiClient, @NonNull Storage storage) {
this(apiClient, storage, new CryptoUtil(context, storage, KEY_ALIAS));
}

Expand All @@ -78,7 +78,7 @@ public CryptoManager(@NonNull Context context, @NonNull AuthenticationAPIClient
* has configured a secure LockScreen (PIN, Pattern, Password or Fingerprint).
* <p>
* The activity passed as first argument here must override the {@link Activity#onActivityResult(int, int, Intent)} method and
* call {@link CryptoManager#checkAuthenticationResult(int, int)} with the received parameters.
* call {@link SecureCredentialsManager#checkAuthenticationResult(int, int)} with the received parameters.
*
* @param activity a valid activity context. Will be used in the authentication request to launch a LockScreen intent.
* @param requestCode the request code to use in the authentication request. Must be a value between 1 and 200.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@RunWith(RobolectricTestRunner.class)
@Config(constants = com.auth0.android.auth0.BuildConfig.class, sdk = 21, manifest = Config.NONE)
public class CryptoManagerTest {
public class SecureCredentialsManagerTest {

@Mock
private AuthenticationAPIClient client;
Expand All @@ -75,7 +75,7 @@ public class CryptoManagerTest {
@Rule
public ExpectedException exception = ExpectedException.none();

private CryptoManager manager;
private SecureCredentialsManager manager;
private Gson gson;

@Before
Expand All @@ -86,8 +86,8 @@ public void setUp() throws Exception {
KeyguardManager kManager = mock(KeyguardManager.class);
when(activityContext.getSystemService(Context.KEYGUARD_SERVICE)).thenReturn(kManager);

CryptoManager cryptoManager = new CryptoManager(client, storage, crypto);
manager = spy(cryptoManager);
SecureCredentialsManager secureCredentialsManager = new SecureCredentialsManager(client, storage, crypto);
manager = spy(secureCredentialsManager);
doReturn(CredentialsMock.CURRENT_TIME_MS).when(manager).getCurrentTimeInMillis();
gson = new Gson();
}
Expand All @@ -97,7 +97,7 @@ public void shouldCreateAManagerInstance() throws Exception {
Context context = Robolectric.buildActivity(Activity.class).create().start().resume().get();
AuthenticationAPIClient apiClient = new AuthenticationAPIClient(new Auth0("clientId", "domain"));
Storage storage = new SharedPreferencesStorage(context);
final CryptoManager manager = new CryptoManager(context, apiClient, storage);
final SecureCredentialsManager manager = new SecureCredentialsManager(context, apiClient, storage);
assertThat(manager, is(notNullValue()));
}

Expand Down

0 comments on commit aa2a7ac

Please sign in to comment.