This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into AGDROID-719
- Loading branch information
Showing
27 changed files
with
666 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../org/aerogear/auth/AbstractPrincipal.java → ...r/android/ags/auth/AbstractPrincipal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.aerogear.auth; | ||
package org.aerogear.android.ags.auth; | ||
|
||
/** | ||
* Base class for aerogear principals | ||
|
2 changes: 1 addition & 1 deletion
2
.../java/org/aerogear/auth/AbstractRole.java → ...rogear/android/ags/auth/AbstractRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.aerogear.auth; | ||
package org.aerogear.android.ags.auth; | ||
|
||
/** | ||
* Base class for roles pojos. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../org/aerogear/auth/AuthServiceConfig.java → ...r/android/ags/auth/AuthServiceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.aerogear.auth; | ||
package org.aerogear.android.ags.auth; | ||
|
||
/** | ||
* Authentication service configuration | ||
|
41 changes: 28 additions & 13 deletions
41
...aerogear/auth/utils/AuthStateManager.java → ...ar/android/ags/auth/AuthStateManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,75 @@ | ||
package org.aerogear.auth.utils; | ||
package org.aerogear.android.ags.auth; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import org.aerogear.auth.credentials.OIDCCredentials; | ||
import org.json.JSONException; | ||
|
||
import org.aerogear.android.ags.auth.credentials.OIDCCredentials; | ||
|
||
/** | ||
* Saves, retrieves and delete a token. | ||
*/ | ||
public class AuthStateManager { | ||
|
||
private static AuthStateManager instance = null; | ||
private static final String STORE_NAME = "org.aerogear.android.auth.AuthState"; | ||
private static final String KEY_STATE = "state"; | ||
|
||
private final SharedPreferences prefs; | ||
|
||
public AuthStateManager(final Context context) { | ||
private AuthStateManager(final Context context) { | ||
this.prefs = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE); | ||
} | ||
|
||
/** | ||
* Reads credentials from storage. | ||
* @return OIDCCredentials | ||
*/ | ||
public OIDCCredentials read() { | ||
String currentState = prefs.getString(KEY_STATE, null); | ||
public OIDCCredentials load() { | ||
final String currentState = prefs.getString(KEY_STATE, null); | ||
if (currentState == null) { | ||
return new OIDCCredentials(); | ||
} | ||
try { | ||
return new OIDCCredentials(currentState); | ||
} catch (JSONException ex) { | ||
return new OIDCCredentials(); | ||
} | ||
return OIDCCredentials.deserialize(currentState); | ||
} | ||
|
||
/** | ||
* Saves a token | ||
* @param authState token to be saved | ||
* @throws IllegalStateException | ||
*/ | ||
public synchronized void write(final OIDCCredentials authState) { | ||
public synchronized void save(final OIDCCredentials authState) { | ||
if (authState == null) { | ||
clear(); | ||
} else { | ||
if(!prefs.edit().putString(KEY_STATE, authState.serialise()).commit()) { | ||
SharedPreferences.Editor e = prefs.edit(); | ||
SharedPreferences.Editor bleh = e.putString(KEY_STATE, authState.serialize()); | ||
if(!bleh.commit()) { | ||
throw new IllegalStateException("Failed to update state from shared preferences"); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Deletes a token | ||
* @throws IllegalArgumentException | ||
*/ | ||
public synchronized void clear() { | ||
if (!prefs.edit().remove(KEY_STATE).commit()) { | ||
throw new IllegalStateException("Failed to clear state from shared preferences"); | ||
} | ||
} | ||
|
||
static AuthStateManager getInstance(final Context context) { | ||
if (instance == null) { | ||
instance = new AuthStateManager(context); | ||
} | ||
return instance; | ||
} | ||
|
||
public static AuthStateManager getInstance() { | ||
if (instance == null) { | ||
throw new IllegalStateException("Context has not previously been provided. Cannot initialize without Context."); | ||
} | ||
return instance; | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...rg/aerogear/auth/AuthenticationChain.java → ...android/ags/auth/AuthenticationChain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erogear/auth/AuthenticationException.java → ...oid/ags/auth/AuthenticationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...in/java/org/aerogear/auth/ClientRole.java → ...aerogear/android/ags/auth/ClientRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rc/main/java/org/aerogear/auth/IRole.java → .../org/aerogear/android/ags/auth/IRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ava/org/aerogear/auth/IUserPrincipal.java → ...gear/android/ags/auth/IUserPrincipal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ain/java/org/aerogear/auth/RealmRole.java → .../aerogear/android/ags/auth/RealmRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package org.aerogear.auth; | ||
package org.aerogear.android.ags.auth; | ||
|
||
public final class RealmRole extends AbstractRole { | ||
public RealmRole(final String roleName) { | ||
super(roleName); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...erogear/auth/credentials/ICredential.java → ...oid/ags/auth/credentials/ICredential.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
auth/src/main/java/org/aerogear/android/ags/auth/credentials/IIntegrityCheckParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.aerogear.android.ags.auth.credentials; | ||
|
||
public interface IIntegrityCheckParameters { | ||
|
||
String getAudience(); | ||
String getIssuer(); | ||
String getPublicKey(); | ||
|
||
/** | ||
* Check whether the parameters are valid or not. The criteria for validity is that each of | ||
* the parameters is defined (not null) and has valid formatting. | ||
* @return <code>true</code> if the parameters are valid. | ||
*/ | ||
boolean isValid(); | ||
String serialize(); | ||
} |
Oops, something went wrong.