Package org.apache.syncope.common.types

Examples of org.apache.syncope.common.types.AuditLoggerName


        public List<AuditLoggerName> getObject() {
            Map<Category, Set<AuditLoggerName>> audits = loggerRestClient.listAuditsByCategory();

            List<AuditLoggerName> object = new ArrayList<AuditLoggerName>();
            for (Enum<?> subcategory : category.getSubCategoryElements()) {
                AuditLoggerName auditLoggerName = new AuditLoggerName(category, subcategory, result);
                if (audits.containsKey(category) && audits.get(category).contains(auditLoggerName)) {
                    object.add(auditLoggerName);
                }
            }
View Full Code Here


        }

        @Override
        public void setObject(final List<AuditLoggerName> object) {
            for (Enum<?> subcategory : category.getSubCategoryElements()) {
                AuditLoggerName auditLoggerName = new AuditLoggerName(category, subcategory, result);

                if (object.contains(auditLoggerName)) {
                    loggerRestClient.enableAudit(auditLoggerName);
                } else {
                    loggerRestClient.disableAudit(auditLoggerName);
View Full Code Here

                        protected void populateItem(final ListItem<Enum<?>> item) {
                            final Enum<?> subcategory = item.getModelObject();

                            final Check<AuditLoggerName> successCheck = new Check<AuditLoggerName>("successCheck",
                                    new Model<AuditLoggerName>(
                                    new AuditLoggerName(category, subcategory, Result.success)), successGroup);
                            item.add(successCheck);
                        }
                    };
            successGroup.add(successView);

            ListView<Enum<?>> failureView =
                    new AltListView<Enum<?>>("failureView", new ArrayList(category.getSubCategoryElements())) {

                        private static final long serialVersionUID = 4949588177564901031L;

                        @Override
                        protected void populateItem(final ListItem<Enum<?>> item) {
                            final Enum<?> subcategory = item.getModelObject();

                            final Check<AuditLoggerName> failureCheck = new Check<AuditLoggerName>("failureCheck",
                                    new Model<AuditLoggerName>(
                                    new AuditLoggerName(category, subcategory, Result.failure)), failureGroup);
                            item.add(failureCheck);
                        }
                    };
            failureGroup.add(failureView);
        }
View Full Code Here

        assertEquals(startSize, loggers.size());
    }

    @Test
    public void enableDisableAudit() {
        AuditLoggerName auditLoggerName = new AuditLoggerName(AuditElements.Category.report,
                AuditElements.ReportSubCategory.deleteExecution, AuditElements.Result.failure);

        List<AuditLoggerName> audits = CollectionWrapper.wrapLogger(loggerService.list(LoggerType.AUDIT));
        assertNotNull(audits);
        assertFalse(audits.contains(auditLoggerName));

        LoggerTO loggerTO = new LoggerTO();
        String name = auditLoggerName.toLoggerName();
        loggerTO.setName(name);
        loggerTO.setLevel(SyncopeLoggerLevel.DEBUG);
        loggerService.update(LoggerType.AUDIT, name, loggerTO);

        audits = CollectionWrapper.wrapLogger(loggerService.list(LoggerType.AUDIT));
        assertNotNull(audits);
        assertTrue(audits.contains(auditLoggerName));

        loggerService.delete(LoggerType.AUDIT, auditLoggerName.toLoggerName());

        audits = CollectionWrapper.wrapLogger(loggerService.list(LoggerType.AUDIT));
        assertNotNull(audits);
        assertFalse(audits.contains(auditLoggerName));
    }
View Full Code Here

    }

    public void audit(final Category category, final Enum<?> subcategory, final Result result, final String message,
            final Throwable throwable) {

        AuditLoggerName auditLoggerName = null;
        try {
            auditLoggerName = new AuditLoggerName(category, subcategory, result);
        } catch (IllegalArgumentException e) {
            LOG.error("Invalid audit parameters, aborting...", e);
        }

        if (auditLoggerName != null) {
            StringBuilder auditMessage = new StringBuilder();

            final SecurityContext ctx = SecurityContextHolder.getContext();
            if (ctx != null && ctx.getAuthentication() != null) {
                auditMessage.append('[').append(ctx.getAuthentication().getName()).append(']').append(' ');
            }
            auditMessage.append(message);

            Logger logger = LoggerFactory.getLogger(auditLoggerName.toLoggerName());
            if (throwable == null) {
                logger.debug(auditMessage.toString());
            } else {
                logger.debug(auditMessage.toString(), throwable);
            }
View Full Code Here

        assertEquals(startSize, loggers.size());
    }

    @Test
    public void enableDisableAudit() {
        AuditLoggerName auditLoggerName = new AuditLoggerName(
                EventCategoryType.REST,
                ReportController.class.getSimpleName(),
                null,
                "deleteExecution",
                AuditElements.Result.FAILURE);

        List<AuditLoggerName> audits = CollectionWrapper.wrapLogger(loggerService.list(LoggerType.AUDIT));
        assertNotNull(audits);
        assertFalse(audits.contains(auditLoggerName));

        LoggerTO loggerTO = new LoggerTO();
        String name = auditLoggerName.toLoggerName();
        loggerTO.setName(name);
        loggerTO.setLevel(SyncopeLoggerLevel.DEBUG);
        loggerService.update(LoggerType.AUDIT, name, loggerTO);

        audits = CollectionWrapper.wrapLogger(loggerService.list(LoggerType.AUDIT));
        assertNotNull(audits);
        assertTrue(audits.contains(auditLoggerName));

        loggerService.delete(LoggerType.AUDIT, auditLoggerName.toLoggerName());

        audits = CollectionWrapper.wrapLogger(loggerService.list(LoggerType.AUDIT));
        assertNotNull(audits);
        assertFalse(audits.contains(auditLoggerName));
    }
View Full Code Here

        public List<AuditLoggerName> getObject() {
            Map<Category, Set<AuditLoggerName>> audits = loggerRestClient.listAuditsByCategory();

            List<AuditLoggerName> object = new ArrayList<AuditLoggerName>();
            for (Enum<?> subcategory : category.getSubCategoryElements()) {
                AuditLoggerName auditLoggerName = new AuditLoggerName(category, subcategory, result);
                if (audits.containsKey(category) && audits.get(category).contains(auditLoggerName)) {
                    object.add(auditLoggerName);
                }
            }
View Full Code Here

        }

        @Override
        public void setObject(final List<AuditLoggerName> object) {
            for (Enum<?> subcategory : category.getSubCategoryElements()) {
                AuditLoggerName auditLoggerName = new AuditLoggerName(category, subcategory, result);

                if (object.contains(auditLoggerName)) {
                    loggerRestClient.enableAudit(auditLoggerName);
                } else {
                    loggerRestClient.disableAudit(auditLoggerName);
View Full Code Here

                protected void populateItem(final ListItem<Enum<?>> item) {
                    final Enum<?> subcategory = item.getModelObject();

                    final Check<AuditLoggerName> successCheck = new Check<AuditLoggerName>("successCheck",
                            new Model<AuditLoggerName>(
                            new AuditLoggerName(category, subcategory, Result.success)), successGroup);
                    item.add(successCheck);
                }
            };
            successGroup.add(successView);

            ListView<Enum<?>> failureView =
                    new AltListView<Enum<?>>("failureView", new ArrayList(category.getSubCategoryElements())) {

                private static final long serialVersionUID = 4949588177564901031L;

                @Override
                protected void populateItem(final ListItem<Enum<?>> item) {
                    final Enum<?> subcategory = item.getModelObject();

                    final Check<AuditLoggerName> failureCheck = new Check<AuditLoggerName>("failureCheck",
                            new Model<AuditLoggerName>(
                            new AuditLoggerName(category, subcategory, Result.failure)), failureGroup);
                    item.add(failureCheck);
                }
            };
            failureGroup.add(failureView);
        }
View Full Code Here

                    for (String toBeRemoved : eventSelectionChanged.getToBeRemoved()) {
                        if (events.contains(toBeRemoved)) {
                            final Map.Entry<EventCategoryTO, Result> eventCategory =
                                    LoggerEventUtils.parseEventCategory(toBeRemoved);

                            final AuditLoggerName auditLoggerName = new AuditLoggerName(
                                    eventCategory.getKey().getType(),
                                    eventCategory.getKey().getCategory(),
                                    eventCategory.getKey().getSubcategory(),
                                    CollectionUtils.isEmpty(eventCategory.getKey().getEvents())
                                    ? null : eventCategory.getKey().getEvents().iterator().next(),
                                    eventCategory.getValue());

                            loggerRestClient.disableAudit(auditLoggerName);
                            events.remove(toBeRemoved);
                        }
                    }

                    for (String toBeAdded : eventSelectionChanged.getToBeAdded()) {
                        if (!events.contains(toBeAdded)) {
                            final Map.Entry<EventCategoryTO, Result> eventCategory =
                                    LoggerEventUtils.parseEventCategory(toBeAdded);

                            final AuditLoggerName auditLoggerName = new AuditLoggerName(
                                    eventCategory.getKey().getType(),
                                    eventCategory.getKey().getCategory(),
                                    eventCategory.getKey().getSubcategory(),
                                    CollectionUtils.isEmpty(eventCategory.getKey().getEvents())
                                    ? null : eventCategory.getKey().getEvents().iterator().next(),
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.types.AuditLoggerName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.