-
Notifications
You must be signed in to change notification settings - Fork 1
/
auth.clj
38 lines (34 loc) · 1.12 KB
/
auth.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(ns cral.alfresco.auth
(:require [clj-http.lite.client :as client]
[clojure.data.json :as json]
[cral.alfresco.config :as config]
[cral.utils.utils :as utils]
[cral.alfresco.model.auth])
(:import (clojure.lang PersistentHashMap)
(cral.alfresco.model.auth Ticket)))
(defn create-ticket
"Create a ticket."
[^String username ^String password & [^PersistentHashMap opts]]
(utils/call-rest
client/post
(format "%s/tickets" (config/get-url 'auth))
nil
{:content-type :json
:body (json/write-str {
:userId username
:password password})}
opts))
(defn- *-ticket [method ^Ticket ticket ^PersistentHashMap opts]
(utils/call-rest
method
(format "%s/tickets/-me-" (config/get-url 'auth))
ticket
opts))
(defn validate-ticket
"Validate a ticket."
[^Ticket ticket & [^PersistentHashMap opts]]
(*-ticket client/get ticket opts))
(defn delete-ticket
"Delete a ticket."
[^Ticket ticket & [^PersistentHashMap opts]]
(*-ticket client/delete ticket opts))