use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class LoggingDto method getNewObject.
public LoggingConfigurationType getNewObject() {
LoggingConfigurationType configuration = new LoggingConfigurationType();
AuditingConfigurationType audit = new AuditingConfigurationType();
audit.setEnabled(isAuditLog());
audit.setDetails(isAuditDetails());
if (StringUtils.isNotEmpty(getAuditAppender())) {
audit.getAppender().add(getAuditAppender());
}
configuration.setAuditing(audit);
configuration.setRootLoggerAppender(getRootAppender());
configuration.setRootLoggerLevel(getRootLevel());
for (AppenderConfiguration item : getAppenders()) {
configuration.getAppender().add(item.getConfig());
}
for (LoggerConfiguration item : getLoggers()) {
for (ClassLoggerConfigurationType logger : configuration.getClassLogger()) {
if (logger.getPackage().equals(item.getName())) {
throw new IllegalStateException("Logger with name '" + item.getName() + "' is already defined.");
}
}
//TODO : clean up toXmlType() method.. getAppenders() in LogginConfiguration is empty by default..shouldn't it be null?
if (item.toXmlType() != null) {
configuration.getClassLogger().add(item.toXmlType());
}
}
for (FilterConfiguration item : getFilters()) {
for (SubSystemLoggerConfigurationType filter : configuration.getSubSystemLogger()) {
if (filter.getComponent().name().equals(item.getName())) {
throw new IllegalStateException("Filter with name '" + item.getName() + "' is already defined.");
}
}
configuration.getSubSystemLogger().add(item.toXmlType());
}
for (LoggerConfiguration logger : getLoggers()) {
logger.setEditing(false);
}
for (FilterConfiguration filter : getFilters()) {
filter.setEditing(false);
}
for (AppenderConfiguration appender : getAppenders()) {
appender.setEditing(false);
}
return configuration;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class SystemConfigurationDto method init.
private void init(SystemConfigurationType config) {
if (config == null) {
return;
}
if (config.getGlobalAccountSynchronizationSettings() != null) {
AssignmentPolicyEnforcementType globalAEP = config.getGlobalAccountSynchronizationSettings().getAssignmentPolicyEnforcement();
aepLevel = AEPlevel.fromAEPLevelType(globalAEP);
}
CleanupPolicyType auditCleanup = config.getCleanupPolicy().getAuditRecords();
CleanupPolicyType taskCleanup = config.getCleanupPolicy().getClosedTasks();
auditCleanupValue = auditCleanup.getMaxAge().toString();
taskCleanupValue = taskCleanup.getMaxAge().toString();
passPolicyDto = loadPasswordPolicy(config);
securityPolicyDto = loadSecurityPolicy(config);
objectPolicyList = new ArrayList<>();
List<ObjectPolicyConfigurationType> objectPolicies = config.getDefaultObjectPolicyConfiguration();
if (objectPolicies != null && !objectPolicies.isEmpty()) {
for (ObjectPolicyConfigurationType policy : objectPolicies) {
objectPolicyList.add(new ObjectPolicyConfigurationTypeDto(policy));
}
} else {
objectPolicyList.add(new ObjectPolicyConfigurationTypeDto());
}
// NOTIFICATIONS
if (config.getNotificationConfiguration() != null) {
notificationConfig = new NotificationConfigurationDto(config.getNotificationConfiguration());
} else {
notificationConfig = new NotificationConfigurationDto();
}
// LOGGING
LoggingConfigurationType logging = config.getLogging();
if (logging != null) {
for (AppenderConfigurationType appender : logging.getAppender()) {
if (appender instanceof FileAppenderConfigurationType) {
appenders.add(new FileAppenderConfig((FileAppenderConfigurationType) appender));
} else {
appenders.add(new AppenderConfiguration(appender));
}
}
Collections.sort(appenders);
loggingConfig = new LoggingDto(config.getLogging());
} else {
loggingConfig = new LoggingDto();
}
loggingConfig.setAppenders(appenders);
// PROFILING
if (config.getProfilingConfiguration() != null) {
List<ClassLoggerConfigurationType> classLoggerConfig = config.getLogging() != null ? config.getLogging().getClassLogger() : null;
profilingDto = new ProfilingDto(config.getProfilingConfiguration(), classLoggerConfig);
} else {
profilingDto = new ProfilingDto();
}
profilingDto.setAppenders(appenders);
enableExperimentalCode = SystemConfigurationTypeUtil.isExperimentalCodeEnabled(config);
userDashboardLink = loadUserDashboardLink(config);
additionalMenuLink = loadAdditionalMenuItem(config);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class AbstractWebserviceTest method checkAuditEnabled.
private void checkAuditEnabled(SystemConfigurationType configurationType) throws FaultMessage {
LoggingConfigurationType loggingConfig = configurationType.getLogging();
AuditingConfigurationType auditConfig = loggingConfig.getAuditing();
if (auditConfig == null) {
auditConfig = new AuditingConfigurationType();
auditConfig.setEnabled(true);
loggingConfig.setAuditing(auditConfig);
} else {
if (BooleanUtils.isTrue(auditConfig.isEnabled())) {
return;
}
auditConfig.setEnabled(true);
}
ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), "logging", ModificationTypeType.REPLACE, loggingConfig);
ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, null);
assertSuccess(deltaOpList);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class TestLoggingConfiguration method test101EnableBasicAudit.
@Test
public void test101EnableBasicAudit() throws Exception {
TestUtil.displayTestTile("test101EnableBasicAudit");
// GIVEN
LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + ".test101EnableBasicAudit");
OperationResult result = task.getResult();
// Precondition
tailer.tail();
tailer.assertNoAudit();
// Setup
PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
applyTestLoggingConfig(logging);
AuditingConfigurationType auditingConfigurationType = logging.getAuditing();
if (auditingConfigurationType == null) {
auditingConfigurationType = new AuditingConfigurationType();
logging.setAuditing(auditingConfigurationType);
}
auditingConfigurationType.setEnabled(true);
auditingConfigurationType.setDetails(false);
ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// Make sure that the (optional) audit message from the above change will not get into the way
tailer.tail();
tailer.reset();
// This message will appear in the log and will help diagnose problems
display("TEST: Applied audit config, going to execute test change");
// try do execute some change (add user object), it should be audited
PrismObject<UserType> user = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.USER_JACK_FILE);
deltas = MiscSchemaUtil.createCollection(ObjectDelta.createAddDelta(user));
modelService.executeChanges(deltas, null, task, result);
// This message will appear in the log and will help diagnose problems
display("TEST: Executed test change");
// THEN
tailer.tail();
tailer.assertAudit(2);
tailer.assertAuditRequest();
tailer.assertAuditExecution();
tailer.close();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType in project midpoint by Evolveum.
the class TestLoggingConfiguration method test010AddModelSubsystemLogger.
@Test
public void test010AddModelSubsystemLogger() throws Exception {
final String TEST_NAME = "test010AddModelSubsystemLogger";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// Precondition
tailer.logAndTail();
assertBasicLogging(tailer);
tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_DEBUG, ProfilingDataManager.Subsystem.MODEL.name());
tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.MODEL.name());
// Setup
PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
applyTestLoggingConfig(logging);
SubSystemLoggerConfigurationType modelSubSystemLogger = new SubSystemLoggerConfigurationType();
modelSubSystemLogger.setComponent(LoggingComponentType.MODEL);
modelSubSystemLogger.setLevel(LoggingLevelType.DEBUG);
logging.getSubSystemLogger().add(modelSubSystemLogger);
ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
tailer.logAndTail();
assertBasicLogging(tailer);
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, ProfilingDataManager.Subsystem.MODEL.name());
tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.MODEL.name());
// Test that the class logger for this test messages works
// GIVEN
tailer.setExpecteMessage("This is THE MESSage");
// WHEN
display("This is THE MESSage");
// THEN
tailer.tail();
tailer.assertExpectedMessage();
tailer.close();
}
Aggregations