private void initSecurityConstraints()
{
Map<String, ServletConfigImpl> servlets = _servletManager.getServlets();
for (Map.Entry<String, ServletConfigImpl> entry : servlets.entrySet()) {
ServletSecurityElement securityElement
= entry.getValue().getSecurityElement();
if (securityElement == null)
continue;
/*
ServletSecurity.EmptyRoleSemantic rootRoleSemantic
= securityElement.getEmptyRoleSemantic();
*/
final Set<String> patterns = _servletMapper.getUrlPatterns(entry.getKey());
final Collection<HttpMethodConstraintElement> constraints
= securityElement.getHttpMethodConstraints();
if (constraints != null) {
for (HttpMethodConstraintElement httpMethodConstraintElement : securityElement
.getHttpMethodConstraints()) {
ServletSecurity.EmptyRoleSemantic emptyRoleSemantic =
httpMethodConstraintElement.getEmptyRoleSemantic();
ServletSecurity.TransportGuarantee transportGuarantee =
httpMethodConstraintElement.getTransportGuarantee();
String[] roles = httpMethodConstraintElement.getRolesAllowed();
SecurityConstraint constraint = new SecurityConstraint();
constraint.setFallthrough(false);
if (emptyRoleSemantic == ServletSecurity.EmptyRoleSemantic.DENY) {
constraint.addConstraint(new PermitEmptyRolesConstraint(false));
} else if (roles.length == 0
&& transportGuarantee == ServletSecurity.TransportGuarantee.NONE) {
constraint.addConstraint(new PermitEmptyRolesConstraint(true));
} else {
for (String role : roles)
constraint.addRoleName(role);
if (transportGuarantee == ServletSecurity.TransportGuarantee.CONFIDENTIAL)
constraint.addConstraint(new TransportConstraint("CONFIDENTIAL"));
}
WebResourceCollection resources = new WebResourceCollection();
resources.addHttpMethod(httpMethodConstraintElement.getMethodName());
for (String pattern : patterns) {
resources.addURLPattern(pattern);
constraint.addURLPattern(pattern);
}
constraint.addWebResourceCollection(resources);
_constraintManager.addConstraint(constraint);
}
}
ServletSecurity.EmptyRoleSemantic emptyRoleSemantic
= securityElement.getEmptyRoleSemantic();
ServletSecurity.TransportGuarantee transportGuarantee
= securityElement.getTransportGuarantee();
String []roles = securityElement.getRolesAllowed();
SecurityConstraint constraint = new SecurityConstraint();
if (emptyRoleSemantic == ServletSecurity.EmptyRoleSemantic.DENY) {
constraint.addConstraint(new PermitEmptyRolesConstraint(false));