mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 10:34:25 +00:00
More restrictive handle definitions
As per request by pnbecker and tdonahue, reworking supports() method to be more restrictive in its handle validation while also still allowing support for multi-instance environments with derived handles. Now, if a handle does not match one of the currently known DSpace handle provider formats, it will be rejected.
This commit is contained in:
@@ -82,19 +82,20 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
|
||||
|| identifier.startsWith(canonicalPrefix)
|
||||
|| identifier.startsWith("hdl:")
|
||||
|| identifier.startsWith("info:hdl")
|
||||
|| identifier.matches("^https?://hdl.handle.net/")
|
||||
|| identifier.matches("^https?://.+/handle/"))
|
||||
|| identifier.matches("^https?://hdl\\.handle\\.net/.*")
|
||||
|| identifier.matches("^https?://.+/handle/.*"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// return false if identifier starts with DOI prefix
|
||||
if(identifier.startsWith("10.") || identifier.matches("^https?://dx.doi.org") || identifier.startsWith("doi:"))
|
||||
return false;
|
||||
// return false if identifier does not contain a '/' or is a URL that does not match above patterns
|
||||
if(! identifier.contains("/") || identifier.matches("^https?://.+"))
|
||||
return false;
|
||||
// otherwise, assumed a valid handle
|
||||
return true;
|
||||
// return true if base prefix matches in case of multi-instance deployment with derived prefixes demarcated by a dot "."
|
||||
if(prefix.contains(".")) {
|
||||
String[] splitPrefix = prefix.split("\\.");
|
||||
if(splitPrefix.length > 1 && identifier.startsWith(splitPrefix[0])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// otherwise, assume invalid handle
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user