String[] httpMethods = info.getExcludedMethods();
if( httpMethods != null )
{
// There were excluded security-constraints
WebResourcePermission wrp = new WebResourcePermission(qurl, httpMethods);
WebUserDataPermission wudp = new WebUserDataPermission(qurl,
httpMethods, null);
pc.addToExcludedPolicy(wrp);
pc.addToExcludedPolicy(wudp);
//!(excluded methods) [JACC 1.1]
String excludedString = "!" + getCommaSeparatedString(httpMethods);
WebResourcePermission wrp1 = new WebResourcePermission(info.pattern, excludedString);
WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern,excludedString);
pc.addToUncheckedPolicy(wrp1);
pc.addToUncheckedPolicy(wudp1);
}
// Create the role permissions
Iterator<Map.Entry<String, Set<String>>> roles = info.getRoleMethods();
while( roles.hasNext() )
{
Map.Entry<String, Set<String>> roleMethods = roles.next();
String role = (String) roleMethods.getKey();
WebResourcePermission wrp;
if("*".equals(role))
{
//JBAS-1824: <role-name>*</role-name>
wrp = new WebResourcePermission(qurl, (String)null);
}
else
{
Set<String> methods = roleMethods.getValue();
httpMethods = new String[methods.size()];
methods.toArray(httpMethods);
wrp = new WebResourcePermission(qurl, httpMethods);
}
pc.addToRole(role, wrp);
//JACC 1.1: create !(httpmethods) in unchecked perms
if(httpMethods != null)
{
final String pattern = info.pattern;
final String methodsAsString = "!" + getCommaSeparatedString(httpMethods);
WebResourcePermission wrpUnchecked = null;
try
{
wrpUnchecked = new WebResourcePermission(pattern, methodsAsString);
}
catch (final IllegalArgumentException iae)
{
throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern
+ "\" and methods: " + methodsAsString, iae);
}
pc.addToUncheckedPolicy(wrpUnchecked);
}
}
// Create the unchecked permissions
String[] missingHttpMethods = info.getMissingMethods();
if( missingHttpMethods.length > 0 )
{
// Create the unchecked permissions WebResourcePermissions
WebResourcePermission wrp = new WebResourcePermission(qurl, missingHttpMethods);
pc.addToUncheckedPolicy(wrp);
}
else
pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null));
//SECURITY-63: Missing auth-constraint needs unchecked policy
if(info.isMissingAuthConstraint)
{
pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null));
}
// Create the unchecked permissions WebUserDataPermissions
Iterator<Map.Entry<String, Set<String>>> transportContraints = info.getTransportMethods();
while( transportContraints.hasNext() )
{
Map.Entry<String, Set<String>> transportMethods = transportContraints.next();
String transport = transportMethods.getKey();
Set<String> methods = transportMethods.getValue();
httpMethods = new String[methods.size()];
methods.toArray(httpMethods);
WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, transport);
pc.addToUncheckedPolicy(wudp);
//If the transport is "NONE", then add an exlusive WebUserDataPermission
//with the url pattern and null
if("NONE".equals(transport))
{
WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern, null);
pc.addToUncheckedPolicy(wudp1);
}
else
{
//JACC 1.1: Transport is CONFIDENTIAL/INTEGRAL, add a !(http methods)
if(httpMethods != null)
{
WebUserDataPermission wudpNonNull = new WebUserDataPermission(info.pattern,
"!" + getCommaSeparatedString(httpMethods));
pc.addToUncheckedPolicy(wudpNonNull);
}
}
}