Skip to content
Merged
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
6 changes: 4 additions & 2 deletions auth0/src/main/java/com/auth0/android/dpop/DPoP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public data class HeaderData(val authorizationHeader: String, val dpopProof: Str
* Class for securing requests with DPoP (Demonstrating Proof of Possession) as described in
* [RFC 9449](https://datatracker.ietf.org/doc/html/rfc9449).
*/
public class DPoP(private val context: Context) {
public class DPoP(context: Context) {

private val applicationContext: Context = context.applicationContext

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding . holding activity context would cause issue DPoP instance lives longer than activity and causing activity to not GC?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

/**
* Determines whether a DPoP proof should be generated for the given URL and parameters. The proof should
Expand Down Expand Up @@ -79,7 +81,7 @@ public class DPoP(private val context: Context) {
*/
@Throws(DPoPException::class)
internal fun generateKeyPair() {
DPoPUtil.generateKeyPair(context)
DPoPUtil.generateKeyPair(applicationContext)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class AuthenticationAPIClientTest {
mockAPI = AuthenticationAPIMockServer()
mockKeyStore = mock()
mockContext = mock()
whenever(mockContext.applicationContext).thenReturn(mockContext)
val auth0 = auth0
client = AuthenticationAPIClient(auth0)
gson = GsonBuilder().serializeNulls().create()
Expand Down
2 changes: 2 additions & 0 deletions auth0/src/test/java/com/auth0/android/dpop/DPoPTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class DPoPTest {
mockResponse = mock()
mockKeyStore = mock()
mockResponseBody = mock()

whenever(mockContext.applicationContext).thenReturn(mockContext)
dPoP = DPoP(mockContext)

DPoP._auth0Nonce = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class WebAuthProviderTest {

mockKeyStore = mock()
mockContext = mock()
Mockito.`when`(mockContext.applicationContext).thenReturn(mockContext)

DPoPUtil.keyStore = mockKeyStore

Expand Down
Loading