driver-procs.tcl

Does not contain a contract.

Location:
/packages/acs-authentication/tcl/driver-procs.tcl

Related Files

[ hide source ] | [ make this the default ]

File Contents

ad_library {
    Procs for driver parameters service contract implementations.

    @author Simon Carstensen (simon@collaobraid.biz)
    @creation-date 2003-08-27
    @cvs-id $Id: driver-procs.tcl,v 1.13.2.1 2019/09/11 13:10:22 antoniop Exp $
}

namespace eval auth {}
namespace eval auth::driver {}



#####
#
# auth::driver
#
#####

d_proc -public auth::driver::get_parameters {
    {-impl_id:required}
} {
    Returns a list of names of parameters for the driver

    @author Simon Carstensen (simon@collaboraid.biz)
    @creation-date 2003-08-27
} {
    if { $impl_id eq "" } {
        return {}
    }

    set parameters {}

    ad_try {
        set parameters [acs_sc::invoke \
                            -error \
                            -impl_id $impl_id \
                            -operation GetParameters]
    } on error {errorMsg} {
        ad_log Error "Error getting parameters for impl_id $impl_id: $errorMsg"
    }
    return $parameters
}

d_proc -public auth::driver::get_parameter_values {
    {-authority_id:required}
    {-impl_id:required}
} {
    Gets a list of parameter values ready to be passed to a service contract implementation.
    If a parameter doesn't have a value, the value will be the empty string.

    @author Simon Carstensen (simon@collaboraid.biz)
    @creation-date 2003-08-27
} {
    array set param [list]

    db_foreach select_values {
        select key, value
        from   auth_driver_params
        where  impl_id = :impl_id
        and    authority_id = :authority_id
    } {
        set param($key$value
    }

    # We need to ensure that the driver gets all the parameters it is asking for, and nothing but the ones it is asking for
    set params [list]
    foreach { name desc } [get_parameters -impl_id $impl_id] {
        if { [info exists param($name)] } {
            lappend params $name $param($name)
        } else {
            lappend params $name {}
        }
    }

    return $params
}

d_proc -public auth::driver::set_parameter_value {
    {-authority_id:required}
    {-impl_id:required}
    {-parameter:required}
    {-value:required}
} {
    Updates the parameter value in the database.

    @author Simon Carstensen (simon@collaboraid.biz)
    @creation-date 2003-08-27
} {
    set exists_p [db_string param_exists_p {}]

    if { $exists_p } {
        db_dml update_parameter {} -clobs [list $value]
    } else {
        db_dml insert_parameter {} -clobs [list $value]
    }
}

d_proc -deprecated -public auth::driver::GetParameters {
    {-impl_id:required}
} {
    Returns a list of names of parameters for the driver

    This proc duplicates auth::driver::get_parameters

    @see auth::driver::get_parameters

    @author Simon Carstensen (simon@collaboraid.biz)
    @creation-date 2003-08-27
} {
    return [acs_sc::invoke \
                -error \
                -impl_id $impl_id \
                -operation GetParameters]
}


# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: