Index of all namespaces
easily create java.net.Authenticator instances
easily create java.net.Authenticator instances see http://docs.oracle.com/javase/8/docs/api/java/net/Authenticator.html
authenticator is a small Clojure library that can be used to easily implement a java.net.Authenticator.
Authenticators can be asked to provide username and password for network connections that require them.
(require '[authenticator.core :as auth]) (defn get-credentials [options] (println "options" options) (when (= (:host options) "localhost") ["user" "password"])) (auth/set-default-authenticator get-credentials) (slurp "http://localhost/secret/")
The get-credentials function above is called with a single map as argument. It contains the following keys:
- hostname of the site or proxy requesting authentication, or nil if not available
- port number for the requested connection
- prompt string given by the requestor
- protocol for the requested connection
- scheme for the requested connection
- InetAddress of the site requesting authorization, or null if not available
- URL that resulted in this request for authentication
- :proxy for a Proxy or :server otherwise
The function should return a [username, password] pair to be used with the connection or nil if it can’t supply credentials.
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.