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

Add SecurityDomainService to Job v2 APIs #4805

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

fmarco76
Copy link
Member

No description provided.

@fmarco76 fmarco76 requested a review from edewata July 19, 2024 17:21
Copy link
Contributor

@edewata edewata left a comment

Choose a reason for hiding this comment

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

I have some comments but feel free to merge as is.

Comment on lines 48 to 51
public AuditServletBase(CMSEngine engine, String username) {
this.engine = engine;
this.userName = username;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a concern now, but this means for each request we need to create a new AuditServletBase instance (which is what the current code does):

auditServlet = new AuditServletBase(getEngine(), request.getUserPrincipal().getName());
auditConfigNew = auditServlet.updateAuditConfig(auditConfig);

If there is a lot of requests it might be more efficient to reuse the existing instance:

init() {
    auditServlet = new AuditServletBase(getEngine());
}
updateAuditConfig() {
    auditConfigNew = auditServlet.updateAuditConfig(request.getUserPrincipal().getName(), auditConfig);
}

Just something to consider for future improvement.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I have follow this approach in all the services because the initial design, without annotation, was differently organised. I think there is room for this optimisation in several services but not all since in same cases the initialisation requires information provided by the request (e.g. SecurityDomainServletBase require the locale) and need additional work.
I'll do this optimisation in separate PR.

* @author Marco Fargetta {@literal <[email protected]>}
* @author alee
*/
public class SecurityDomainServletBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future we might be able to merge SecurityDomainServletBase and SecurityDomainProcessor.

@@ -189,7 +158,7 @@ public Method getActionMethod(HttpMethod met, String path) {
}
String keyPath = webActions.keySet().stream().
filter( key -> {
String keyRegex = key.replace("{}", "([A-Za-z0-9_\\-]+)");
String keyRegex = key.replace("{}", "([A-Za-z0-9_\\-\\.\\\s]+)");
Copy link
Contributor

Choose a reason for hiding this comment

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

Theoretically a URL path could also contain non-ASCII characters, so this might not be sufficient. Should we use something like ([^\/]+)?

Copy link
Member Author

@fmarco76 fmarco76 Jul 22, 2024

Choose a reason for hiding this comment

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

Yes, I was looking at old URL specification not considering non ASCII. I have updated to get everything until / following your comment since there is no need to verify which characters are in the path, the URL should already be validated by tomcat.

@fmarco76
Copy link
Member Author

@edewata Thanks!

@fmarco76 fmarco76 merged commit ae45377 into dogtagpki:master Jul 22, 2024
145 of 155 checks passed
@fmarco76 fmarco76 deleted the SecurityDomainService_v2 branch July 22, 2024 09:10
Copy link

sonarcloud bot commented Jul 22, 2024

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