Skip to content
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

Most of Second PR #2

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Most of Second PR #2

wants to merge 9 commits into from

Conversation

lyzhang27
Copy link

No description provided.

@lyzhang27 lyzhang27 requested a review from manu-sinha May 2, 2018 21:05
@@ -0,0 +1,208 @@
package com.auth0.msg;

Choose a reason for hiding this comment

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

You haven't refactored for package name?

Copy link
Author

Choose a reason for hiding this comment

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

TODO

import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.charset.StandardCharsets;
import java.util.*;

Choose a reason for hiding this comment

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

Please add sepcific import.

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link

@manu-sinha manu-sinha left a comment

Choose a reason for hiding this comment

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

  • Javadocs are missing from many classes/methods
  • Lot of methods are empty

private String input;
private Error error = null;
private boolean verified = false;
ObjectMapper mapper = new ObjectMapper();

Choose a reason for hiding this comment

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

does this need to be protected?

Copy link
Author

Choose a reason for hiding this comment

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

done

* @throws InvalidClaimsException
*/
public String toJwt(Key key, Algorithm algorithm) throws InvalidClaimsException, SerializationException {
return null;

Choose a reason for hiding this comment

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

implementation?

Copy link
Author

Choose a reason for hiding this comment

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

noted

Copy link
Author

Choose a reason for hiding this comment

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

done

}
}
if (!errors.isEmpty()) {
String aggregateError = "";

Choose a reason for hiding this comment

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

please reuse errorSB instead of aggregateError.

Copy link
Author

Choose a reason for hiding this comment

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

done

* verify that the required claims are present
* @return whether the verification passed
*/
protected boolean verify() {

Choose a reason for hiding this comment

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

The method signature should tell that this method can throw InvalidClaimsException so that caller can appropriately handle failed validation.

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link
Author

Choose a reason for hiding this comment

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

done


if (errorSB.length() != 0) {
errors.add("Message is missing required claims:" + errorSB.toString());
return false;

Choose a reason for hiding this comment

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

This doesn't help - you are adding errors but not returning.

Copy link
Author

Choose a reason for hiding this comment

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

Modified to put error messages into the InvalidClaimException thrown at the end which should be handled upstream and also update the instance of Error object

Copy link
Author

Choose a reason for hiding this comment

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

Corrected

public class ECKeyDefinition extends KeyDefinition {
private String crv;

public ECKeyDefinition(KeyType type, KeyUseCase useCase, String crv) {

Choose a reason for hiding this comment

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

Please explain each of the parameters.

Copy link
Author

Choose a reason for hiding this comment

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

done

/**
* A runtime exception that is thrown when there is an invalid claim in a Message object type
*/
public class InvalidClaimsException extends RuntimeException {

Choose a reason for hiding this comment

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

Extending RuntimeException is not right. You should extend Exception. This should be a checked exception so that caller can handle and recover from this.

Copy link
Author

Choose a reason for hiding this comment

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

Done


import java.util.List;
import java.util.Map;

Choose a reason for hiding this comment

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

Please provide Javadoc

Copy link
Author

Choose a reason for hiding this comment

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

TODO


@Override
public boolean hasError() {
return false;

Choose a reason for hiding this comment

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

why are you overriding hasError and always returning false? What happens when verify fails? If this is a special scenario please provide javadoc to explain that.

Copy link
Author

Choose a reason for hiding this comment

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

Corrected

@@ -0,0 +1,87 @@
package com.auth0.msg;

Choose a reason for hiding this comment

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

In abstract message, i have suggested some changes to methods, please make the same changes to interface.

Copy link
Author

Choose a reason for hiding this comment

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

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants