Skip to content

Commit ab00024

Browse files
committed
add new error for verification contact blocked
1 parent 9edfe14 commit ab00024

5 files changed

Lines changed: 51 additions & 1 deletion

File tree

common/src/main/java/com/microsoft/identity/common/nativeauth/internal/controllers/NativeAuthMsalController.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,16 @@ class NativeAuthMsalController : BaseNativeAuthController() {
664664
correlationId = result.correlationId
665665
)
666666
}
667+
is JITChallengeApiResult.BlockedVerificationContact -> {
668+
val customDescription = "Verification contact blocked. " +
669+
"Please try using another email or phone number, or select an alternative authentication method."
670+
JITCommandResult.BlockedVerificationContact(
671+
error = result.error,
672+
errorDescription = customDescription + result.errorDescription,
673+
errorCodes = result.errorCodes,
674+
correlationId = result.correlationId
675+
)
676+
}
667677
is JITChallengeApiResult.OOBRequired -> {
668678
JITCommandResult.VerificationRequired(
669679
correlationId = result.correlationId,

common4j/src/main/com/microsoft/identity/common/java/nativeauth/controllers/results/JITCommandResult.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ interface JITCommandResult {
3838
override fun toString(): String = "VerificationRequired(correlationId=$correlationId, codeLength=$codeLength, challengeChannel=$challengeChannel)"
3939
}
4040

41+
data class BlockedVerificationContact(
42+
override val correlationId: String,
43+
val error: String,
44+
val errorDescription: String,
45+
val errorCodes: List<Int>
46+
) : JITChallengeAuthMethodCommandResult {
47+
override fun toUnsanitizedString(): String = "BlockedVerificationContact(correlationId=$correlationId, error=$error, errorDescription=$errorDescription, errorCodes=$errorCodes)"
48+
49+
override fun toString(): String = "BlockedVerificationContact(correlationId=$correlationId)"
50+
}
51+
4152
data class IncorrectVerificationContact(
4253
override val correlationId: String,
4354
val error: String,

common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/responses/jit/JITChallengeApiResponse.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.google.gson.annotations.Expose
2626
import com.google.gson.annotations.SerializedName
2727
import com.microsoft.identity.common.java.nativeauth.providers.INativeAuthApiResponse
2828
import com.microsoft.identity.common.java.nativeauth.providers.responses.ApiErrorResult
29+
import com.microsoft.identity.common.java.nativeauth.util.isBlockedChallengeTarget
2930
import com.microsoft.identity.common.java.nativeauth.util.isInvalidChallengeTarget
3031
import com.microsoft.identity.common.java.nativeauth.util.isInvalidRequest
3132
import com.microsoft.identity.common.java.nativeauth.util.isOOB
@@ -78,7 +79,14 @@ class JITChallengeApiResponse(
7879
correlationId = correlationId
7980
)
8081
}
81-
82+
error.isInvalidRequest() && errorCodes?.first().isBlockedChallengeTarget() -> {
83+
JITChallengeApiResult.BlockedVerificationContact(
84+
error = error.orEmpty(),
85+
errorDescription = errorDescription.orEmpty(),
86+
errorCodes = errorCodes.orEmpty(),
87+
correlationId = correlationId
88+
)
89+
}
8290
else -> {
8391
JITChallengeApiResult.UnknownError(
8492
error = error.orEmpty(),

common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/responses/jit/JITChallengeApiResult.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ sealed interface JITChallengeApiResult: ApiResult {
8080
}
8181
}
8282

83+
data class BlockedVerificationContact(
84+
override val correlationId: String,
85+
override val error: String,
86+
override val errorDescription: String,
87+
override val errorCodes: List<Int>
88+
) : ApiErrorResult(
89+
error = error,
90+
errorDescription = errorDescription,
91+
errorCodes = errorCodes,
92+
correlationId = correlationId
93+
), JITChallengeApiResult {
94+
override fun toUnsanitizedString() = "BlockedVerificationContact(correlationId=$correlationId, " +
95+
"error=$error, errorDescription=$errorDescription, subError=$subError)"
96+
97+
override fun toString(): String = "BlockedVerificationContact(correlationId=$correlationId)"
98+
}
99+
83100
data class InvalidVerificationContact(
84101
override val correlationId: String,
85102
override val error: String,

common4j/src/main/com/microsoft/identity/common/java/nativeauth/util/ApiErrorResponseUtil.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ internal fun Int?.isInvalidChallengeTarget(): Boolean {
117117
return this == 901001
118118
}
119119

120+
internal fun Int?.isBlockedChallengeTarget(): Boolean {
121+
return this == 550024
122+
}
123+
120124
fun String?.isMFARequired(): Boolean {
121125
return this.contentEquals(other = "mfa_required", ignoreCase = true)
122126
}

0 commit comments

Comments
 (0)