Maven在POM中使用加密密码 [英] Maven use Encrypted passwords in POM

查看:1530
本文介绍了Maven在POM中使用加密密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Maven 3中使用pom.xml中的加密密码?

How can I use encrypted password in pom.xml with maven 3?

我有一些pom使用对我们来说非常微妙的密码,例如,我们可以将POM部署在Weblogic之类的应用程序服务器中或在数据库中运行Scripts,我们不希望仅将密码放在其中是.

I have some pom that use password that are very delicated for us, for example we have POM to deploy in Application servers such as Weblogic or run Scripts in the database, and we don't like to just put the password as it is.

我已经具有部署工件的主密码.

I already have the master password for deployment artifacts.

我在考虑是否有生成密码的方法:

I am thinking if there is a way for example to generate a password:

$ mvn --encrypt-password somepass
{wGpHaPO3nJ4HSKJa7qcMK9qjHAdwlvMrtjYjj8bwguI=}

然后我可以用这种方式在某些pom中使用它吗?

And after that Can I use it in some pom in this way:

<configuration>
              <driver>oracle.jdbc.driver.OracleDriver</driver>
              <url>jdbc:oracle:thin:@ordbsdev.siman.com:1521:RMSDEV</url>
              <username>${siman.rms13.db.user}</username>
              <password>{wGpHaPO3nJ4HSKJa7qcMK9qjHAdwlvMrtjYjj8bwguI=}</password>
</configuration>

此外,我希望能有其他选择.

Also, I would appreciate an alternative to do it.

推荐答案

我认为Tunaki要求您执行的操作是在

I think what Tunaki is asking you to do is to define a property in your settings.xml, e.g.

<settings ...

  <profile>
    ...
    <properties>
      <xyz>{wGpHaPO3nJ4HSKJa7qcMK9qjHAdwlvMrtjYjj8bwguI=}</xyz>
    </properties>
  <profile>
</setting>

然后使用您在POM中的设置使用此属性:

Then use this property from your settings in your POM:

<configuration>
  ...
  <password>${xyz}</password>
</configuration>

但是读取此配置的工具必须能够解密密码.

But the tool reading this configuration has to be capable to decrypt the password.

最好将加密的密码和服务器配置存储在您的settings.xml中,如下所示:

Even better would be to store the encrypted password with a server configuration in your settings.xml like this:

<settings ...
  ...
  <servers>
    ...
    <server>
      <id>xyz</id>
      <username>manager</username>
      <password>{wGpHaPO3nJ4HSKJa7qcMK9qjHAdwlvMrtjYjj8bwguI=}</password>
    </server>
    ...
  </servers>
  ...
</setting>

但是同样,配置信息的使用者必须能够读取服务器配置.在 https://maven.apache.org上有一个Maven部署插件的示例. /guides/mini/guide-encryption.html (例如-DrepositoryId = xyz).

But again, the consumer of your configuration information has to be capable of reading server configurations. There is an example for the Maven Deploy Plugin at https://maven.apache.org/guides/mini/guide-encryption.html (e.g. -DrepositoryId=xyz).

所引用的问题列出了 SqlExecMojo 作为插件如何解密密码的示例.

The referenced question lists the SqlExecMojo as an example on how plugins decrypt passwords.

这篇关于Maven在POM中使用加密密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆