mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 14:33:09 +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:
@@ -62,19 +62,20 @@ public class HandleIdentifierProvider extends IdentifierProvider {
|
|||||||
|| identifier.startsWith(canonicalPrefix)
|
|| identifier.startsWith(canonicalPrefix)
|
||||||
|| identifier.startsWith("hdl:")
|
|| identifier.startsWith("hdl:")
|
||||||
|| identifier.startsWith("info:hdl")
|
|| identifier.startsWith("info:hdl")
|
||||||
|| identifier.matches("^https?://hdl.handle.net/")
|
|| identifier.matches("^https?://hdl\\.handle\\.net/.*")
|
||||||
|| identifier.matches("^https?://.+/handle/"))
|
|| identifier.matches("^https?://.+/handle/.*"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// return false if identifier starts with DOI prefix
|
// return true if base prefix matches in case of multi-instance deployment with derived prefixes demarcated by a dot "."
|
||||||
if(identifier.startsWith("10.") || identifier.matches("^https?://dx.doi.org") || identifier.startsWith("doi:"))
|
if(prefix.contains(".")) {
|
||||||
return false;
|
String[] splitPrefix = prefix.split("\\.");
|
||||||
// return false if identifier does not contain a '/' or is a URL that does not match above patterns
|
if(splitPrefix.length > 1 && identifier.startsWith(splitPrefix[0])) {
|
||||||
if(! identifier.contains("/") || identifier.matches("^https?://.+"))
|
return true;
|
||||||
return false;
|
}
|
||||||
// otherwise, assumed a valid handle
|
}
|
||||||
return true;
|
// otherwise, assume invalid handle
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -82,19 +82,20 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
|
|||||||
|| identifier.startsWith(canonicalPrefix)
|
|| identifier.startsWith(canonicalPrefix)
|
||||||
|| identifier.startsWith("hdl:")
|
|| identifier.startsWith("hdl:")
|
||||||
|| identifier.startsWith("info:hdl")
|
|| identifier.startsWith("info:hdl")
|
||||||
|| identifier.matches("^https?://hdl.handle.net/")
|
|| identifier.matches("^https?://hdl\\.handle\\.net/.*")
|
||||||
|| identifier.matches("^https?://.+/handle/"))
|
|| identifier.matches("^https?://.+/handle/.*"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// return false if identifier starts with DOI prefix
|
// return true if base prefix matches in case of multi-instance deployment with derived prefixes demarcated by a dot "."
|
||||||
if(identifier.startsWith("10.") || identifier.matches("^https?://dx.doi.org") || identifier.startsWith("doi:"))
|
if(prefix.contains(".")) {
|
||||||
return false;
|
String[] splitPrefix = prefix.split("\\.");
|
||||||
// return false if identifier does not contain a '/' or is a URL that does not match above patterns
|
if(splitPrefix.length > 1 && identifier.startsWith(splitPrefix[0])) {
|
||||||
if(! identifier.contains("/") || identifier.matches("^https?://.+"))
|
return true;
|
||||||
return false;
|
}
|
||||||
// otherwise, assumed a valid handle
|
}
|
||||||
return true;
|
// otherwise, assume invalid handle
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -78,19 +78,20 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
|
|||||||
|| identifier.startsWith(canonicalPrefix)
|
|| identifier.startsWith(canonicalPrefix)
|
||||||
|| identifier.startsWith("hdl:")
|
|| identifier.startsWith("hdl:")
|
||||||
|| identifier.startsWith("info:hdl")
|
|| identifier.startsWith("info:hdl")
|
||||||
|| identifier.matches("^https?://hdl.handle.net/")
|
|| identifier.matches("^https?://hdl\\.handle\\.net/.*")
|
||||||
|| identifier.matches("^https?://.+/handle/"))
|
|| identifier.matches("^https?://.+/handle/.*"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// return false if identifier starts with DOI prefix
|
// return true if base prefix matches in case of multi-instance deployment with derived prefixes demarcated by a dot "."
|
||||||
if(identifier.startsWith("10.") || identifier.matches("^https?://dx.doi.org") || identifier.startsWith("doi:"))
|
if(prefix.contains(".")) {
|
||||||
return false;
|
String[] splitPrefix = prefix.split("\\.");
|
||||||
// return false if identifier does not contain a '/' or is a URL that does not match above patterns
|
if(splitPrefix.length > 1 && identifier.startsWith(splitPrefix[0])) {
|
||||||
if(! identifier.contains("/") || identifier.matches("^https?://.+"))
|
return true;
|
||||||
return false;
|
}
|
||||||
// otherwise, assumed a valid handle
|
}
|
||||||
return true;
|
// otherwise, assume invalid handle
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user