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
2 changes: 1 addition & 1 deletion common
Submodule common updated 26 files
+1 −0 changelog.txt
+0 −72 common/src/main/java/com/microsoft/identity/common/nativeauth/internal/commands/GetAuthMethodsCommand.kt
+2 −2 common/src/main/java/com/microsoft/identity/common/nativeauth/internal/commands/MFAChallengeCommand.kt
+59 −142 common/src/main/java/com/microsoft/identity/common/nativeauth/internal/controllers/NativeAuthMsalController.kt
+3 −1 common/src/main/java/com/microsoft/identity/common/nativeauth/internal/util/CommandUtil.java
+6 −20 ...om/microsoft/identity/common/internal/providers/microsoft/nativeauth/integration/SignInOAuthStrategyTest.kt
+45 −91 common/src/test/java/com/microsoft/identity/common/nativeauth/internal/controllers/NativeAuthControllerTest.kt
+32 −1 common/src/test/java/com/microsoft/identity/common/nativeauth/internal/util/CommandUtilTest.kt
+0 −2 common4j/src/main/com/microsoft/identity/common/java/eststelemetry/PublicApiId.java
+0 −64 ...main/com/microsoft/identity/common/java/nativeauth/commands/parameters/GetAuthMethodsCommandParameters.java
+11 −6 .../microsoft/identity/common/java/nativeauth/commands/parameters/MFAChallengeAuthMethodCommandParameters.java
+0 −64 ...osoft/identity/common/java/nativeauth/commands/parameters/MFASelectedDefaultChallengeCommandParameters.java
+6 −0 ...in/com/microsoft/identity/common/java/nativeauth/commands/parameters/SignInSubmitCodeCommandParameters.java
+0 −13 common4j/src/main/com/microsoft/identity/common/java/nativeauth/controllers/results/MFACommandResult.kt
+3 −6 common4j/src/main/com/microsoft/identity/common/java/nativeauth/controllers/results/SignInCommandResult.kt
+2 −0 common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthConstants.kt
+4 −3 common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt
+3 −3 ...on4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/requests/signin/SignInTokenRequest.kt
+7 −23 ...main/com/microsoft/identity/common/java/nativeauth/providers/responses/signin/SignInChallengeApiResponse.kt
+0 −20 ...c/main/com/microsoft/identity/common/java/nativeauth/providers/responses/signin/SignInChallengeApiResult.kt
+0 −4 common4j/src/main/com/microsoft/identity/common/java/nativeauth/util/ApiErrorResponseUtil.kt
+104 −0 common4j/src/main/com/microsoft/identity/common/java/util/TenantUtil.kt
+4 −2 common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProviderTest.kt
+0 −25 common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthResponseHandlerTest.kt
+277 −0 common4j/src/test/com/microsoft/identity/common/java/util/TenantUtilTest.kt
+0 −1 common4j/src/testFixtures/java/com/microsoft/identity/common/nativeauth/MockApiResponseType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
import com.microsoft.identity.common.java.dto.AccountRecord;
import com.microsoft.identity.common.java.exception.ClientException;
import com.microsoft.identity.common.java.nativeauth.authorities.NativeAuthCIAMAuthority;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.GetAuthMethodsCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.MFADefaultChallengeCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.MFASelectedDefaultChallengeCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.MFAChallengeAuthMethodCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.MFASubmitChallengeCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordResendCodeCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordStartCommandParameters;
Expand Down Expand Up @@ -677,6 +675,7 @@ public static SignInSubmitCodeCommandParameters createSignInSubmitCodeCommandPar
.continuationToken(continuationToken)
.authenticationScheme(authenticationScheme)
.challengeType(configuration.getChallengeTypes())
.isMFAGrantType(false)
.code(code)
.scopes(scopes)
.correlationId(correlationId)
Expand Down Expand Up @@ -778,54 +777,6 @@ public static SignInSubmitPasswordCommandParameters createSignInSubmitPasswordCo
return commandParameters;
}

/**
* Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.MFAChallengeCommand}] of Native Auth
* @param configuration PCA configuration
* @param tokenCache token cache for storing results
* @param correlationId correlation ID to use in the API request, taken from the previous request in the flow
* @param continuationToken continuation token
* @param scopes scopes requested during sign in flow
* @return Command parameter object
* @throws ClientException
*/
public static MFADefaultChallengeCommandParameters createMFADefaultChallengeCommandParameters(
@NonNull final NativeAuthPublicClientApplicationConfiguration configuration,
@NonNull final OAuth2TokenCache tokenCache,
@NonNull final String continuationToken,
@NonNull final String correlationId,
final List<String> scopes) throws ClientException {

final NativeAuthCIAMAuthority authority = ((NativeAuthCIAMAuthority) configuration.getDefaultAuthority());

final AbstractAuthenticationScheme authenticationScheme = AuthenticationSchemeFactory.createScheme(
AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext()),
null
);

final MFADefaultChallengeCommandParameters commandParameters =
MFADefaultChallengeCommandParameters.builder()
.platformComponents(AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext()))
.applicationName(configuration.getAppContext().getPackageName())
.applicationVersion(getPackageVersion(configuration.getAppContext()))
.clientId(configuration.getClientId())
.isSharedDevice(configuration.getIsSharedDevice())
.redirectUri(configuration.getRedirectUri())
.oAuth2TokenCache(tokenCache)
.requiredBrokerProtocolVersion(configuration.getRequiredBrokerProtocolVersion())
.sdkType(SdkType.MSAL)
.sdkVersion(PublicClientApplication.getSdkVersion())
.powerOptCheckEnabled(configuration.isPowerOptCheckForEnabled())
.authority(authority)
.authenticationScheme(authenticationScheme)
.continuationToken(continuationToken)
.scopes(scopes)
.challengeType(configuration.getChallengeTypes())
.correlationId(correlationId)
.build();

return commandParameters;
}

/**
* Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.MFAChallengeCommand}] of Native Auth
* @param configuration PCA configuration
Expand All @@ -836,7 +787,7 @@ public static MFADefaultChallengeCommandParameters createMFADefaultChallengeComm
* @return Command parameter object
* @throws ClientException
*/
public static MFASelectedDefaultChallengeCommandParameters createMFASelectedChallengeCommandParameters(
public static MFAChallengeAuthMethodCommandParameters createMFAChallengeAuthMethodCommandParameters(
@NonNull final NativeAuthPublicClientApplicationConfiguration configuration,
@NonNull final OAuth2TokenCache tokenCache,
@NonNull final String continuationToken,
Expand All @@ -853,8 +804,8 @@ public static MFASelectedDefaultChallengeCommandParameters createMFASelectedChal

final String authMethodId = authMethod.getId();

final MFASelectedDefaultChallengeCommandParameters commandParameters =
MFASelectedDefaultChallengeCommandParameters.builder()
final MFAChallengeAuthMethodCommandParameters commandParameters =
MFAChallengeAuthMethodCommandParameters.builder()
.platformComponents(AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext()))
.applicationName(configuration.getAppContext().getPackageName())
.applicationVersion(getPackageVersion(configuration.getAppContext()))
Expand Down Expand Up @@ -927,44 +878,6 @@ public static MFASubmitChallengeCommandParameters createMFASubmitChallengeComman
return commandParameters;
}

/**
* Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.GetAuthMethodsCommand}] of Native Auth
* @param configuration PCA configuration
* @param tokenCache token cache for storing results
* @param correlationId correlation ID to use in the API request, taken from the previous request in the flow
* @param continuationToken Continuation token
* @return Command parameter object
*/
public static GetAuthMethodsCommandParameters createGetAuthMethodsCommandParameters(
@NonNull final NativeAuthPublicClientApplicationConfiguration configuration,
@NonNull final OAuth2TokenCache tokenCache,
@NonNull final String continuationToken,
@NonNull final String correlationId) {

final NativeAuthCIAMAuthority authority = ((NativeAuthCIAMAuthority) configuration.getDefaultAuthority());

final GetAuthMethodsCommandParameters commandParameters =
GetAuthMethodsCommandParameters.builder()
.platformComponents(AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext()))
.applicationName(configuration.getAppContext().getPackageName())
.applicationVersion(getPackageVersion(configuration.getAppContext()))
.clientId(configuration.getClientId())
.isSharedDevice(configuration.getIsSharedDevice())
.redirectUri(configuration.getRedirectUri())
.oAuth2TokenCache(tokenCache)
.requiredBrokerProtocolVersion(configuration.getRequiredBrokerProtocolVersion())
.sdkType(SdkType.MSAL)
.sdkVersion(PublicClientApplication.getSdkVersion())
.powerOptCheckEnabled(configuration.isPowerOptCheckForEnabled())
.authority(authority)
.continuationToken(continuationToken)
.challengeType(configuration.getChallengeTypes())
.correlationId(correlationId)
.build();

return commandParameters;
}

/**
* Creates command parameter for [ResetPasswordStartCommand] of Native Auth.
* @param configuration PCA configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ class NativeAuthPublicClientApplication(
correlationId = result.correlationId,
scopes = scopes,
config = nativeAuthConfig
)
),
authMethods = result.authMethods.toListOfAuthMethods()
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.microsoft.identity.nativeauth.statemachine.errors

import com.microsoft.identity.nativeauth.statemachine.results.MFAGetAuthMethodsResult
import com.microsoft.identity.nativeauth.statemachine.results.MFARequiredResult
import com.microsoft.identity.nativeauth.statemachine.results.MFASubmitChallengeResult

Expand All @@ -26,27 +25,6 @@ class MFARequestChallengeError(
override var exception: Exception? = null
): MFARequiredResult, BrowserRequiredError, Error(errorType = errorType, error = error, errorMessage= errorMessage, correlationId = correlationId, errorCodes = errorCodes, exception = exception)

/**
* MFA get authentication methods error. Use the utility methods of this class
* to identify and handle the error. This error is produced by
* [com.microsoft.identity.nativeauth.statemachine.states.MFARequiredState.getAuthMethods]
* @param errorType the error type value of the error that occurred.
* @param error the error returned by the authentication server.
* @param errorMessage the error message returned by the authentication server.
* @param correlationId a unique identifier for the request that can help in diagnostics.
* @param errorCodes a list of specific error codes returned by the authentication server.
* @param exception an internal unexpected exception that happened.
*/
class MFAGetAuthMethodsError(
override val errorType: String? = null,
override val error: String? = null,
override val errorMessage: String?,
override val correlationId: String,
override val errorCodes: List<Int>? = null,
val subError: String? = null,
override var exception: Exception? = null
): MFAGetAuthMethodsResult, BrowserRequiredError, Error(errorType = errorType, error = error, errorMessage= errorMessage, correlationId = correlationId, errorCodes = errorCodes, exception = exception)

/**
* MFA submit challenge error. The user should use the utility methods of this class
* to identify and handle the error. This error is produced by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

package com.microsoft.identity.nativeauth.statemachine.results

import com.microsoft.identity.nativeauth.AuthMethod
import com.microsoft.identity.nativeauth.statemachine.states.MFARequiredState

/**
Expand All @@ -46,26 +45,8 @@ interface MFARequiredResult: Result {
val sentTo: String,
val channel: String,
) : MFARequiredResult, Result.SuccessResult(nextState = nextState)

/**
* Selection required result, which indicates that a specific authentication method must be selected, which
* the server will send the challenge to (once sendChallenge() is called).
*
* @param nextState [com.microsoft.identity.nativeauth.statemachine.states.MFARequiredState] the current state of the flow with follow-on methods.
* @param authMethods the authentication methods that can be used to complete the challenge flow.
*/
class SelectionRequired(
override val nextState: MFARequiredState,
val authMethods: List<AuthMethod>
) : MFARequiredResult, MFAGetAuthMethodsResult, Result.SuccessResult(nextState = nextState)
}

/**
* Results related to get authentication methods operation, produced by
* [com.microsoft.identity.nativeauth.statemachine.states.MFARequiredState.getAuthMethods]
*/
interface MFAGetAuthMethodsResult : Result

/**
* Results related to MFA submit challenge operation, produced by
* [com.microsoft.identity.nativeauth.statemachine.states.MFARequiredState.submitChallenge]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ interface SignInResult : Result {
* @param nextState [com.microsoft.identity.nativeauth.statemachine.states.AwaitingMFAState] the current state of the flow with follow-on methods.
*/
class MFARequired(
override val nextState: AwaitingMFAState
) : SignInResult, Result.SuccessResult(nextState = nextState), SignInSubmitPasswordResult
override val nextState: AwaitingMFAState,
val authMethods: List<AuthMethod>
) : Result.SuccessResult(nextState = nextState), SignInResult, SignInSubmitPasswordResult

/**
* StrongAuthMethodRegistration Result, which indicates that a registration of a strong authentication method is required to continue.
Expand All @@ -94,7 +95,7 @@ interface SignInResult : Result {
class StrongAuthMethodRegistrationRequired(
override val nextState: RegisterStrongAuthState,
val authMethods: List<AuthMethod>
) : SignInResult, SignInSubmitPasswordResult, Result.SuccessResult(nextState = nextState)
) : Result.SuccessResult(nextState = nextState), SignInResult, SignInSubmitPasswordResult
}

/**
Expand Down
Loading