Skip to content

Commit e9d4739

Browse files
Wdt 822 discover roles (#980)
* discover global roles * Update domain_info_discoverer.py * Update TypeUtils.java
1 parent 8eb89cc commit e9d4739

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

core/src/main/java/oracle/weblogic/deploy/aliases/TypeUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,10 @@ private static char[] convertToCharArray(String strValue) {
270270

271271
public static Object[] convertToObjectArray(Object value, String strValue, String delimiter)
272272
throws AliasException {
273-
System.out.println("I am in the method" + strValue);
274273
Object[] result;
275274
if (Object[].class.isAssignableFrom(value.getClass())) {
276-
System.out.println("is assignable " + strValue);
277275
result = Object[].class.cast(value);
278276
} else if (value instanceof List) {
279-
System.out.println("Is instance of List");
280277
List list = (List) value;
281278
if (!list.isEmpty()) {
282279
//thanks to Java Generics type erasure in List, need to get element type from list element
@@ -289,7 +286,6 @@ public static Object[] convertToObjectArray(Object value, String strValue, Strin
289286
result = null;
290287
}
291288
} else {
292-
System.out.println("Not anything but a string " + strValue);
293289
result = convertStringToList(strValue, delimiter).toArray(new String[0]);
294290
}
295291
LOGGER.fine("before convert {0} and after convert {1}", value, result);

core/src/main/python/wlsdeploy/tool/discover/domain_info_discoverer.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import glob
@@ -23,7 +23,18 @@
2323
_class_name = 'DomainInfoDiscoverer'
2424
_logger = PlatformLogger(discoverer.get_discover_logger_name())
2525

26+
ROLE_NAME_LIST = {
27+
"AppTester": '?weblogic.entitlement.rules.OwnerIDDGroup(AppTesters)',
28+
'Operator': '?weblogic.entitlement.rules.AdministrativeGroup(Operators)',
29+
'Admin': '?weblogic.entitlement.rules.AdministrativeGroup(Administrators)',
30+
'Deployer': '?weblogic.entitlement.rules.AdministrativeGroup(Deployers)',
31+
'Monitor': '?weblogic.entitlement.rules.AdministrativeGroup(Monitors)',
32+
'OracleSystemRole': 'Grp(OracleSystemGroup)',
33+
'CrossDomainConnector': '?weblogic.entitlement.rules.OwnerIDDGroup(CrossDomainConnectors)',
34+
'Anonymous': 'Grp(everyone)',
35+
'AdminChannelUser': '?weblogic.entitlement.rules.OwnerIDDGroup(AdminChannelUsers)'
2636

37+
}
2738
class DomainInfoDiscoverer(Discoverer):
2839
"""
2940
Discover extra information about the domain. This information is not what is stored in domain
@@ -48,6 +59,8 @@ def discover(self):
4859
discoverer.add_to_model_if_not_empty(self._dictionary, model_top_folder_name, result)
4960
model_top_folder_name, result = self.get_user_env_scripts()
5061
discoverer.add_to_model_if_not_empty(self._dictionary, model_top_folder_name, result)
62+
model_top_folder_name, result = self.get_roles()
63+
discoverer.add_to_model_if_not_empty(self._dictionary, model_top_folder_name, result)
5164
_logger.exiting(class_name=_class_name, method_name=_method_name)
5265
return self._dictionary
5366

@@ -124,3 +137,35 @@ def get_user_env_scripts(self):
124137

125138
_logger.exiting(class_name=_class_name, method_name=_method_name, result=entries)
126139
return model_constants.DOMAIN_SCRIPTS, entries
140+
141+
def get_roles(self):
142+
_method_name = 'get_roles'
143+
_logger.entering(class_name=_class_name, method_name=_method_name)
144+
model = dict()
145+
model_folder = model_constants.WLS_ROLES
146+
if self._wlst_mode == WlstModes.ONLINE:
147+
props=[]
148+
149+
cmo = self._wlst_helper.get_cmo()
150+
realms = cmo.getSecurityConfiguration().getRealms()
151+
for r in realms:
152+
rms=r.getRoleMappers()
153+
for rm in rms:
154+
if rm.getName() == 'XACMLRoleMapper':
155+
c=rm.listAllRoles(500)
156+
157+
while rm.haveCurrent(c):
158+
props.append(rm.getCurrentProperties(c))
159+
rm.advance(c)
160+
rm.close(c)
161+
162+
for entry in props:
163+
if 'RoleName' in entry and entry['RoleName'] != '**':
164+
role_name = entry['RoleName']
165+
role_expression = entry['Expression']
166+
if role_name not in ROLE_NAME_LIST or ROLE_NAME_LIST[role_name] != role_expression:
167+
# put it in the model
168+
model[role_name] = dict()
169+
model[role_name][model_constants.EXPRESSION] = role_expression
170+
return model_folder, model
171+

0 commit comments

Comments
 (0)