Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Conversation

@palimpsestor
Copy link
Contributor

@palimpsestor palimpsestor commented Jan 11, 2017

resolves #1211

…from OAuthExceptions.

@dogeared dogeared added this to the 1.3.1 milestone Jan 12, 2017
@dogeared dogeared changed the base branch from master to 1.3.x January 12, 2017 21:08
/**
* Constructs {@link OAuthStormpathFactorChallengeGrantRequestAuthenticator}s.
*
* @since 1.1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.3.1

@dogeared
Copy link
Member

seems like a few new classes/interfaces in here. Add some new tests?

@mrioan mrioan self-assigned this Jan 14, 2017
Copy link
Contributor

@mrioan mrioan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palimpsestor I provided a few comments. Back to you

catch (ResourceException re) {
assertEquals(re.getStatus(), 400)
assertEquals(re.getCode(), 13104)
assertEquals("The code submitted is not valid.", re.getDeveloperMessage())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palimpsestor We do not assert messages any longer, doing that has caused tests to begin to fail out of the blue since the the backend sometimes change them. Code and Status must be asserted since they are part of the "contract"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed that assertion.

private static final int KEY_MODULUS = (int) Math.pow(10, CODE_DIGITS);
private static final int CODE_DIGITS = 6;

private static int calculateCode(byte[] key, long tm) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palimpsestor Could you please add a comment here explaining what this function does? It seems that eventually we might need to reduce this logic but it will be difficult to achieve that without first understanding what this does. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment, and went ahead and simplified this method a bit. This is roughly identical to what we use on the IAM side when verifying a challenge to a Google Authenticator factor.

private static final ObjectMapper objectMapper;

static {
objectMapper = new ObjectMapper();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be initialized in line 30?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

}

json += "}";
public OAuthException(OAuthErrorCode code, Map<String, Object> error, String message) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this constructor to line 59 so all the constructors are together?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (action instanceof String) {
// get action map from error based on the action
Map<String, Object> errorMap = new LinkedHashMap<>();
errorMap.put("error_description", defaultError.getProperty("error_description"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't all this hardcoded properties being exposed in a single place as constants in order to be referenced here? This will help both avoid typos and avoid issues if any property is changed in the future

@@ -0,0 +1,14 @@
package com.stormpath.sdk.oauth;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license header

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@@ -0,0 +1,9 @@
package com.stormpath.sdk.oauth;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license header

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

/**
* @since 1.3.1
*/
public interface OAuthStormpathFactorChallengeGrantRequestAuthenticator extends OAuthRequestAuthenticator<OAuthGrantRequestAuthenticationResult> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a short description to this interface, developers will be seeing this interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@@ -0,0 +1,7 @@
package com.stormpath.sdk.oauth;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license header

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

/**
* @since 1.3.1
*/
public interface OAuthStormpathFactorChallengeGrantRequestAuthenticatorFactory extends OAuthRequestAuthenticatorFactory<OAuthStormpathFactorChallengeGrantRequestAuthenticator> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a short description to this interface, developers will be seeing this interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@mrioan mrioan assigned palimpsestor and unassigned mrioan Jan 14, 2017
@mrioan
Copy link
Contributor

mrioan commented Jan 14, 2017

@palimpsestor Travis is failing with this error: NoClassDefFoundError: Could not initialize class com.stormpath.sdk.oauth.Authenticators. It does not look like a legit problem because that class really exists. I will re-execute that job now.

@mrioan
Copy link
Contributor

mrioan commented Jan 14, 2017

@palimpsestor. Approved. Merging now

@mrioan mrioan merged commit 8c11022 into 1.3.x Jan 14, 2017
@mrioan mrioan deleted the Issue-1211-mfa-policy-support branch January 14, 2017 10:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants