Package org.forgerock.audit.json
Class AuditJsonConfig
- java.lang.Object
-
- org.forgerock.audit.json.AuditJsonConfig
-
public final class AuditJsonConfig extends Object
Utility class to facilitate creation and configuration of audit service and audit event handlers through JSON.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JsonValue
getAuditEventHandlerConfigurationSchema(String className, ClassLoader classLoader)
Gets the configuration schema for an audit event handler as json schema.static JsonValue
getJson(InputStream input)
Returns a JSON value from the provided input stream.static <C extends EventHandlerConfiguration>
CparseAuditEventHandlerConfiguration(Class<C> clazz, JsonValue jsonConfig)
Returns the audit event handler configuration from the provided JSON string.static AuditServiceConfiguration
parseAuditServiceConfiguration(InputStream input)
Returns the audit service configuration from the provided input stream.static AuditServiceConfiguration
parseAuditServiceConfiguration(String json)
Returns the audit service configuration from the provided JSON string.static AuditServiceConfiguration
parseAuditServiceConfiguration(JsonValue json)
Returns the audit service configuration from the provided JSON value.static void
registerHandlerToService(JsonValue jsonConfig, AuditServiceBuilder auditServiceBuilder)
Configures and registers the audit event handler corresponding to the provided JSON configuration to the provided audit service.static void
registerHandlerToService(JsonValue jsonConfig, AuditServiceBuilder auditServiceBuilder, ClassLoader classLoader)
Configures and registers the audit event handler corresponding to the provided JSON configuration to the provided audit service, using a specific class loader.
-
-
-
Method Detail
-
getJson
public static JsonValue getJson(InputStream input) throws AuditException
Returns a JSON value from the provided input stream.- Parameters:
input
- Input stream containing an arbitrary JSON structure.- Returns:
- the JSON value corresponding to the JSON structure
- Throws:
AuditException
- If an error occurs.
-
parseAuditServiceConfiguration
public static AuditServiceConfiguration parseAuditServiceConfiguration(InputStream input) throws AuditException
Returns the audit service configuration from the provided input stream.- Parameters:
input
- Input stream containing JSON configuration of the audit service.- Returns:
- the configuration object
- Throws:
AuditException
- If any error occurs.
-
parseAuditServiceConfiguration
public static AuditServiceConfiguration parseAuditServiceConfiguration(String json) throws AuditException
Returns the audit service configuration from the provided JSON string.- Parameters:
json
- JSON string representing the configuration of the audit service.- Returns:
- the configuration object
- Throws:
AuditException
- If any error occurs.
-
parseAuditServiceConfiguration
public static AuditServiceConfiguration parseAuditServiceConfiguration(JsonValue json) throws AuditException
Returns the audit service configuration from the provided JSON value.- Parameters:
json
- JSON value representing the configuration of the audit service.- Returns:
- the configuration object
- Throws:
AuditException
- If any error occurs.
-
registerHandlerToService
public static void registerHandlerToService(JsonValue jsonConfig, AuditServiceBuilder auditServiceBuilder) throws AuditException
Configures and registers the audit event handler corresponding to the provided JSON configuration to the provided audit service.- Parameters:
jsonConfig
- The configuration of the audit event handler as JSON.auditServiceBuilder
- The builder for the service the event handler will be registered to.- Throws:
AuditException
- If any error occurs during configuration or registration of the handler.
-
registerHandlerToService
public static void registerHandlerToService(JsonValue jsonConfig, AuditServiceBuilder auditServiceBuilder, ClassLoader classLoader) throws AuditException
Configures and registers the audit event handler corresponding to the provided JSON configuration to the provided audit service, using a specific class loader.- Parameters:
jsonConfig
- The configuration of the audit event handler as JSON.auditServiceBuilder
- The builder for the service the event handler will be registered to.classLoader
- The class loader to use to load the handler and its configuration class.- Throws:
AuditException
- If any error occurs during configuration or registration of the handler.
-
parseAuditEventHandlerConfiguration
public static <C extends EventHandlerConfiguration> C parseAuditEventHandlerConfiguration(Class<C> clazz, JsonValue jsonConfig) throws AuditException
Returns the audit event handler configuration from the provided JSON string.- Type Parameters:
C
- The type of the configuration bean for the event handler.- Parameters:
jsonConfig
- The configuration of the audit event handler as JSON.clazz
- The class for type<C>
.- Returns:
- the fully configured audit event handler
- Throws:
AuditException
- If any error occurs while instantiating the configuration from JSON.
-
getAuditEventHandlerConfigurationSchema
public static JsonValue getAuditEventHandlerConfigurationSchema(String className, ClassLoader classLoader) throws AuditException
Gets the configuration schema for an audit event handler as json schema. The supplied json config must contain a field called class with the value of the audit event handler implementation class.- Parameters:
className
- The class name to get the configuration for.classLoader
- TheClassLoader
to use to load the event handler and event handler config class.- Returns:
- The config schema as json schema.
- Throws:
AuditException
- If any error occurs parsing the config class for schema.
-
-