Results 1 to 2 of 2

Thread: [SOLVED] Rest Get Calendar Authentication

  1. #1
    Join Date
    Mar 2011
    Location
    Charleston, IL
    Posts
    2
    Rep Power
    4

    Default [SOLVED] Rest Get Calendar Authentication

    I am new to Zimbra and I am trying to get calendar events fed from Zimbra into our database using a PL SQL script from Oracle. I am trying to use the REST API Get Calendar Method. I can establish the connection through the URL directly from IE, but it prompts me. I am trying to get around the prompt, so that I can establish the connection without being prompted. Does anyone have a suggestion on how to handle this?

    Here is the code I am trying to execute:

    ************************************************** ********

    SET SERVEROUTPUT ON;
    declare
    http_response varchar2(4000);

    BEGIN
    DBMS_OUTPUT.ENABLE(1000000);


    http_response := utl_http.request('http://cherry.serv15.eiu.edu/service/home/mldrake@testmail.eiu.edu/Calendar?fmt=xml');



    DBMS_OUTPUT.PUT_LINE( http_response);

    END;
    .
    RUN

    ************************************************** ********

    Any help would be greatly appreciated! Thanks so much.

  2. #2
    Join Date
    Mar 2011
    Location
    Charleston, IL
    Posts
    2
    Rep Power
    4

    Default Zimbra authentication SOLVED for REST Get Calendar

    We have figured out how to do this.

    here is the code for PL SQL in Oracle:
    ************************************************** ********
    SET SERVEROUTPUT ON;
    declare
    l_key varchar2(2000) := 'af26789543ac'; --This is whatever your zimbraPreAuth key value is from the Zimbra server l_current_timestamp number;
    l_preauth_values varchar2(2000);
    l_mac raw(2000);
    http_response varchar2(4000);

    BEGIN
    DBMS_OUTPUT.ENABLE(1000000);

    --This calls the get_date_millis function and returns the date back in milliseconds
    l_current_timestamp := get_date_millis(sysdate);

    --This builds the string that is required to generate the hmac
    l_preauth_values := 'mbwalton@test.iu.edu|name|0|'|| l_current_timestamp;


    --This converts the zimbraPreAuth key to a hash value to send securely to Zimbra to establish a login connection/authentication
    l_mac := dbms_crypto.mac ( UTL_I18N.STRING_TO_RAW (l_preauth_values, 'UTF8'), dbms_crypto.hmac_sh1, UTL_I18N.STRING_TO_RAW (l_key, 'UTF8'));

    --This actually makes the request to the Zimbra Server and does the preauthentication sending it the values that the zimbra preauth.txt file shows us to send, including the hmac value generated
    http_response := utl_http.request('http://server.serv20.iu.edu/service/preauth?account=mbwalton@test.iu.edu'||chr(38)|| 'expires=0'|| chr(38)||'timestamp=' || l_current_timestamp || chr(38) ||'preauth=' || l_mac || chr(38) || 'redirectURL=http://server.serv20.iu.edu/service/home/mbwalton/Calendar?fmt=xml' );
    --This will return xml data of all the CalendarsDBMS_OUTPUT.PUT_LINE(http_response);

    END;

    ************************************************** ********

    Here is the created function that we call above to turn the date into milliseconds because Oracle does not have a function for this.

    create or replace function get_date_millis (i_date in date) return number is
    begin
    return to_number(
    to_date(to_char((cast(i_date as timestamp)) at time zone 'gmt', 'yyyy.mm.dd hh24:mi:ss'),
    'yyyy.mm.dd hh24:mi:ss')
    - to_date('01.01.1970','dd.mm.yyyy')
    ) * (24 * 60 * 60 * 1000);
    end;
    /



    IMPORTANT: You can find the preauth.txt file on your Zimbra server under the /opt/zimbra/docs path.
    I hope this helps!

Similar Threads

  1. Cannot Import ics Calendar via REST
    By amartin in forum Migration
    Replies: 2
    Last Post: 07-23-2014, 12:37 AM
  2. Replies: 2
    Last Post: 01-27-2011, 08:46 AM
  3. Authentication failed on Calendar and Contacts
    By MrMEEE in forum Evolution Connector
    Replies: 18
    Last Post: 09-07-2007, 07:40 AM
  4. Remote calendar that requires basic authentication
    By Flyen in forum Administrators
    Replies: 5
    Last Post: 04-04-2006, 11:49 AM
  5. Replies: 1
    Last Post: 03-03-2006, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •