Search in sources :

Example 11 with JsonObject

use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.

the class RecordReport method globalInformationReport.

/**
     * Create the global information report
     * * @return
     */
private JsonValue globalInformationReport(Record record) {
    JsonObject report = JsonValueBuilder.jsonValue();
    synchronized (dateFormat) {
        report.put(DATE_LABEL, dateFormat.format(new Date()));
    }
    report.put(OPENAM_VERSION_LABEL, SystemPropertiesManager.get(Constants.AM_VERSION));
    // OpenAM properties contain a part of the OpenAM configuration, we need to have the config export enable
    if (record.getRecordProperties().isConfigExportEnabled()) {
        JsonObject openAMPropertiesJson = JsonValueBuilder.jsonValue();
        Properties sysProps = SystemProperties.getProperties();
        for (String propertyName : sysProps.stringPropertyNames()) {
            report.put(propertyName, sysProps.getProperty(propertyName));
        }
        report.put(OPENAM_PROPERTIES_LABEL, openAMPropertiesJson.build().asMap());
    }
    return report.build();
}
Also used : JsonObject(org.forgerock.openam.utils.JsonObject) Properties(java.util.Properties) SystemProperties(com.iplanet.am.util.SystemProperties) Date(java.util.Date)

Example 12 with JsonObject

use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.

the class RecordResource method actionStop.

/**
     * Stop action
     *
     * @return
     */
private Promise<ActionResponse, ResourceException> actionStop() {
    try {
        Record record = debugRecorder.stopRecording();
        if (record == null) {
            return new BadRequestException("No record or it's already stopped.").asPromise();
        } else {
            JsonObject result = JsonValueBuilder.jsonValue();
            result.put(STATUS_LABEL, false);
            result.put(RECORD_LABEL, record.exportJson().asMap());
            return newResultPromise(newActionResponse(result.build()));
        }
    } catch (RecordException e) {
        debug.message("Record can't be stopped.", e);
        return new BadRequestException("Record can't be stopped.", e).asPromise();
    }
}
Also used : BadRequestException(org.forgerock.json.resource.BadRequestException) JsonObject(org.forgerock.openam.utils.JsonObject)

Example 13 with JsonObject

use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.

the class RecordResource method actionStatus.

/**
     * Status action
     *
     * @return
     */
private Promise<ActionResponse, ResourceException> actionStatus() {
    Record currentRecord = debugRecorder.getCurrentRecord();
    JsonObject jsonValue = JsonValueBuilder.jsonValue();
    if (currentRecord != null) {
        jsonValue.put(STATUS_LABEL, true);
        jsonValue.put(RECORD_LABEL, currentRecord.exportJson().asMap());
    } else {
        jsonValue.put(STATUS_LABEL, false);
    }
    return newResultPromise(newActionResponse(jsonValue.build()));
}
Also used : JsonObject(org.forgerock.openam.utils.JsonObject)

Example 14 with JsonObject

use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.

the class RecordProperties method toJson.

/**
     * Export a record properties into json
     *
     * @param recordProperties
     * @return json representing the record properties
     */
public static JsonValue toJson(RecordProperties recordProperties) {
    JsonObject jsonProperties = JsonValueBuilder.jsonValue();
    // Global
    jsonProperties.put(RecordConstants.ISSUE_ID_LABEL, recordProperties.issueID);
    jsonProperties.put(RecordConstants.REFERENCE_ID_LABEL, recordProperties.referenceID);
    jsonProperties.put(RecordConstants.DESCRIPTION_LABEL, recordProperties.description);
    jsonProperties.put(RecordConstants.ZIP_ENABLE_LABEL, recordProperties.zipEnable);
    // Sub json
    jsonProperties.put(RecordConstants.THREAD_DUMP_LABEL, toThreadDumpJson(recordProperties).asMap());
    jsonProperties.put(RecordConstants.CONFIG_EXPORT_LABEL, toConfigExportJson(recordProperties).asMap());
    jsonProperties.put(RecordConstants.DEBUG_LOGS_LABEL, toDebugLogsJson(recordProperties).asMap());
    return jsonProperties.build();
}
Also used : JsonObject(org.forgerock.openam.utils.JsonObject)

Example 15 with JsonObject

use of org.forgerock.openam.utils.JsonObject in project OpenAM by OpenRock.

the class RecordProperties method toThreadDumpJson.

/**
     * Export the thread dump json block
     *
     * @param recordProperties
     * @return the thread dump json block
     */
private static JsonValue toThreadDumpJson(RecordProperties recordProperties) {
    JsonObject threadsDumpsProperties = JsonValueBuilder.jsonValue();
    threadsDumpsProperties.put(RecordConstants.THREAD_DUMP_ENABLE_LABEL, recordProperties.threadDumpEnable);
    if (recordProperties.threadDumpEnable) {
        JsonObject threadsDumpsDelayProperties = JsonValueBuilder.jsonValue();
        threadsDumpsDelayProperties.put(RecordConstants.THREAD_DUMP_DELAY_TIME_UNIT_LABEL, TimeUnit.SECONDS.toString());
        threadsDumpsDelayProperties.put(RecordConstants.THREAD_DUMP_DELAY_VALUE_LABEL, recordProperties.threadDumpDelayInSeconds);
        threadsDumpsProperties.put(RecordConstants.THREAD_DUMP_DELAY_LABEL, threadsDumpsDelayProperties.build().asMap());
    }
    return threadsDumpsProperties.build();
}
Also used : JsonObject(org.forgerock.openam.utils.JsonObject)

Aggregations

JsonObject (org.forgerock.openam.utils.JsonObject)16 SystemProperties (com.iplanet.am.util.SystemProperties)2 Properties (java.util.Properties)2 NotFoundException (org.forgerock.json.resource.NotFoundException)2 STSPublishException (org.forgerock.openam.sts.STSPublishException)2 JsonArray (org.forgerock.openam.utils.JsonArray)2 SSOToken (com.iplanet.sso.SSOToken)1 PagePropertiesCallback (com.sun.identity.authentication.spi.PagePropertiesCallback)1 RedirectCallback (com.sun.identity.authentication.spi.RedirectCallback)1 Date (java.util.Date)1 Locale (java.util.Locale)1 JsonValue (org.forgerock.json.JsonValue)1 BadRequestException (org.forgerock.json.resource.BadRequestException)1 AuthenticationContext (org.forgerock.openam.core.rest.authn.core.AuthenticationContext)1 RestAuthErrorCodeException (org.forgerock.openam.core.rest.authn.exceptions.RestAuthErrorCodeException)1 RestAuthException (org.forgerock.openam.core.rest.authn.exceptions.RestAuthException)1 RestAuthResponseException (org.forgerock.openam.core.rest.authn.exceptions.RestAuthResponseException)1 RestSTSInstanceConfig (org.forgerock.openam.sts.rest.config.user.RestSTSInstanceConfig)1 SoapSTSInstanceConfig (org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig)1