1 26 27 package org.objectweb.jonas_ear.deployment.api; 28 29 import java.util.ArrayList ; 30 import java.util.Enumeration ; 31 import java.util.HashMap ; 32 import java.util.Iterator ; 33 import java.util.List ; 34 import java.util.Map ; 35 import java.util.Vector ; 36 37 import org.objectweb.jonas_ear.deployment.xml.Application; 38 import org.objectweb.jonas_ear.deployment.xml.JonasApplication; 39 import org.objectweb.jonas_ear.deployment.xml.JonasSecurity; 40 import org.objectweb.jonas_ear.deployment.xml.Module; 41 import org.objectweb.jonas_ear.deployment.xml.SecurityRole; 42 import org.objectweb.jonas_ear.deployment.xml.SecurityRoleMapping; 43 import org.objectweb.jonas_ear.deployment.xml.Web; 44 45 import org.objectweb.jonas_lib.deployment.api.AbsDeploymentDesc; 46 47 54 55 public class EarDeploymentDesc extends AbsDeploymentDesc { 56 57 60 private Vector connectorTags = null; 61 62 65 private Vector altDDConnectors = null; 66 67 70 private Vector ejbTags = null; 71 72 75 private Vector altDDEjbs = null; 76 77 80 private Vector webTags = null; 81 82 85 private Vector clientTags = null; 86 87 90 private Vector altDDWebs = null; 91 92 95 private Vector altDDClients = null; 96 97 100 private Vector securityRolesNames = null; 101 102 105 private String xmlContent = null; 106 107 110 private String jonasXmlContent = null; 111 112 115 private Map userToRoleMapping = null; 116 117 125 public EarDeploymentDesc(ClassLoader classLoaderForCls, Application application, JonasApplication jonasApplication) 126 throws EarDeploymentDescException { 127 128 if (classLoaderForCls == null) { 130 throw new EarDeploymentDescException("DeploymentDesc: Classloader is null"); 131 } 132 133 ejbTags = new Vector (); 134 connectorTags = new Vector (); 135 webTags = new Vector (); 136 clientTags = new Vector (); 137 altDDEjbs = new Vector (); 138 altDDClients = new Vector (); 139 altDDConnectors = new Vector (); 140 altDDWebs = new Vector (); 141 securityRolesNames = new Vector (); 142 143 displayName = application.getDisplayName(); 145 146 for (Iterator i = application.getModuleList().iterator(); i.hasNext();) { 148 Module module = (Module) i.next(); 149 String ejb = module.getEjb(); 150 String connector = module.getConnector(); 151 String java = module.getJava(); 152 Web web = module.getWeb(); 153 String altDD = module.getAltDd(); 154 if (ejb != null) { 155 ejbTags.add(ejb); 156 altDDEjbs.add(altDD); 157 } else if (connector != null) { 158 connectorTags.add(connector); 159 altDDConnectors.add(altDD); 160 } else if (java != null) { 161 clientTags.add(java); 162 altDDClients.add(altDD); 163 } else if (web != null) { 164 webTags.add(web); 165 altDDWebs.add(altDD); 166 } 167 } 168 169 for (Iterator i = application.getSecurityRoleList().iterator(); i.hasNext();) { 171 SecurityRole securityRole = (SecurityRole) i.next(); 172 if (securityRole != null) { 173 if (securityRole.getRoleName() != null) { 174 securityRolesNames.add(securityRole.getRoleName()); 175 } 176 } 177 } 178 179 JonasSecurity jonasSecurity = jonasApplication.getJonasSecurity(); 181 if (jonasSecurity != null) { 182 userToRoleMapping = new HashMap (); 183 for (Iterator it = jonasSecurity.getSecurityRoleMappingList().iterator(); it.hasNext();) { 184 SecurityRoleMapping securityRoleMapping = (SecurityRoleMapping) it.next(); 185 if (securityRoleMapping != null) { 186 String roleName = securityRoleMapping.getRoleName(); 188 List principals = securityRoleMapping.getPrincipalNamesList(); 190 191 for (Iterator itPrincipals = principals.iterator(); itPrincipals.hasNext();) { 193 String principalName = (String ) itPrincipals.next(); 195 List currentMapping = (List ) userToRoleMapping.get(principalName); 197 if (currentMapping == null) { 198 currentMapping = new ArrayList (); 199 userToRoleMapping.put(principalName, currentMapping); 200 } 201 currentMapping.add(roleName); 203 } 204 } 205 } 206 } 207 208 } 209 210 214 public String [] getEjbTags() { 215 String [] tmp = new String [ejbTags.size()]; 216 ejbTags.copyInto(tmp); 217 return tmp; 218 } 219 220 224 public String [] getAltDDEjbs() { 225 String [] tmp = new String [altDDEjbs.size()]; 226 altDDEjbs.copyInto(tmp); 227 return tmp; 228 } 229 230 234 public String [] getClientTags() { 235 String [] tmp = new String [clientTags.size()]; 236 clientTags.copyInto(tmp); 237 return tmp; 238 } 239 240 244 public String [] getAltDDClients() { 245 String [] tmp = new String [altDDClients.size()]; 246 altDDClients.copyInto(tmp); 247 return tmp; 248 } 249 250 254 public Web[] getWebTags() { 255 Web[] tmp = new Web[webTags.size()]; 256 webTags.copyInto(tmp); 257 return tmp; 258 } 259 260 264 public String [] getAltDDWebs() { 265 String [] tmp = new String [altDDWebs.size()]; 266 altDDWebs.copyInto(tmp); 267 return tmp; 268 } 269 270 274 public String [] getConnectorTags() { 275 String [] tmp = new String [connectorTags.size()]; 276 connectorTags.copyInto(tmp); 277 return tmp; 278 } 279 280 284 public String [] getAltDDConnectors() { 285 String [] tmp = new String [altDDConnectors.size()]; 286 altDDConnectors.copyInto(tmp); 287 return tmp; 288 } 289 290 294 public String [] getSecurityRolesNames() { 295 String [] tmp = new String [securityRolesNames.size()]; 296 securityRolesNames.copyInto(tmp); 297 return tmp; 298 } 299 300 304 public String getXmlContent() { 305 return xmlContent; 306 } 307 308 312 public String getJonasXmlContent() { 313 return jonasXmlContent; 314 } 315 316 320 public void setXmlContent(String xml) { 321 xmlContent = xml; 322 } 323 324 328 public void setJonasXmlContent(String xml) { 329 jonasXmlContent = xml; 330 } 331 332 336 public String toString() { 337 338 StringBuffer ret = new StringBuffer (); 339 ret.append("\ndisplay-name=" + displayName); 340 ret.append("\nconnectors="); 341 for (Enumeration e = connectorTags.elements(); e.hasMoreElements();) { 342 ret.append(e.nextElement() + ","); 343 } 344 ret.append("\nejbs="); 345 for (Enumeration e = ejbTags.elements(); e.hasMoreElements();) { 346 ret.append(e.nextElement() + ","); 347 } 348 ret.append("\nwebs="); 349 for (Enumeration e = webTags.elements(); e.hasMoreElements();) { 350 ret.append(((Web) e.nextElement()).getWebUri() + ","); 351 } 352 ret.append("\njavas="); 353 for (Enumeration e = clientTags.elements(); e.hasMoreElements();) { 354 ret.append(e.nextElement() + ","); 355 } 356 ret.append("\nsecurity-roles-names="); 357 for (Enumeration e = securityRolesNames.elements(); e.hasMoreElements();) { 358 ret.append(e.nextElement() + ","); 359 } 360 361 return ret.toString(); 362 } 363 364 367 public Map getUserToRoleMapping() { 368 return userToRoleMapping; 369 } 370 } | Popular Tags |