Skip to content

Commit

Permalink
fixing gradle also making public IdToken from function
Browse files Browse the repository at this point in the history
  • Loading branch information
SayazhanBos committed Apr 8, 2024
1 parent 07a752f commit 4674134
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
4 changes: 1 addition & 3 deletions app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="net.openid.appauthdemo" >
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apply from: '../config/android-common.gradle'
apply from: '../config/keystore.gradle'

android {
namespace 'net.openid.appauthdemo'
defaultConfig {
applicationId 'net.openid.appauthdemo'
project.archivesBaseName = 'appauth-demoapp'
Expand Down
3 changes: 2 additions & 1 deletion config/android-common.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
android {
namespace 'net.openid.appauth'
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
Expand Down Expand Up @@ -41,7 +42,7 @@ task jar(type: Copy, dependsOn:'bundleRelease') {
// produces a JAR containing sources
task sourcesJar(type: Jar, dependsOn:'generateReleaseSources') {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier = 'sources'
}

tasks.withType(JavaCompile) {
Expand Down
4 changes: 2 additions & 2 deletions config/coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ task jacocoTestReport(type: JacocoReport, dependsOn: "testDebugUnitTest") {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.enabled = true
html.enabled = true
xml.required.set(true)
html.required.set(true)
}
// Class R is used, but usage will not be covered, so ignore this class from report
afterEvaluate {
Expand Down
4 changes: 2 additions & 2 deletions config/javadoc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
task androidJavadoc(type: JavaExec) {
jvmArgs = ['--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED']
classpath files(project.android.getBootClasspath())
main = 'jdk.javadoc.internal.tool.Main'
mainClass = 'jdk.javadoc.internal.tool.Main'
ext.destinationDir = file("${project.buildDir}/docs/javadoc")
args = ['-doctitle', "AppAuth for Android",
'-use',
Expand All @@ -25,7 +25,7 @@ task androidJavadoc(type: JavaExec) {
}

task javadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from androidJavadoc.ext.destinationDir
}

Expand Down
2 changes: 1 addition & 1 deletion config/style.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task checkAllSource(type: Checkstyle) {
afterEvaluate {
source 'java'
include '**/*.java'
classpath = files project.configurations.compile.files
classpath = files()
}
}

Expand Down
3 changes: 1 addition & 2 deletions library/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.openid.appauth">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
10 changes: 7 additions & 3 deletions library/java/net/openid/appauth/IdToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ private static JSONObject parseJwtSection(String section) throws JSONException {
return new JSONObject(jsonString);
}

static IdToken from(String token) throws JSONException, IdTokenException {
public static IdToken from(String token) throws JSONException, IdTokenException {
String[] sections = token.split("\\.");

if (sections.length <= 1) {
throw new IdTokenException("ID token must have both header and claims section");
}

// We ignore header contents, but parse it to check that it is structurally valid JSON
parseJwtSection(sections[0]);
JSONObject headers = parseJwtSection(sections[0]);
JSONObject claims = parseJwtSection(sections[1]);

final String issuer = JsonUtil.getString(claims, KEY_ISSUER);
Expand All @@ -182,7 +182,11 @@ static IdToken from(String token) throws JSONException, IdTokenException {
}
final Long expiration = claims.getLong(KEY_EXPIRATION);
final Long issuedAt = claims.getLong(KEY_ISSUED_AT);
final String nonce = JsonUtil.getStringIfDefined(claims, KEY_NONCE);
String tempNonce = JsonUtil.getStringIfDefined(claims, KEY_NONCE);
if (tempNonce == null) {
tempNonce = JsonUtil.getStringIfDefined(headers, KEY_NONCE);
}
final String nonce = tempNonce;
final String authorizedParty = JsonUtil.getStringIfDefined(claims, KEY_AUTHORIZED_PARTY);

for (String key: BUILT_IN_CLAIMS) {
Expand Down

0 comments on commit 4674134

Please sign in to comment.