if (!servletMapping.endsWith("*")) {
servletMapping += "*";
}
SecurityContext securityContext = new SecurityContext();
boolean isConfidentialityRequired = false;
boolean isAuthenticationRequired = false;
// find out which policies are active
if (binding instanceof PolicySetAttachPoint) {
List<Intent> intents = ((PolicySetAttachPoint)binding).getRequiredIntents();
for(Intent intent : intents) {
if (intent.getName().equals(AUTEHTICATION_INTENT)) {
isAuthenticationRequired = true;
} else if (intent.getName().equals(CONFIDENTIALITY_INTENT)) {
isConfidentialityRequired = true;
}
}
List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (ConfidentialityPolicy.class.isInstance(p) && isConfidentialityRequired) {
//Handle enabling and configuring SSL
ConfidentialityPolicy confidentialityPolicy = (ConfidentialityPolicy)p;
securityContext.setSSLEnabled(true);
securityContext.setSSLProperties(confidentialityPolicy.toProperties());
} else if(AuthenticationConfigurationPolicy.class.isInstance(p) && isAuthenticationRequired) {
// Handle authentication and user configuration
AuthenticationConfigurationPolicy authenticationConfiguration = (AuthenticationConfigurationPolicy)p;
securityContext.setAuthenticationEnabled(true);
securityContext.getUsers().clear();
securityContext.getUsers().addAll(authenticationConfiguration.getUsers());
}
}
}
}