Set allSet = new HashSet(); // == allMap.values()
Map allMap = new HashMap(); //uncheckedPatterns union excludedPatterns union rolesPatterns.
SecurityConstraintType[] securityConstraintArray = webApp.getSecurityConstraintArray();
for (int i = 0; i < securityConstraintArray.length; i++) {
SecurityConstraintType securityConstraintType = securityConstraintArray[i];
Map currentPatterns;
if (securityConstraintType.isSetAuthConstraint()) {
if (securityConstraintType.getAuthConstraint().getRoleNameArray().length == 0) {
currentPatterns = excludedPatterns;
} else {
currentPatterns = rolesPatterns;
}
} else {
currentPatterns = uncheckedPatterns;
}
String transport = "";
if (securityConstraintType.isSetUserDataConstraint()) {
transport = securityConstraintType.getUserDataConstraint().getTransportGuarantee().getStringValue().trim().toUpperCase();
}
WebResourceCollectionType[] webResourceCollectionTypeArray = securityConstraintType.getWebResourceCollectionArray();
for (int j = 0; j < webResourceCollectionTypeArray.length; j++) {
WebResourceCollectionType webResourceCollectionType = webResourceCollectionTypeArray[j];
UrlPatternType[] urlPatternTypeArray = webResourceCollectionType.getUrlPatternArray();
for (int k = 0; k < urlPatternTypeArray.length; k++) {
UrlPatternType urlPatternType = urlPatternTypeArray[k];
String url = urlPatternType.getStringValue().trim();
URLPattern pattern = (URLPattern) currentPatterns.get(url);
if (pattern == null) {
pattern = new URLPattern(url);
currentPatterns.put(url, pattern);
}
URLPattern allPattern = (URLPattern) allMap.get(url);
if (allPattern == null) {
allPattern = new URLPattern(url);
allSet.add(allPattern);
allMap.put(url, allPattern);
}
HttpMethodType[] httpMethodTypeArray = webResourceCollectionType.getHttpMethodArray();
if (httpMethodTypeArray.length == 0) {
pattern.addMethod("");
allPattern.addMethod("");
} else {
for (int l = 0; l < httpMethodTypeArray.length; l++) {
HttpMethodType httpMethodType = httpMethodTypeArray[l];
//TODO is trim OK?
String method = httpMethodType.getStringValue().trim();
pattern.addMethod(method);
allPattern.addMethod(method);
}
}
if (currentPatterns == rolesPatterns) {
RoleNameType[] roleNameTypeArray = securityConstraintType.getAuthConstraint().getRoleNameArray();
for (int l = 0; l < roleNameTypeArray.length; l++) {
RoleNameType roleNameType = roleNameTypeArray[l];
String role = roleNameType.getStringValue().trim();
if (role.equals("*")) {
pattern.addAllRoles(securityRoles);