use of com.sun.enterprise.config.serverbeans.AuditModule in project Payara by payara.
the class DeleteAuditModule method chooseAuditModule.
private AuditModule chooseAuditModule(final ActionReport report) {
config = CLIUtil.chooseConfig(domain, target, report);
if (config == null) {
return null;
}
securityService = config.getSecurityService();
for (AuditModule am : securityService.getAuditModule()) {
if (am.getName().equals(auditModuleName)) {
return am;
}
}
return null;
}
use of com.sun.enterprise.config.serverbeans.AuditModule in project Payara by payara.
the class ListAuditModule method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
report.getTopMessagePart().setChildrenType("audit-module");
for (AuditModule am : securityService.getAuditModule()) {
ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(am.getName());
}
}
use of com.sun.enterprise.config.serverbeans.AuditModule in project Payara by payara.
the class BaseAuditManager method loadAuditModules.
/**
* This method initializes BaseAuditManager which load audit modules and
* audit enabled flag
*/
@Override
public void loadAuditModules() {
try {
SecurityService securityBean = serverContext.getDefaultServices().getService(SecurityService.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
assert (securityBean != null);
// @todo will be removed to incorporate the new structure.
// v3:Commented boolean auditFlag = securityBean.isAuditEnabled();
boolean auditFlag = Boolean.parseBoolean(securityBean.getAuditEnabled());
setAuditOn(auditFlag);
/*V3:Commented
com.sun.enterprise.config.serverbeans.AuditModule[] am =
securityBean.getAuditModule();*/
List<com.sun.enterprise.config.serverbeans.AuditModule> am = securityBean.getAuditModule();
for (com.sun.enterprise.config.serverbeans.AuditModule it : am) {
// V3:Commented for (int i = 0; i < am.length; i++){
try {
// V3:Commented String name = am[i].getName();
// V3:Commented String classname = am[i].getClassname();
String name = it.getName();
String classname = it.getClassname();
Properties p = new Properties();
// XXX should we remove this two extra properties
p.setProperty(NAME, name);
p.setProperty(CLASSNAME, classname);
List<Property> ep = it.getProperty();
/*V3:Commented
ElementProperty[] ep = am[i].getElementProperty();
int epsize = am[i].sizeElementProperty();
for (int j = 0; j < epsize; j++){
String nme = ep[j].getName();
String val = ep[j].getValue();
p.setProperty(nme, val);
}*/
for (Property prop : ep) {
p.setProperty(prop.getName(), prop.getValue());
}
BaseAuditModule auditModule = loadAuditModule(classname, p);
instances.add(auditModule);
moduleToNameMap.put(auditModule, name);
nameToModuleMap.put(name, auditModule);
if (isAuditModuleOfParameterizedType(auditModule)) {
typedModules.add((T) auditModule);
}
} catch (Exception ex) {
String msg = _localStrings.getLocalString("auditmgr.loaderror", "Audit: Cannot load AuditModule = {0}", // V3:Commented new Object[]{ am[i].getName() });
new Object[] { it.getName() });
_logger.log(Level.WARNING, msg, ex);
}
}
} catch (Exception e) {
String msg = _localStrings.getLocalString("auditmgr.badinit", "Audit: Cannot load Audit Module Initialization information. AuditModules will not be loaded.");
_logger.log(Level.WARNING, msg, e);
}
}
use of com.sun.enterprise.config.serverbeans.AuditModule in project Payara by payara.
the class CreateAuditModule method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
// check if there exists an audit module by the specified name
// if so return failure.
List<AuditModule> ams = securityService.getAuditModule();
for (AuditModule am : ams) {
if (am.getName().equals(auditModuleName)) {
report.setMessage(localStrings.getLocalString("create.audit.module.duplicatefound", "AuditModule named {0} exists. " + "Cannot add duplicate AuditModule.", auditModuleName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
// No duplicate audit modules found. So add one.
try {
ConfigSupport.apply(new SingleConfigCode<SecurityService>() {
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure {
AuditModule newAuditModule = param.createChild(AuditModule.class);
populateAuditModuleElement(newAuditModule);
param.getAuditModule().add(newAuditModule);
return newAuditModule;
}
}, securityService);
} catch (TransactionFailure e) {
report.setMessage(localStrings.getLocalString("create.audit.module.fail", "Creation of AuditModule {0} failed", auditModuleName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
// report.setMessage(localStrings.getLocalString("create.audit.module.success",
// "Creation of AuditModule {0} completed successfully", auditModuleName));
}
Aggregations