function Aastra_check_signature_Asterisk($user)
{
    global $AA_FREEPBX_MODE;
    global $AA_PHONE_SIGNATURE;
    # Return if device/user mode
    if ($AA_FREEPBX_MODE == '2' or !$AA_PHONE_SIGNATURE) {
        return;
    }
    # Retrieve stored signature
    $signature = Aastra_read_signature($user);
    # Maybe a first time
    if ($signature['signature'] == '') {
        # Store the signature
        Aastra_store_signature($user);
    } else {
        # Check signature
        if (Aastra_getphone_fingerprint() != $signature['signature']) {
            # Debug
            Aastra_debug('function=Aastra_check_signature, Phone fingerprint mismatch. Stored=' . $signature['signature'] . ' Current= ' . Aastra_getphone_fingerprint());
            # Display Error
            $output = "<AastraIPPhoneTextScreen>\n";
            $output .= "<Title>Authentication Error</Title>\n";
            $output .= "<Text>You are not authorized to use this application. Please contact your administrator.</Text>\n";
            $output .= "</AastraIPPhoneTextScreen>\n";
            header("Content-Type: text/xml");
            header("Content-Length: " . strlen($output));
            echo $output;
            exit;
        }
    }
}
function Aastra_store_signature($user)
{
    # Store the signature
    $header = Aastra_decode_HTTP_header();
    $signature['mac'] = $header['mac'];
    $signature['ip'] = $header['ip'];
    $signature['model'] = $header['model'];
    $signature['signature'] = Aastra_getphone_fingerprint();
    Aastra_save_user_context($user, 'signature', $signature);
}