|
19 | 19 | import com.google.common.collect.ComparisonChain;
|
20 | 20 | import com.novell.ldap.LDAPAttribute;
|
21 | 21 | import com.novell.ldap.LDAPEntry;
|
| 22 | +import com.novell.ldap.util.ByteArray; |
22 | 23 | import com.tremolosecurity.myvd.dataObj.ClusterInfo;
|
23 | 24 | import com.tremolosecurity.myvd.dataObj.RoleInfo;
|
24 | 25 | import com.tremolosecurity.provisioning.core.ProvisioningException;
|
@@ -142,6 +143,70 @@ public int compare(RoleInfo o1, RoleInfo o2) {
|
142 | 143 | return portalGroupVals;
|
143 | 144 | }
|
144 | 145 |
|
| 146 | + public List<String> getClusterGroups(List<ByteArray> groups,String clusterName) throws ProvisioningException { |
| 147 | + HashMap<String, ClusterInfo> clusterAz = new HashMap<>(); |
| 148 | + List<String> clusterGroups = new ArrayList<String>(); |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + for (ByteArray rawGroup : groups) { |
| 153 | + String group = rawGroup.toString(); |
| 154 | + RoleInfo ri = this.roles.get(group); |
| 155 | + if (ri == null) { |
| 156 | + |
| 157 | + ri = this.loadRoleInfo(group); |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + } |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + ClusterInfo cluster = clusterAz.get(ri.getCluster()); |
| 169 | + if (cluster == null) { |
| 170 | + cluster = new ClusterInfo(ri.getCluster()); |
| 171 | + clusterAz.put(ri.getCluster(), cluster); |
| 172 | + } |
| 173 | + |
| 174 | + cluster.getGroups().add(group); |
| 175 | + |
| 176 | + Map<String, Integer> ns = cluster.getNamespaces().get(ri.getNamespace()); |
| 177 | + if (ns == null) { |
| 178 | + ns = new HashMap<String, Integer>(); |
| 179 | + cluster.getNamespaces().put(ri.getNamespace(), ns); |
| 180 | + } |
| 181 | + ns.put(ri.getName(), 1); |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | + ClusterInfo clusterInfo = clusterAz.get("N/A"); |
| 187 | + logger.info("clusterInfo NA : " + clusterInfo); |
| 188 | + if (clusterInfo != null) { |
| 189 | + |
| 190 | + clusterGroups.addAll(clusterInfo.getGroups()); |
| 191 | + } |
| 192 | + |
| 193 | + clusterInfo = clusterAz.get(clusterName); |
| 194 | + logger.info("clusterInfo : " + clusterInfo); |
| 195 | + if (clusterInfo != null) { |
| 196 | + clusterGroups.addAll(clusterInfo.getGroups()); |
| 197 | + } |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + } |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + return clusterGroups; |
| 208 | + } |
| 209 | + |
145 | 210 | public List<String> generateMappings(LDAPEntry entry) throws ProvisioningException {
|
146 | 211 | JSONArray portalGroupVals = new JSONArray();
|
147 | 212 | List<RoleInfo> sortedRoles = new ArrayList<RoleInfo>();
|
|
0 commit comments