[Asterisk-Dev] Cisco 79xx XML-Push Authentication
Alexander Noack
alex at aiesec.wiwi.uni-rostock.de
Fri Apr 16 14:10:45 MST 2004
Rich Adamson wrote:
>
> Can you give us an config example?
>
Sorry if I haven't been very clear ....
Assume you want to push an XML-Object to the 79xx (works for the SCCP
image, might work for the 6.x SIP image).
The Push is done by posting a "CiscoIPPhoneExecute" with the URL of
the Object you want to be loaded. The POSTing has to be directed to
the phone at the URL "/CGI/Execute" and must use HTTP Basic
Authentication.
Upon the request the phone contacts the Authentication service as
stated in the phone's config file (see post
http://lists.digium.com/pipermail/asterisk-dev/2004-March/003456.html
). The data transmitted contains the UserID, Password and devicename
(POST data) which your script will have to decide upon what to do
next. A possible answer can be "ERROR", "UN-AUTHORIZED" or
"AUTHORIZED", printed without any headers.
After the authentication succeeds, the requested URL is pulled, and
the resulting object is displayed.
Thus,
1.) create a SEP<MACADDRESS>.cnf.xml (see link above) and add an
entry to the "<authenticationURL>" pointing to your authentication
script. A simple authentication script, always allowing access, would
be
<?php
echo "AUTHORIZED";
?>
(This doesn't check UserID and Password)
2.) send an Execute Object to the phone, containing the URL you want
to be pulled
<?php
#
# This is an example of CiscoIPPhoneExecute as seen in the SDK
#
# Usage: Simply include in your php program and call the funtion
# using the parameters:
# $ip = IP of phone we're pushing to
# $uri = the URL or URI we want the phone
to execute
# $uid = the user id to authenticate
against to the phone
# $pwd = the password to authenticate
#
#
# Author: alex at aiesec.uni-rostock.de, Oct. 2003
#
function push2phone($ip, $uri, $uid, $pwd)
{
$auth = base64_encode($uid.":".$pwd);
$xml = "<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"
URL=\"".$uri."\"/></CiscoIPPhoneExecute>";
$xml = "XML=".urlencode($xml);
$post = "POST /CGI/Execute HTTP/1.0\r\n";
$post .= "Host: $ip\r\n";
$post .= "Authorization: Basic $auth\r\n";
$post .= "Connection: close\r\n";
$post .= "Content-Type: application/x-www-form-urlencoded\r\n";
$post .= "Content-Length: ".strlen($xml)."\r\n\r\n";
$fp = fsockopen ( $ip, 80, $errno, $errstr, 30);
if(!$fp){ echo "$errstr ($errno)<br>\n"; }
else
{
fputs($fp, $post.$xml);
flush();
while (!feof($fp))
{
$response .= fgets($fp, 128);
flush();
}
}
return $response;
}
##############################
$ip = "your.CISCO.phone.here";
$uri = "http://your.web.server.here/hello_world.php";
$uid = "test";
$pwd = "test";
echo push2phone($ip, $uri, $uid, $pwd);
?>
You can call the above script from the command line (using php) or
whatever interface you require. Other than pulling XML-Objects from
your server, you could also initiate RTP streams as stated in the
Cisco docs.
Hope that helped :)
Alex
More information about the asterisk-dev
mailing list