Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion app/java/net/openid/appauthdemo/TokenActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ private void performTokenRequest(
callback);
}

@MainThread
private void performTokenValidation(
TokenResponse response,
AuthorizationService.TokenValidationResponseCallback callback) {

mAuthService.performTokenValidation(
response,
callback);
}

@WorkerThread
private void handleAccessTokenResponse(
@Nullable TokenResponse tokenResponse,
Expand All @@ -300,7 +310,7 @@ private void handleAccessTokenResponse(
runOnUiThread(this::displayAuthorized);
}

@WorkerThread
@MainThread
private void handleCodeExchangeResponse(
@Nullable TokenResponse tokenResponse,
@Nullable AuthorizationException authException) {
Expand All @@ -314,7 +324,34 @@ private void handleCodeExchangeResponse(
//noinspection WrongThread
runOnUiThread(() -> displayNotAuthorized(message));
} else {
if (tokenResponse != null
&& tokenResponse.idToken != null
&& tokenResponse.request.configuration.discoveryDoc != null) {
performTokenValidation(
tokenResponse,
this::handleTokenValidationResponse);
} else {
final String message = "Failed to perform id_token validation";

// WrongThread inference is incorrect for lambdas
//noinspection WrongThread
runOnUiThread(() -> displayNotAuthorized(message));
}
}
}

@WorkerThread
private void handleTokenValidationResponse(
boolean isTokenValid,
@Nullable AuthorizationException authException) {
if (isTokenValid) {
runOnUiThread(this::displayAuthorized);
} else {
final String message = "Invalid id_token";

// WrongThread inference is incorrect for lambdas
//noinspection WrongThread
runOnUiThread(() -> displayNotAuthorized(message));
}
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'org.ajoberstar:gradle-git:1.7.1'
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android.defaultConfig.project.archivesBaseName = 'appauth'
// libraries or apps.
android.buildTypes.debug.manifestPlaceholders = [
'appAuthRedirectScheme': 'net.openid.appauth.test'
];
]

dependencies {
api "com.android.support:customtabs:${rootProject.supportLibVersion}"
Expand Down
Loading