try {
int tenantId =
SuperTenantCarbonContext.getCurrentContext(axisConfiguration)
.getTenantId();
Collection<SecurityScenario> scenarios = SecurityScenarioDatabase.getAllScenarios();
UserRegistry tenantUserRegistry =
IdentitySTSMgtServiceComponent.getRegistryService()
.getConfigSystemRegistry(tenantId);
for (Iterator<SecurityScenario> ite = scenarios.iterator(); ite.hasNext();) {
SecurityScenario scenario = ite.next();
String scenarioId = scenario.getScenarioId();
if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
!scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
String resourceUri = SecurityConstants.SECURITY_POLICY + "/" + scenarioId;
if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
!scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
Resource scenarioResource = tenantUserRegistry.newResource();
URL resource =
IdentitySTSMgtServiceComponent.getBundleContext().
getBundle().
getResource(scenarioId +
"-policy.xml");
if (resource != null) {
scenarioResource.setContentStream(resource.openStream());
tenantUserRegistry.put(resourceUri, scenarioResource);
} else {
log.error("Could not load policy scenario " + scenarioId +
" for tenant " + tenantId);
}
}