XQuery/Publishing to Subversion
Motivation
editTo have a single button on a content management system that will copy a file to a remote subversion repository.
Method
editConfiguration of the subversion repository on a standard Apache server that is configured with an SSL certificate. This will encrypt all communication between the intranet system and the remote subversion server. We will also set the authentication to be Basic Authentication.
Apache Configuration File
edit<Location "/testsvn/">
DAV svn
AuthName "svntest"
SVNParentPath /Library/Subversion/RepositoryTest
SVNAutoversioning on
<Limit GET HEAD OPTIONS CONNECT POST PROPFIND PUT DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require user testuser1 testuser2 testuser3
</Limit>
AuthType Basic
</Location>
HTTP Put Function for Basic Authentication
editHTTP Basic authentication requires the user to concatenate the user and password with a colon separating the strings and then do a base64-encoding on that string. This is then sent in the HTTP header with the key of "Authorization". The HTTP header must look like the following:
Authorization = Basic BASE64-ENCODED-USER-PASSWORD
The following XQuery function performs this process.
declare function http:put-basic-auth($url, $content, $username, $password, $in-header) as node(){
let $credentials := concat($username, ':', $password)
let $encode := util:base64-encode($credentials)
let $value := concat('Basic ', $encode)
let $new-headers :=
<headers>
{$in-header/header}
<header name="Authorization" value="{$value}"/>
</headers>
let $response := httpclient:put($url, $content, false(), $new-headers)
return $response
};
To put the file, put the URL in the correct content area, and the content to be inserted, the user name and password and
Monitoring HTTP Client Libraries
editDebugging authentication protocols is very difficult if you do not have the correct tools. A useful tool is to enable logging for the httpclient module.
<category name="org.apache.commons.httpclient" additivity="false">
<priority value="debug"/>
<appender-ref ref="console"/>
</category>