Skip to content

Commit 36160e8

Browse files
committed
Start using codox to generate API documentation.
Document all of the functions in the process.
1 parent 0a76461 commit 36160e8

16 files changed

+1144
-544
lines changed

project.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:pedantic? :abort
77
:dependencies [[org.clojure/clojure "1.7.0"]
88
[net.n01se/clojure-jna "1.0.0"]]
9+
:profiles {:dev {:plugins [[lein-codox "0.9.1"]]}}
910
:deploy-repositories ^:replace [["clojars" {:url "https://clojars.org/repo"
1011
:username [:gpg :env/clojars_username]
1112
:password [:gpg :env/clojars_password]

src/clj_libssh2/agent.clj

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
(ns clj-libssh2.agent
2+
"Functions for interacting with an SSH agent. The agent is expected to be
3+
available on the UNIX domain socket referred to by the SSH_AUTH_SOCK
4+
environment variable."
25
(:require [clj-libssh2.error :refer [handle-errors with-timeout]]
3-
[clj-libssh2.libssh2 :as libssh2]
46
[clj-libssh2.libssh2.agent :as libssh2-agent])
57
(:import [com.sun.jna.ptr PointerByReference]))
68

79
(defn- get-identity
810
"Get the next available identity from the agent. Pass nil for previous to get
9-
the first entry."
11+
the first entry.
12+
13+
Arguments:
14+
15+
session A clj-libssh2.session.Session object.
16+
ssh-agent An ssh agent object from libssh2_agent_init.
17+
previous The last identity returned from a call to this function. Pass nil
18+
to get the first entry.
19+
20+
Return:
21+
22+
A native object as returned by libssh2_agent_get_identity."
1023
[session ssh-agent previous]
1124
(when (nil? previous)
1225
(handle-errors session
@@ -22,7 +35,18 @@
2235
(throw (Exception. "An unknown error occurred")))))
2336

2437
(defn authenticate
25-
"Attempt to authenticate a session using the agent."
38+
"Attempt to authenticate a session using the agent.
39+
40+
Arguments:
41+
42+
session A clj-libssh2.session.Session object which refers to a session
43+
which has not already been authenticated.
44+
username The username for the user who is trying to authenticate.
45+
46+
Return:
47+
48+
True on success. An exception will be thrown if the user could not be
49+
authenticated."
2650
[session username]
2751
(let [ssh-agent (libssh2-agent/init (:session session))]
2852
(when (nil? ssh-agent)

src/clj_libssh2/authentication.clj

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
(ns clj-libssh2.authentication
2+
"Authenticate a session."
23
(:require [clojure.java.io :refer [file]]
3-
[clj-libssh2.libssh2.userauth :as libssh2-userauth]
4-
[clj-libssh2.agent :as ssh-agent]
5-
[clj-libssh2.error :refer [handle-errors with-timeout]])
4+
[clj-libssh2.agent :as agent]
5+
[clj-libssh2.error :refer [handle-errors with-timeout]]
6+
[clj-libssh2.libssh2.userauth :as libssh2-userauth])
67
(:import clojure.lang.PersistentArrayMap))
78

89
(defprotocol Credentials
9-
(valid? [credentials]))
10+
"A datatype to represent a way of authentication and the necessary data to
11+
use that authentication method."
12+
(valid? [credentials]
13+
"Check if this Credentials instance is internally consistent."))
1014

1115
(defrecord AgentCredentials [username]
1216
Credentials
@@ -26,11 +30,25 @@
2630
(valid? [credentials] (and (some? username) (some? password))))
2731

2832
(defmulti authenticate
33+
"Authenticate a session.
34+
35+
Arguments:
36+
37+
session A clj-libssh2.session.Session object referring to an SSH
38+
session which has not yet been authenticated.
39+
credentials Either an instance of Credentials or a map which can be
40+
transformed into a Credentials object.
41+
42+
Return:
43+
44+
True on success. An exception will be thrown if ther session could not be
45+
authenticated."
46+
{:arglists '([session credentials])}
2947
(fn [session credentials] (type credentials)))
3048

3149
(defmethod authenticate AgentCredentials
3250
[session credentials]
33-
(ssh-agent/authenticate session (:username credentials)))
51+
(agent/authenticate session (:username credentials)))
3452

3553
(defmethod authenticate KeyCredentials
3654
[session credentials]

0 commit comments

Comments
 (0)