public void applySecurity(String serviceName, String scenarioId, KerberosConfigData kerberosConfigurations)
throws SecurityConfigException {
if (kerberosConfigurations == null) {
log.error("Kerberos configurations provided are invalid.");
throw new SecurityConfigException("Kerberos configuration parameters are null. " +
"Please specify valid kerberos configurations.");
}
try {
// Begin registry transaction
boolean transactionStarted = Transaction.isStarted();
if (!transactionStarted) {
registry.beginTransaction();
}
// Disable security if already a policy is applied
this.disableSecurityOnService(serviceName);
AxisService service = axisConfig.getServiceForActivation(serviceName);
if (service == null) {
throw new SecurityConfigException("nullService");
}
boolean isRahasEngaged = false;
applyPolicy(service, scenarioId, null, null, null, kerberosConfigurations);
isRahasEngaged = engageModules(scenarioId, serviceName, service);
if (!isRahasEngaged) {
log.info("Rahas engaged to service - " + serviceName);
}
disableRESTCalls(serviceName, scenarioId);
persistsKerberosData(service, kerberosConfigurations);
if (!transactionStarted) {
registry.commitTransaction();
}
} catch (RegistryException e) {
StringBuilder str = new StringBuilder("Error persisting security scenario ").
append(scenarioId).append(" for service ").append(serviceName);
log.error(str.toString(),e);
try {
registry.rollbackTransaction();
} catch (RegistryException ex) {
log.error("An error occurred while rollback, registry.", ex);
}
throw new SecurityConfigException(str.toString(), e);
}
}