Skip to content

Commit e70a685

Browse files
committed
adjust method
1 parent f965726 commit e70a685

File tree

1 file changed

+10
-4
lines changed
  • common4j/src/main/com/microsoft/identity/common/java/util

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// THE SOFTWARE.
2323
package com.microsoft.identity.common.java.util
2424

25+
import com.microsoft.identity.common.java.authorities.Authority
2526
import com.microsoft.identity.common.java.authorities.AzureActiveDirectoryAudience
2627
import com.microsoft.identity.common.java.authorities.AzureActiveDirectoryAuthority
2728
import java.util.Locale
@@ -34,11 +35,16 @@ class MsaUtil {
3435
/**
3536
* Given an authority, check if this is an MSA request
3637
*/
37-
fun isMsaRequest(authority : AzureActiveDirectoryAuthority) : Boolean{
38-
val audience = authority.audience.tenantId.lowercase(Locale.ROOT)
38+
fun isMsaRequest(authority : Authority) : Boolean{
39+
return if (authority !is AzureActiveDirectoryAuthority) {
40+
false
41+
} else {
42+
// authority has been silently casted to AzureActiveDirectoryAuthority
43+
val audience = authority.audience.tenantId.lowercase(Locale.ROOT)
3944

40-
// Check if audience is consumers or the MSA Mega Tenant
41-
return audience == AzureActiveDirectoryAudience.MSA_MEGA_TENANT_ID || audience == AzureActiveDirectoryAudience.CONSUMERS
45+
// Check if audience is consumers or the MSA Mega Tenant
46+
audience == AzureActiveDirectoryAudience.MSA_MEGA_TENANT_ID || audience == AzureActiveDirectoryAudience.CONSUMERS
47+
}
4248
}
4349
}
4450
}

0 commit comments

Comments
 (0)