Search in sources :

Example 1 with JsonObject

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

the class RestAuthLanguageCallbackHandler method convertToJson.

/**
     * {@inheritDoc}
     */
public JsonValue convertToJson(LanguageCallback callback, int index) {
    Locale locale = callback.getLocale();
    JsonObject jsonObject = JsonValueBuilder.jsonValue().put("type", CALLBACK_NAME);
    if (locale != null) {
        jsonObject.array("input").add(createInputField(index, "Language", locale.getLanguage())).addLast(createInputField(index, "Country", locale.getCountry()));
    }
    return jsonObject.build();
}
Also used : Locale(java.util.Locale) JsonObject(org.forgerock.openam.utils.JsonObject)

Example 2 with JsonObject

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

the class RecordProperties method toConfigExportJson.

/**
     * Export the config export json block
     *
     * @param recordProperties
     * @return the config export json block
     */
private static JsonValue toConfigExportJson(RecordProperties recordProperties) {
    JsonObject configExportProperties = JsonValueBuilder.jsonValue();
    configExportProperties.put(RecordConstants.CONFIG_EXPORT_ENABLE_LABEL, recordProperties.configExportEnable);
    if (recordProperties.configExportEnable) {
        if (recordProperties.configExportSharePassword) {
            configExportProperties.put(RecordConstants.CONFIG_EXPORT_PASSWORD_LABEL, recordProperties.configExportPassword);
        } else {
            configExportProperties.put(RecordConstants.CONFIG_EXPORT_PASSWORD_LABEL, NOT_SHARED_PASSWORD);
        }
        configExportProperties.put(RecordConstants.CONFIG_EXPORT_SHARE_PASSWORD_LABEL, recordProperties.configExportSharePassword);
    }
    return configExportProperties.build();
}
Also used : JsonObject(org.forgerock.openam.utils.JsonObject)

Example 3 with JsonObject

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

the class RecordProperties method toDebugLogsJson.

/**
     * Export the debug logs json block
     *
     * @param recordProperties
     * @return the debug logs json block
     */
private static JsonValue toDebugLogsJson(RecordProperties recordProperties) {
    JsonObject debugLogsProperties = JsonValueBuilder.jsonValue();
    debugLogsProperties.put(RecordConstants.DEBUG_LOGS_DEBUG_LEVEL_LABEL, recordProperties.debugLevel.toString());
    if (recordProperties.autoStopEnable) {
        JsonObject autoStopProperties = JsonValueBuilder.jsonValue();
        if (recordProperties.autoStopTimeEnable) {
            JsonObject timeProperties = JsonValueBuilder.jsonValue();
            timeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_TIME_UNIT_LABEL, TimeUnit.MILLISECONDS.toString());
            timeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_TIME_VALUE_LABEL, recordProperties.autoStopTimeInMS);
            autoStopProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_TIME_LABEL, timeProperties.build().asMap());
        }
        if (recordProperties.autoStopFileSizeEnable) {
            JsonObject fileSizeProperties = JsonValueBuilder.jsonValue();
            fileSizeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_FILESIZE_SIZEUNIT_LABEL, FileSizeUnit.KB.toString());
            fileSizeProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_FILESIZE_VALUE_LABEL, recordProperties.autoStopFileSizedInKB);
            autoStopProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_FILESIZE_LABEL, fileSizeProperties.build().asMap());
        }
        debugLogsProperties.put(RecordConstants.DEBUG_LOGS_AUTOSTOP_LABEL, autoStopProperties.build().asMap());
    }
    return debugLogsProperties.build();
}
Also used : JsonObject(org.forgerock.openam.utils.JsonObject)

Example 4 with JsonObject

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

the class RecordReport method getJVMInformation.

/**
     * Create the JVM information
     *
     * @return
     */
private JsonValue getJVMInformation() {
    JsonObject report = JsonValueBuilder.jsonValue();
    //Arguments
    List<String> arguments = runtimeMxBean.getInputArguments();
    JsonArray argumentsJson = report.array(JVM_ARGUMENTS_LABEL);
    for (String argument : arguments) {
        argumentsJson.add(argument);
    }
    // some useful jvm properties
    JsonObject propertiesJson = JsonValueBuilder.jsonValue();
    propertiesJson.put("java.vm.info", System.getProperty("java.vm.info"));
    propertiesJson.put("java.vm.name", System.getProperty("java.vm.info"));
    propertiesJson.put("java.vm.specification.name", System.getProperty("java.vm.specification.name"));
    propertiesJson.put("java.vm.specification.vendor", System.getProperty("java.vm.specification.vendor"));
    propertiesJson.put("java.vm.specification.version", System.getProperty("java.vm.specification.version"));
    propertiesJson.put("java.vm.vendor", System.getProperty("java.vm.vendor"));
    propertiesJson.put("java.vm.version", System.getProperty("java.vm.version"));
    report.put(JVM_PROPERTIES_LABEL, propertiesJson.build().asMap());
    report.put(JVM_JAVA_VERSION_LABEL, System.getProperty("java.version"));
    //Memory
    JsonObject memoryJson = JsonValueBuilder.jsonValue();
    memoryJson.put(JVM_UNIT_MEMORY_LABEL, FileSizeUnit.MB);
    //Getting the runtime reference from system
    Runtime runtime = Runtime.getRuntime();
    //Print used memory
    memoryJson.put(JVM_USED_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.totalMemory() - runtime.freeMemory()));
    //Print free memory
    memoryJson.put(JVM_FREE_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.freeMemory()));
    //Print total available memory
    memoryJson.put(JVM_TOTAL_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.totalMemory()));
    //Print Maximum available memory
    memoryJson.put(JVM_MAX_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.maxMemory()));
    //GNU systems don't support the "sun.arch.data.model" property, so we print both
    memoryJson.put(JVM_BIT_SIZE_GNU_LABEL, System.getProperty("sun.arch.data.model"));
    memoryJson.put(JVM_BIT_SIZE_LABEL, System.getProperty("os.arch"));
    report.put(JVM_MEMORY_LABEL, memoryJson.build().asMap());
    return report.build();
}
Also used : JsonArray(org.forgerock.openam.utils.JsonArray) JsonObject(org.forgerock.openam.utils.JsonObject)

Example 5 with JsonObject

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

the class RecordReport method getSystemProperties.

/**
     * Get the system properties
     *
     * @return
     */
private JsonValue getSystemProperties() {
    JsonObject report = JsonValueBuilder.jsonValue();
    Properties sysProps = System.getProperties();
    for (String propertyName : sysProps.stringPropertyNames()) {
        report.put(propertyName, sysProps.getProperty(propertyName));
    }
    return report.build();
}
Also used : JsonObject(org.forgerock.openam.utils.JsonObject) Properties(java.util.Properties) SystemProperties(com.iplanet.am.util.SystemProperties)

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