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

#30 Duplicate the jersey module to "jersey" for 2.26 and "jersey-225" for 2.25 #40

Merged
merged 2 commits into from
Apr 14, 2018

Conversation

pierre-l
Copy link
Contributor

See #30, #36.


public static class Binder extends AbstractBinder {

private final ProfileFactoryBuilder profile;
private final OptionalProfileFactoryBuilder optProfile;
private final ProfileManagerFactoryBuilder manager;
private ProfileManagerFactoryBuilder manager;
Copy link
Member

Choose a reason for hiding this comment

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

this should still be final I think

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 it should. I'll fix this.

@Context
Providers providers;
private Providers providers;
Copy link
Member

Choose a reason for hiding this comment

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

this could be final now that there is a constructor to initialise it

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 it could, and it will :)

}
}

static class ProfileValueFactory extends AbstractContainerRequestValueFactory<CommonProfile>
implements ProfileFactory {
static class OptionalProfileValueFactory implements OptionalProfileFactory {
Copy link
Member

Choose a reason for hiding this comment

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

any reason why you don't rely on injection here to get the request instead of making it explicit in the interface?
I liked the idea of having an interface agnostic to the where the request was coming from… but maybe it's not possible anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, the main reason is that I could not find a way to make it work. A secondary reason is that the origin of the request as a parameter comes directly from the AbstractValueParamProvider.
To me it felt like the way to go, but I'm no expert.

Copy link
Member

Choose a reason for hiding this comment

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

indeed it seems a good idea to reuse the request instead of having it injected.

btw I see you corrected the few things I noted in the other PR but not in this one

static class OptionalProfileValueFactory extends AbstractContainerRequestValueFactory<Optional<CommonProfile>>
implements OptionalProfileFactory {
private static Optional<CommonProfile> optionalProfile(ContainerRequest containerRequest) {
RequestPac4JSecurityContext securityContext = new RequestPac4JSecurityContext(containerRequest.getSecurityContext());
Copy link
Member

Choose a reason for hiding this comment

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

I think you should be able to write: new RequestPac4JSecurityContext(containerRequest)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, thanks!

this.profile = profile == null ? ProfileValueFactory::new : profile;
this.optProfile = optProfile == null ? OptionalProfileValueFactory::new : optProfile;
this.manager = manager == null ? ProfileManagerValueFactory::new : manager;
this.manager = manager;
Copy link
Member

Choose a reason for hiding this comment

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

why don't you do the same as with profile and optProfile and initialize manager here?

Copy link
Contributor Author

@pierre-l pierre-l Apr 11, 2018

Choose a reason for hiding this comment

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

Because if the manager is not specified I wanted it to be injected. This would avoid the need for a Pac4J user to inject everything in the Feature and then having to pass it all to the Binder constructor.
It doesn't feel ideal to me because now the manager is special compared to the profile and optProfile, but I thought of it as of a good compromise.

Copy link
Member

Choose a reason for hiding this comment

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

The user shouldn't be using the Binder with parameters but only the binder without parameters.
And anyway, in any case, the constructor didn't change so I'm not sure what you mean ^^

Let's keep it like this, if it works it's ok, we will have other occasions to clean that, I'm pretty sure there is a lot that can be done for this class...

@victornoel victornoel merged commit b2b3b3c into pac4j:master Apr 14, 2018
@victornoel
Copy link
Member

thanks @pierre-l and sorry for the delay :)

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