From eadcfff96db9a8b6a1a49dbbea429d6e7f2d1d73 Mon Sep 17 00:00:00 2001 From: shaozhuguang Date: Tue, 17 Sep 2019 18:04:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ump/service/SecurityServiceHandler.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/source/manager/ump-service/src/main/java/com/jd/blockchain/ump/service/SecurityServiceHandler.java b/source/manager/ump-service/src/main/java/com/jd/blockchain/ump/service/SecurityServiceHandler.java index 577e674f..267d154e 100644 --- a/source/manager/ump-service/src/main/java/com/jd/blockchain/ump/service/SecurityServiceHandler.java +++ b/source/manager/ump-service/src/main/java/com/jd/blockchain/ump/service/SecurityServiceHandler.java @@ -49,9 +49,25 @@ public class SecurityServiceHandler implements SecurityService { if (roles.length() > 0) { - - - + securityConfigs.add(propBuild(UmpConstant.SECURITY_ROLES, roles)); + + String[] rolesArray = roles.split(","); + for (String role : rolesArray) { + String roleRealm = role.trim(); + String roleLedgerKey = String.format(UmpConstant.SECURITY_ROLES_PRIVILEGES_LEDGER_FORMAT, roleRealm); + String roleLedgerValue = currentProps.getProperty(roleLedgerKey, ""); + securityConfigs.add(propBuild(roleLedgerKey, roleLedgerValue)); + + String roleTxKey = String.format(UmpConstant.SECURITY_ROLES_PRIVILEGES_TX_FORMAT, roleRealm); + String roleTxValue = currentProps.getProperty(roleTxKey, ""); + securityConfigs.add(propBuild(roleTxKey, roleTxValue)); + } + } else { + throw new IllegalStateException("Can not find Properties from security.config"); } } + + private String propBuild(String key, String value) { + return key + "=" + value; + } }