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

CADC-8776 check the doiadmin cert owns the DOI parent node #7

Merged
merged 7 commits into from
Oct 24, 2024

Conversation

jburke-cadc
Copy link
Collaborator

No description provided.

params.put("doiMetadata", fileContent);
}
if (StringUtil.hasText(journalRef)) {
params.put("journalref", journalRef == null ? "" : journalRef);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can journalRef == null happen inside if

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is one test where the journalRef is null, but the IF condition negates journalRef from being null in the IF. Still that check and set of the journalRef isn't right. It's okay for the current int tests, but you should be able to post a journalRef with an empty value, which translates in the PostAction to deleting the existing journalRef. You can't post an empty journalReg with that test method. Checking that the journalRef is not null before adding it as a parameter is all that's needed. Fixed.

URI vospaceResourceID = URI.create(config.getFirstPropertyValue(DoiInitAction.VAULT_RESOURCE_ID_KEY));
String parentPath = config.getFirstPropertyValue(PARENT_PATH_KEY);

Subject adminSubject = SSLUtil.createSubject(new File("/config/doiadmin.pem"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe the README should mention the exact location where the certs are expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would be helpful, fixed.

VOSpaceClient vosClient = new VOSpaceClient(vospaceResourceID);
String currentPath = "";
String[] paths = parentPath.split("/");
for (String path : paths) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this recursive checking required? It is performed on the server side as well and reported back to the client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good question. We use two container nodes as the root for the DOI's: /AstroDataCitationDOI/CISTI.CANFAR, but the owner and permissions only matter on the second node. I do remember something about why two parent nodes, and why owner and permissions matter for both, but I can't find any reference. Tempted to change that check for only the second parent node, but I'll leave it until I'm more sure. Added a TODO there so I don't forget.

}
}

private static String getUsername(Subject subject) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm. This is almost like AuthenticationUtil.getUseridsFromSubject() but not quite...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah close, but just not quite.

@@ -127,7 +126,7 @@ private Title getTitle(Resource resource) {
Title title = null;
List<Title> titles = resource.getTitles();
for (Title t : titles) {
if (t.titleType == null) {
if (StringUtil.hasText(t.getValue())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So titleType is a but.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

titleType is optional, but the title value went from empty not allowed in the old schema, to empty allowed in the new schema. We don't want empty titles, hence the check. Don't know why it was checking for an optional attribute previously, doesn't make sense.

log.debug("content: " + content);
InputStream inputStream = new ByteArrayInputStream(content.getBytes());

// upload
HttpUpload put = new HttpUpload(inputStream, doiURL);
put.setRequestProperty("Authorization", "Basic " + Base64.encodeString(getCredentials()));
put.setBufferSize(64 * 1024);
put.setContentType("text/plain;charset=UTF-8");
put.run();
put.setRequestProperty("Content-Type", "text/plain;charset=UTF-8");
Copy link
Collaborator

Choose a reason for hiding this comment

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

HttpTransfer.CONTENT_TYPE?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Works for me.

try {
groupsURI = localAuthority.getServiceURI(Standards.GMS_SEARCH_10.toString());
Set<URI> groupsURIs = localAuthority.getServiceURIs(Standards.GMS_SEARCH_10);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure why you need the GMS configured in the doi.properties when you use the one in cadc-registry.properties. Am I missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the GMS configuration, no longer needed. Removed the int test properties file, and added a intTest README to explain the int test setup.

@jburke-cadc jburke-cadc merged commit 27b8c8a into opencadc:main Oct 24, 2024
1 check passed
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