From 3e71b6ffc74f37a7b393bfd7e8e93831df648e89 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Sun, 17 May 2015 18:53:14 +0300 Subject: [PATCH] Commit monger.credentials --- src/clojure/monger/credentials.clj | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/clojure/monger/credentials.clj diff --git a/src/clojure/monger/credentials.clj b/src/clojure/monger/credentials.clj new file mode 100644 index 0000000..aa49424 --- /dev/null +++ b/src/clojure/monger/credentials.clj @@ -0,0 +1,32 @@ +;; Copyright (c) 2011-2015 Michael S. Klishin +;; +;; The use and distribution terms for this software are covered by the +;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +;; which can be found in the file epl-v10.html at the root of this distribution. +;; By using this software in any fashion, you are agreeing to be bound by +;; the terms of this license. +;; You must not remove this notice, or any other, from this software. + +(ns monger.credentials + "Helper functions for instantiating various types + of credentials." + (:require [clojurewerkz.support.chars :refer :all]) + (:import [com.mongodb MongoCredential])) + +;; +;; API +;; + +(defn ^MongoCredential for + "Creates a MongoCredential instance with an unspecified mechanism. + The client will negotiate the best mechanism based on the + version of the server that the client is authenticating to." + [^String username ^String database pwd] + (MongoCredential/createCredential username database (to-char-array pwd))) + +(defn ^MongoCredential x509 + "Creates a MongoCredential instance for the X509-based authentication + protocol." + [^String username] + (MongoCredential/createMongoX509Credential username)) +