e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi/*
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * CDDL HEADER START
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi *
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * The contents of this file are subject to the terms of the
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * Common Development and Distribution License, Version 1.0 only
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * (the "License"). You may not use this file except in compliance
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * with the License.
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi *
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * or http://forgerock.org/license/CDDLv1.0.html.
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * See the License for the specific language governing permissions
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * and limitations under the License.
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi *
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * When distributing Covered Code, include this CDDL HEADER in each
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * file and include the License file at legal-notices/CDDLv1_0.txt.
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * If applicable, add the following below this CDDL HEADER, with the
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * fields enclosed by brackets "[]" replaced with your own identifying
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * information:
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * Portions Copyright [yyyy] [name of copyright owner]
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi *
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * CDDL HEADER END
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi *
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi *
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * Copyright 2015 ForgeRock AS
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi */
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponipackage org.opends.server.loggers;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport static org.forgerock.json.JsonValue.*;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport java.util.ArrayList;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport java.util.Arrays;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport java.util.List;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport java.util.Set;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.forgerock.audit.events.AccessAuditEventBuilder;
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponiimport org.forgerock.i18n.LocalizableMessage;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.forgerock.i18n.LocalizableMessageBuilder;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.forgerock.json.JsonValue;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.forgerock.util.Reject;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.opends.server.core.ModifyDNOperation;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.opends.server.core.SearchOperation;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.opends.server.types.AdditionalLogItem;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.opends.server.types.Control;
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponiimport org.opends.server.types.DisconnectReason;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiimport org.opends.server.types.Operation;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi/**
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * Builder for /audit/access events specific to OpenDJ. This builder add LDAP
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * specific fields to the common fields defined in AccessAuditEventBuilder.
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi *
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * @param <T>
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi * This builder.
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi */
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponiclass OpenDJAccessAuditEventBuilder<T extends OpenDJAccessAuditEventBuilder<T>> extends AccessAuditEventBuilder<T>
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi{
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi private OpenDJAccessAuditEventBuilder()
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi super();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi @SuppressWarnings("rawtypes")
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public static <T> OpenDJAccessAuditEventBuilder<?> openDJAccessEvent()
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return new OpenDJAccessAuditEventBuilder();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapAdditionalItems(Operation op)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi String items = getAdditionalItemsAsString(op);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if (!items.isEmpty())
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("items", items);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapAttr(String attr)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("attr", attr);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapConnectionId(long id)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("connId", id);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapControls(Operation operation)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi JsonValue ldapValue = getLdapValue();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi List<Control> requestControls = operation.getRequestControls();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if (!requestControls.isEmpty())
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("reqControls", getControlsAsString(requestControls));
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi List<Control> responseControls = operation.getResponseControls();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if (!responseControls.isEmpty())
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("respControls", getControlsAsString(responseControls));
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapDn(String dn)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("dn", dn);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapFailureMessage(String msg)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("failureReason", msg);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapIds(Operation op)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi JsonValue ldapValue = getLdapValue();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("connId", op.getConnectionID());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("msgId", op.getMessageID());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapIdToAbandon(int id)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("idToAbandon", id);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapMaskedResultAndMessage(Operation operation)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi JsonValue ldapValue = getLdapValue();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if (operation.getMaskedResultCode() != null)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("maskedResult", operation.getMaskedResultCode().intValue());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi final LocalizableMessageBuilder maskedMsg = operation.getMaskedErrorMessage();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if (maskedMsg != null && maskedMsg.length() > 0)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("maskedMessage", maskedMsg.toString());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponi public T ldapMessage(LocalizableMessage msg)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponi if (msg != null)
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponi {
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponi getLdapValue().put("message", msg.toString());
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapName(String name)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("name", name);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapModifyDN(ModifyDNOperation modifyDNOperation)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi JsonValue ldapValue = getLdapValue();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("newRDN", modifyDNOperation.getRawNewRDN().toString());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("newSup", modifyDNOperation.getRawNewSuperior().toString());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("deleteOldRDN", modifyDNOperation.deleteOldRDN());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapNEntries(int nbEntries)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("nentries", nbEntries);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapOid(String oid)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("oid", oid);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapProtocolVersion(String version)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("version", version);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponi public T ldapReason(DisconnectReason reason)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
de7a38699a83cd9ee7c35143d8986fa05ebdd3d9Nicolas Capponi getLdapValue().put("reason", reason.toString());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapSearch(SearchOperation searchOperation)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi JsonValue ldapValue = getLdapValue();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi // for search base, re-uses the "dn" field
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("dn", searchOperation.getRawBaseDN().toString());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("scope", searchOperation.getScope().toString());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("filter", searchOperation.getRawFilter().toString());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi final Set<String> attrs = searchOperation.getAttributes();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if ((attrs == null) || attrs.isEmpty())
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("attrs", Arrays.asList("ALL"));
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi else
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue.put("attrs", new ArrayList<>(attrs));
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapSync(Operation operation)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if (operation.isSynchronizationOperation())
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("opType", "sync");
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T ldapAuthType(String type)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi getLdapValue().put("authType", type);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi public T runAs(String id)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi Reject.ifNull(id);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi jsonValue.put("runAs", id);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return self();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi private List<String> getControlsAsString(List<Control> controls)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi List<String> list = new ArrayList<>();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi for (final Control control : controls)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi list.add(control.getOID());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return list;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi private String getAdditionalItemsAsString(Operation operation)
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi StringBuilder items = new StringBuilder();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi for (final AdditionalLogItem item : operation.getAdditionalLogItems())
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi items.append(' ');
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi item.toString(items);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return items.toString();
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi private JsonValue getLdapValue()
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi final JsonValue ldapValue;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi if (jsonValue.isDefined("ldap"))
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue = jsonValue.get("ldap");
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi else
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi {
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi ldapValue = json(object());
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi jsonValue.put("ldap", ldapValue);
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi return ldapValue;
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi }
e433824f46514e6ed863eb6b95c70038331c8c24Nicolas Capponi}