~ubuntu-branches/ubuntu/quantal/xen-api/quantal

« back to all changes in this revision

Viewing changes to ocaml/xapi/xapi_auth.ml

  • Committer: Package Import Robot
  • Author(s): Jon Ludlam
  • Date: 2011-07-07 21:50:18 UTC
  • Revision ID: package-import@ubuntu.com-20110707215018-3t9ekbh7qy5y2b1p
Tags: upstream-1.3
ImportĀ upstreamĀ versionĀ 1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(*
 
2
 * Copyright (C) 2006-2009 Citrix Systems Inc.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published
 
6
 * by the Free Software Foundation; version 2.1 only. with the special
 
7
 * exception on linking described in file LICENSE.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU Lesser General Public License for more details.
 
13
 *)
 
14
(**
 
15
 * @group Access Control
 
16
 *)
 
17
 
 
18
open Auth_signature
 
19
open Extauth
 
20
 
 
21
 
 
22
let call_with_exception_handler fn =
 
23
        try fn () with
 
24
                | Extauth.Extauth_is_disabled ->
 
25
                        raise (Api_errors.Server_error(Api_errors.auth_is_disabled, [])) 
 
26
                | Extauth.Unknown_extauth_type msg ->
 
27
                        raise (Api_errors.Server_error(Api_errors.auth_unknown_type, [msg]))
 
28
                | Not_found 
 
29
                | Auth_signature.Subject_cannot_be_resolved ->
 
30
                        raise (Api_errors.Server_error(Api_errors.subject_cannot_be_resolved, []))
 
31
                | Auth_signature.Auth_service_error (errtag,msg) ->
 
32
                        raise (Api_errors.Server_error(Api_errors.auth_service_error, [msg]))
 
33
                | e -> 
 
34
                        raise (Api_errors.Server_error(Api_errors.auth_service_error, [ExnHelper.string_of_exn e]))
 
35
 
 
36
(* PRECONDITION: All of these additional calls require a valid session to be presented.*)
 
37
(* ==> the session validity is already checked in every server.ml call by using Session_check.check *)
 
38
 
 
39
let get_subject_identifier ~__context ~subject_name =
 
40
        call_with_exception_handler (fun () -> ((Ext_auth.d()).get_subject_identifier subject_name))
 
41
 
 
42
let get_group_membership ~__context ~subject_identifier = 
 
43
        call_with_exception_handler (fun () -> ((Ext_auth.d()).query_group_membership subject_identifier))
 
44
 
 
45
let get_subject_information_from_identifier ~__context ~subject_identifier = 
 
46
        call_with_exception_handler (fun () -> ((Ext_auth.d()).query_subject_information subject_identifier))
 
47