-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the signature of signup/signin methods #2010
Changes from all commits
5a90b08
87f57e7
e06b11a
271c316
4848d79
829a9a2
9e2e30f
f3c9795
dc73583
b3a3590
e595c35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,17 +74,13 @@ | |
import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordSubmitNewPasswordCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInResendCodeCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInStartCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInStartUsingPasswordCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInSubmitCodeCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInSubmitPasswordCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpResendCodeCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpStartCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpStartUsingPasswordCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpSubmitCodeCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpSubmitPasswordCommandParameters; | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpSubmitUserAttributesCommandParameters; | ||
import com.microsoft.identity.nativeauth.NativeAuthPublicClientApplicationConfiguration; | ||
|
||
import java.util.AbstractMap; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
@@ -369,41 +365,6 @@ public static DeviceCodeFlowCommandParameters createDeviceCodeFlowCommandParamet | |
return commandParameters; | ||
} | ||
|
||
/** | ||
* Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.SignUpStartCommand}] of Native Auth. | ||
* @param configuration PCA configuration | ||
* @param tokenCache token cache for storing results | ||
* @param username email address of the user | ||
* @return Command parameter object | ||
* @throws ClientException | ||
*/ | ||
public static SignUpStartCommandParameters createSignUpStartCommandParameters( | ||
@NonNull final NativeAuthPublicClientApplicationConfiguration configuration, | ||
@NonNull final OAuth2TokenCache tokenCache, | ||
@NonNull final String username, | ||
final Map<String, String> userAttributes) { | ||
final NativeAuthCIAMAuthority authority = ((NativeAuthCIAMAuthority) configuration.getDefaultAuthority()); | ||
|
||
return SignUpStartCommandParameters.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) | ||
.username(username) | ||
.challengeType(configuration.getChallengeTypes()) | ||
.clientId(configuration.getClientId()) | ||
.userAttributes(userAttributes) | ||
.build(); | ||
} | ||
|
||
/** | ||
* Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.SignUpStartCommand}] of Native Auth when password is provided | ||
* @param configuration PCA configuration | ||
|
@@ -413,16 +374,16 @@ public static SignUpStartCommandParameters createSignUpStartCommandParameters( | |
* @return Command parameter object | ||
* @throws ClientException | ||
*/ | ||
public static SignUpStartUsingPasswordCommandParameters createSignUpStartUsingPasswordCommandParameters( | ||
public static SignUpStartCommandParameters createSignUpStartCommandParameters( | ||
@NonNull final NativeAuthPublicClientApplicationConfiguration configuration, | ||
@NonNull final OAuth2TokenCache tokenCache, | ||
@NonNull final String username, | ||
@NonNull final char[] password, | ||
@Nullable final char[] password, | ||
final Map<String, String> userAttributes) { | ||
|
||
final NativeAuthCIAMAuthority authority = ((NativeAuthCIAMAuthority) configuration.getDefaultAuthority()); | ||
|
||
return SignUpStartUsingPasswordCommandParameters.builder() | ||
return SignUpStartCommandParameters.builder() | ||
.platformComponents(AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext())) | ||
.applicationName(configuration.getAppContext().getPackageName()) | ||
.applicationVersion(getPackageVersion(configuration.getAppContext())) | ||
|
@@ -583,47 +544,6 @@ public static SignUpSubmitPasswordCommandParameters createSignUpSubmitPasswordCo | |
.build(); | ||
} | ||
|
||
/** | ||
* Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.SignInStartCommand}] of Native Auth. | ||
* @param configuration PCA configuration | ||
* @param tokenCache token cache for storing results | ||
* @param username email address of the user | ||
* @return Command parameter object | ||
* @throws ClientException | ||
*/ | ||
public static SignInStartCommandParameters createSignInStartCommandParameters( | ||
@NonNull final NativeAuthPublicClientApplicationConfiguration configuration, | ||
@NonNull final OAuth2TokenCache tokenCache, | ||
@NonNull final String username) throws ClientException { | ||
final AbstractAuthenticationScheme authenticationScheme = AuthenticationSchemeFactory.createScheme( | ||
AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext()), | ||
null | ||
); | ||
|
||
final NativeAuthCIAMAuthority authority = ((NativeAuthCIAMAuthority) configuration.getDefaultAuthority()); | ||
|
||
final SignInStartCommandParameters commandParameters = SignInStartCommandParameters.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) | ||
.username(username) | ||
.authenticationScheme(authenticationScheme) | ||
.clientId(configuration.getClientId()) | ||
.challengeType(configuration.getChallengeTypes()) | ||
.build(); | ||
|
||
return commandParameters; | ||
} | ||
|
||
/** | ||
* Creates command parameter for [{@link com.microsoft.identity.common.nativeauth.internal.commands.SignInStartCommand}] of Native Auth using username and password | ||
* @param configuration PCA configuration | ||
|
@@ -634,11 +554,11 @@ public static SignInStartCommandParameters createSignInStartCommandParameters( | |
* @return Command parameter object | ||
* @throws ClientException | ||
*/ | ||
public static SignInStartUsingPasswordCommandParameters createSignInStartUsingPasswordCommandParameters( | ||
public static SignInStartCommandParameters createSignInStartCommandParameters( | ||
@NonNull final NativeAuthPublicClientApplicationConfiguration configuration, | ||
@NonNull final OAuth2TokenCache tokenCache, | ||
@NonNull final String username, | ||
@NonNull final char[] password, | ||
@Nullable final char[] password, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same - update comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The password is nullable but is still required as Java does not support default values. Developers have to specify all parameters. |
||
final List<String> scopes) throws ClientException { | ||
final AbstractAuthenticationScheme authenticationScheme = AuthenticationSchemeFactory.createScheme( | ||
AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext()), | ||
|
@@ -647,7 +567,7 @@ public static SignInStartUsingPasswordCommandParameters createSignInStartUsingPa | |
|
||
final NativeAuthCIAMAuthority authority = ((NativeAuthCIAMAuthority) configuration.getDefaultAuthority()); | ||
|
||
final SignInStartUsingPasswordCommandParameters commandParameters = SignInStartUsingPasswordCommandParameters.builder() | ||
final SignInStartCommandParameters commandParameters = SignInStartCommandParameters.builder() | ||
.platformComponents(AndroidPlatformComponentsFactory.createFromContext(configuration.getAppContext())) | ||
.applicationName(configuration.getAppContext().getPackageName()) | ||
.applicationVersion(getPackageVersion(configuration.getAppContext())) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update comment (line 373) to reflect the fact that password is optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The password is nullable but is still required as Java does not support default values. Developers have to specify all parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is only used internally, but Kotlin classes (our state machine). In those cases, this field is optional. We've done the same for e.g.
scopes
parameter in other methods.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java does not have optional parameters. Optional parameters are simulated in Java by overloading functions. As this parameter is in the middle, it wouldn't be good style to overload function with reduced set of parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that this method isn't called from any Java class, and so we don't have to consider the non-optionality of this parameter. You can leave it like this however, that's also fine.