Skip to content

Commit

Permalink
Merge pull request #8 from govuk-one-login/refactor/DCMAW-7374
Browse files Browse the repository at this point in the history
Fix pom dependencies
  • Loading branch information
alex-bradbury authored Feb 1, 2024
2 parents abb587b + 54de644 commit 84134bb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
36 changes: 17 additions & 19 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.android.kotlin)
Expand Down Expand Up @@ -101,8 +98,8 @@ dependencies {

listOf(
libs.androidx.core.core.ktx,
libs.appauth,
libs.appcompat,
libs.appauth,
libs.kotlinx.serialization.json
).forEach(::implementation)

Expand All @@ -119,25 +116,26 @@ publishing {
version = rootProject.extra["packageVersion"] as String

artifact("$buildDir/outputs/aar/${project.name}-release.aar")

// generate pom nodes for dependencies
pom.withXml {
val dependenciesNode = asNode().appendNode("dependencies")
configurations.compileOnly.configure {
allDependencies.forEach { dependency ->
val dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", dependency.group)
dependencyNode.appendNode("artifactId", dependency.name)
dependencyNode.appendNode("version", dependency.version)
}
}
}
}
}
repositories {
maven("https://maven.pkg.github.com/govuk-one-login/mobile-android-authentication") {
if (file("${rootProject.projectDir.path}/github.properties").exists()) {
val propsFile = File("${rootProject.projectDir.path}/github.properties")
val props = Properties().also { it.load(FileInputStream(propsFile)) }
val ghUsername = props["username"] as String?
val ghToken = props["token"] as String?

credentials {
username = ghUsername
password = ghToken
}
} else {
credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
}
credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import net.openid.appauth.AuthorizationServiceConfiguration

@Suppress("TooGenericExceptionThrown")
class AppAuthSession(
private val context: Context
context: Context
) : LoginSession {
private val authService: AuthorizationService = AuthorizationService(context)

override fun present(
activity: Activity,
configuration: LoginSessionConfiguration
) {
with(configuration) {
Expand Down Expand Up @@ -47,7 +48,7 @@ class AppAuthSession(

val authIntent = authService.getAuthorizationRequestIntent(authRequest)
ActivityCompat.startActivityForResult(
context as Activity,
activity,
authIntent,
REQUEST_CODE_AUTH,
null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.android.authentication

import android.app.Activity
import android.content.Intent

/**
Expand All @@ -14,6 +15,7 @@ interface LoginSession {
* @param configuration [LoginSessionConfiguration] containing necessary session configuration
*/
fun present(
activity: Activity,
configuration: LoginSessionConfiguration
)

Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/uk/gov/android/authentication/TokenResponse.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package uk.gov.android.authentication

import android.util.Log
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

Expand All @@ -17,4 +19,18 @@ data class TokenResponse(
fun jsonSerializeString(): String {
return Json.encodeToString(this)
}

companion object {
fun jsonDeserialize(text: String): TokenResponse? {
return try {
Json.decodeFromString(text)
} catch (e: SerializationException) {
Log.e(this::class.java.simpleName, e.message, e)
null
} catch (e: IllegalArgumentException) {
Log.e(this::class.java.simpleName, e.message, e)
null
}
}
}
}
2 changes: 2 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<!-- Generated by `./gradlew refreshVersions` to avoid errors when using _ as a version. -->
<issue id="GradlePluginVersion" severity="ignore" />
<issue id="GradleDependency" severity="ignore" />

<issue id="NewerVersionAvailable" severity="informational" />
</lint>

0 comments on commit 84134bb

Please sign in to comment.