Search in sources :

Example 6 with LoggingConfigurationType

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;
}
Also used : AuditingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)

Example 7 with LoggingConfigurationType

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);
}
Also used : CleanupPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType) AssignmentPolicyEnforcementType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) FileAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType) FileAppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType) AppenderConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)

Example 8 with LoggingConfigurationType

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);
}
Also used : ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 9 with LoggingConfigurationType

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();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AuditingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 10 with LoggingConfigurationType

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();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType) Test(org.testng.annotations.Test)

Aggregations

ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)9 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)9 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 Task (com.evolveum.midpoint.task.api.Task)5 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)5 SubSystemLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)5 Test (org.testng.annotations.Test)5 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)4 AuditingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType)3 AppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType)2 AssignmentPolicyEnforcementType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType)2 CleanupPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType)2 FileAppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType)2 DummyConnector (com.evolveum.icf.dummy.connector.DummyConnector)1 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)1 IntegrationTestTools (com.evolveum.midpoint.test.IntegrationTestTools)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1