nsmcp::FileCredentials method prepare (protected)

 <instance of nsmcp::FileCredentials[i]> prepare name

Defined in /usr/local/ns/tcl/nsmcp/lib/credentials.tcl

Parameters:
name (required)

Testcases:
No testcase defined.
Source code:
set section ${:section}/credential/$name
set path [ns_config $section tokenFile {}]
if {[file pathtype $path] ne "absolute" || ![file isfile $path] || ![file readable $path]} {
    error "credential $name requires a readable absolute tokenFile"
}
set principal [ns_config $section principal $name]
set permissions [ns_config $section permissions {}]
if {$principal eq ""} {error "credential $name requires a principal"}
llength $permissions
set expires [ns_config $section expires 0]
if {![string is wideinteger -strict $expires] || ($expires != 0 && $expires <= [clock seconds])} {
    error "credential $name has an invalid or expired expiry"
}
set f [open $path rb]
try {set raw [read $f 4097]} finally {close $f}
if {[string length $raw] > 4096} {error "credential $name has an oversized token file"}
set token [string trim $raw "\r\n"]
if {[string length $token] < 32 || [string length $token] > 4096 ||
    ![regexp {^[A-Za-z0-9._~+/-]+=*$} $token]} {
    error "credential $name has an invalid token file"
}
set digest [ns_crypto::md string -digest sha256 -- $token]
return [dict create token $token digest $digest tokenFile $path principal $principal  permissions $permissions targets [list [ns_info server]] expires $expires]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: