GW2GetPolicySettings
    • PDF

    GW2GetPolicySettings

    • PDF

    Article summary

    The GW2GetPolicySettings function returns the content management policy settings used for a session.

    Synopsis

    A pointer to the information is placed in the object pointed to by policiesBuffer and the size, in bytes, of the data pointed to is placed in the size_t object pointed to by policiesLength. The format of the data will be in the format specified by format.

    #include "glasswall.core2.api.h"
    
    int GW2GetPolicySettings (
        Session session,
        char **policiesBuffer,
        size_t *policiesLength,
        Policy_format format);

    Returns

    Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

    Synopsis

    /// <summary>
    /// Retrieves policy settings for the session
    /// </summary>
    /// <param name="session">Current open Glasswall session</param>
    /// <param name="policiesBufferPtr">A pointer to the object containing a pointer pointing to the policy data</param>
    /// <param name="policiesLengthPtr">A pointer to a object containing the size in bytes </param>
    public  int GetPolicySettings(
        int session,
        out IntPtr policiesBufferPtr,
        ref UIntPtr policiesLengthPtr,
        int format)

    Returns

    Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

    Synopsis

    import com.glasswall.core2javabridge.*;
    
    public String GW2GetPolicySettingsString(int session, int format) throws GlasswallException

    Note:

    The GW2GetPolicySettingsString function outputs the currently registered policy settings for the session specified by session.

    Please refer to API Overview for Return Types and valid enumerators for format.

    This functionality previously required two separate function calls to retrieve the policy setting data. This has now been streamlined to return the settings as a String. The two original functions have been deprecated.

    Returns

    The GW2GetPolicySettingsString function returns a String containing the policy settings.

    A GlasswallException exception will be thrown if session is invalid, or if the policy settings could not be retrieved.

    Synopsis - Deprecated Functions

    import com.glasswall.core2javabridge.*;
    
    (Deprecated)
    public int GW2GetPolicySettings(int session, int format) throws GlasswallException
    public byte[] GetPolicyBuffer(int session) throws GlasswallException

    Description - Deprecated Functions

    The GW2GetPolicySettings function outputs the currently registered policy settings for the session specified by session to the internal policy buffer. Retrieve this data through use of GetPolicyBuffer function. 

    Please refer to API Overview for Return Types and valid enumerators for format.

    Returns - Deprecated Functions

    The GW2GetPolicySettings function returns a GW2_RetStatus enumeration converted to int. The value will be negative if an error occurred. 0 indicates success.

    Please refer to API Overview for Return Types and their details.

    The GetPolicyBuffer returns a byte[] containing the policy settings. This will be null if GW2GetPolicySettings has not been called.

    A GlasswallException exception will be thrown if session is invalid, or if the policy settings could not be retrieved.

    Synopsis

    Returns the content management configuration for a given session.

    def get_content_management_policy(self, session: int):
        """ Returns the content management configuration for a given session.
    
        Args:
            session (int): The session integer.
    
        Returns:
            xml_string (str): The XML string of the current content management configuration.
        """

    Returns

    xml_string (str): The XML string of the current content management configuration.

    Synopsis

    /**
     * This function returns the policy settings used for the specified session
     *
     * @param {number} session The ID of the session.
     * @param {string} policiesBuffer The pointer to the policy buffer.
     * @param {number} policiesLength The size of the data in the policy buffer
     * @param {number} format The format of the policy.
     */
    
    GW2GetPolicySettings(
        session,
        policiesBuffer,
        policiesLength,
        format)

    Returns

    Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

    Example

    const ref = require('ref-napi');
    
    ...
    
    function buffer_to_string(buffer, buffer_size) {
    
        if (!buffer.isNull() && ref.deref(buffer_size) > 0) {
            return Buffer.from(ref.reinterpret(ref.deref(buffer), ref.deref(buffer_size), 0)).toString();
        }
        else {
            return "";
        }
    }
    
    ...
    
    let policy_file_buffer = ref.alloc(ref.refType(ref.types.CString));
    let policy_buffer_size = ref.alloc(ref.types.size_t, 0);
    
    let return_status = gw.GW2GetPolicySettings(session_id, policy_file_buffer, policy_buffer_size, 0);
    let xml_string = buffer_to_string(policy_file_buffer, policy_buffer_size);
    
    ...

    Was this article helpful?