如何使用Gradle在Corda中为每个节点配置安全性?

时间:2018-08-01 15:10:14

标签: corda

我想使用Gradle将安全性属性添加到我的节点配置中。我正在尝试执行以下操作:

node {
name "O=Bank_A,L=New York,C=US"
p2pPort 10005
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
h2Port 9005
cordapps = [
"$project.group:bank-abc:$project.version",
"$project.group:shared-contracts-states:$project.version",
"$corda_release_group:corda-finance:$corda_release_version"
]

security = {
   authService = {
      dataSource = {
         type = "DB"
         passwordEncryption = "SHIRO_1_CRYPT"
         connection = {
             jdbcUrl = "jdbc:h2:tcp://10.0.75.1:9014/node"
             username = "some user"
             password = "some pass"
             driverClassName = "org.h2.Driver"
             }
          }
       }
    }
}

当我执行gradlew deployNodes时。我收到以下错误:

  • 出了什么问题:

评估根项目'tbs-term-reciprocal-dapp'时出现问题。

  

无法为net.corda.plugins.Node类型的对象设置未知属性“ security”。

1 个答案:

答案 0 :(得分:2)

为了添加安全性配置,您需要在节点的Gradle脚本中使用extraConfig。

以您的示例为例,extraConfig将如下所示:

extraConfig = [
    security : [
        authService : [
            dataSource : [
                type: "DB",
                passwordEncryption: "SHIRO_1_CRYPT",
                connection : [
                    jdbcUrl: "jdbc:h2:tcp://10.0.75.1:9014/node",
                    username: "sa",
                    password: "",
                    driverClassName: "org.h2.Driver"
                ]
            ]
        ]
    ]
]