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
12 changes: 5 additions & 7 deletions auth0/src/main/java/com/auth0/android/dpop/DPoP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.auth0.android.request.HttpMethod
import com.auth0.android.request.getErrorBody
import okhttp3.Response
import java.lang.reflect.Modifier.PRIVATE
import java.util.concurrent.atomic.AtomicReference


/**
Expand Down Expand Up @@ -102,12 +103,11 @@ public class DPoP(context: Context) {
private const val AUTHORIZATION_HEADER = "Authorization"
private const val NONCE_HEADER = "DPoP-Nonce"

@Volatile
@VisibleForTesting(otherwise = PRIVATE)
internal var _auth0Nonce: String? = null
internal val _auth0Nonce: AtomicReference<String?> = AtomicReference(null)

public val auth0Nonce: String?
get() = _auth0Nonce
get() = _auth0Nonce.get()

/**
* Stores the nonce value from the Okhttp3 [Response] headers.
Expand All @@ -127,9 +127,7 @@ public class DPoP(context: Context) {
@JvmStatic
internal fun storeNonce(response: Response) {
response.headers[NONCE_HEADER]?.let {
synchronized(this) {
_auth0Nonce = it
}
_auth0Nonce.set(it)
}
}

Expand Down Expand Up @@ -220,7 +218,7 @@ public class DPoP(context: Context) {
@JvmStatic
public fun clearKeyPair() {
DPoPUtil.clearKeyPair()
_auth0Nonce = null
_auth0Nonce.set(null)
}
}
}
1 change: 0 additions & 1 deletion auth0/src/main/java/com/auth0/android/dpop/DPoPUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ internal object DPoPUtil {


@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
@Volatile
internal var keyStore = DPoPKeyStore()


Expand Down
2 changes: 1 addition & 1 deletion auth0/src/test/java/com/auth0/android/dpop/DPoPTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DPoPTest {
whenever(mockContext.applicationContext).thenReturn(mockContext)
dPoP = DPoP(mockContext)

DPoP._auth0Nonce = null
DPoP._auth0Nonce.set(null)

DPoPUtil.keyStore = mockKeyStore
}
Expand Down