在启用LDAP的情况下,无法使用加密密码部署工件

时间:2016-05-25 09:42:50

标签: maven maven-3 artifactory

我们正在使用Artifactory Version 4.7.0。我已经为Artifactory配置了LDAP,我能够成功登录。当我尝试使用加密密码来部署工件时,它无法正常工作。在Artifacts选项卡中,我点击“Set Me Up”并在输入我的凭据后生成Maven设置。然后我下载了settings.xml文件,其中包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://artifactory:9090/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://artifactory:9090/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://artifactory:9090/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://artifactory:9090/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

然后我转到我的个人资料,输入密码并复制加密密码,如下所示:

enter image description here

我在settings.xml中复制了此密码,如下所示:

    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"AP6FcvsVawZhcfEdZB2PCTrCUZa"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>  
      <password>${security.getEscapedEncryptedPassword()!"AP6FcvsVawZhcfEdZB2PCTrCUZa"}</password>
      <id>snapshots</id>
    </server>

然后当我尝试部署工件时,我收到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project more-maven-examples: Failed to deploy artifac
ts: Could not transfer artifact com.infiniteskills.maven:more-maven-examples:jar:1.0 from/to central (http://artifactory:9090/libs-release-local):
Failed to transfer file: http://artifactory:9090/libs-release-local/com/infiniteskills/maven/more-maven-examples/1.0/more-maven-examples-1.0.jar. R
eturn code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

request.log 文件中输入失败的尝试:

20160525143037|9526|REQUEST|10.20.55.124|non_authenticated_user|PUT|/libs-release-local/com/infiniteskills/maven/more-maven-examples/1.0/more-maven-examples-1.0.jar|HTTP/1.1|401|2981
20160525143037|2|REQUEST|10.20.55.124|non_authenticated_user|PUT|/libs-release-local/com/infiniteskills/maven/more-maven-examples/1.0/more-maven-examples-1.0.pom|HTTP/1.1|401|1235

安全&gt;一般&gt;密码加密策略设置为SUPPORTED。此外,密码加密设置为加密。

令人惊讶的是,当我在同一个<server>块的settings.xml文件中硬编码我的名字和LDAP密码时,它可以正常工作。

我做错了什么或是个错误?

2 个答案:

答案 0 :(得分:2)

<password/>部分应该是这样的:

<password>{COQLCE6DU6GtcS5P=}</password>

查看Maven Encryption Guide

答案 1 :(得分:1)

用您的凭据替换整行

<username>actual-username-here</username>  
<password>your-encrypted-password-here</password>

现在尝试过。可以请客。