NexusTargetMappingAuthorizationFilter

NexusTargetMappingAuthorizationFilter

我有一个奇怪的(对我来说):使用 Nexus 2.11.4-01 和另一个软件 (Talend) 正在与之交互。 当 Talend 尝试与 Nexus 对话时,它会抛出一个错误,看起来它正试图点击 http://servername:8081/nexus/service/local/repositories/scratch/content 形式的 URL,当使用 Chrome 浏览时会抛出 403。 Nexus 日志显示:

2015-09-07 15:47:30,396+0000 WARN  [qtp131312334-65] admin org.sonatype.nexus.security.filter.authz.NexusTargetMappingAuthorizationFilter - Cannot translate request to Nexus repository path, expected pattern /service/local/repositories/([^/]*)/content/(.*), request: GET http://servername:8081/nexus/service/local/repositories/scratch/content

对于我尝试的任何回购,现在 "scratch" 应该与此处的模式和来源匹配(诚然对于 Nexus 2.11.3),我通过一些谷歌搜索发现它也应该有效: http://grepcode.com/file/repo1.maven.org/maven2/org.sonatype.nexus/nexus-core/2.11.3-01/org/sonatype/nexus/security/filter/authz/NexusTargetMappingAuthorizationFilter.java

  private String getResourceStorePath(final ServletRequest request) {
    String path = WebUtils.getPathWithinApplication((HttpServletRequest) request);
    if (getPathPrefix() != null) {
      final Pattern p = getPathPrefixPattern();
      final Matcher m = p.matcher(path);
      if (m.matches()) {
        path = getPathReplacement();
        // TODO: hardcoded currently
        if (path.contains("@1")) {
          path = path.replaceAll("@1", Matcher.quoteReplacement(m.group(1)));
        }
        if (path.contains("@2")) {
          path = path.replaceAll("@2", Matcher.quoteReplacement(m.group(2)));
        }
        // and so on... this will be reworked to be dynamic
      }
      else {
        // what happens here: router requests are formed as: /KIND/ID/REPO_PATH
        // where KIND = {"repositories", "groups", ...}, ID is a repo ID, and REPO_PATH is a repository path
        // being here, means we could not even match anything of these, usually having newline in string
        // as that's the only thing the "dotSTAR" regex would not match (it would match any other character)
        log.warn(formatMessage(request, "Cannot translate request to Nexus repository path, expected pattern {}"), p);
        return null;
      }
    }

    return path;
  }

所以我的问题是我做错了什么,我错过了什么?

解决方案是 Talend 5.6 附带的 Nexus 版本(并且它被编写为与之交互)非常古老,而较新版本的 Nexus 使用不同的接口。