summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-03-05 18:55:21 +0000
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-03-05 18:55:21 +0000
commit61541af68cc6efb633d4e528cbc41bd0f4349588 (patch)
treedb28f0f255d453806d8aa9e69e80e7549ba73f95
parent3501e65c8f34b5ef779cc92572b320c3887dcc0e (diff)
downloadrabbitmq-server-61541af68cc6efb633d4e528cbc41bd0f4349588.tar.gz
Added -callbacks for rabbit_auth_mechanism.
-rw-r--r--include/rabbit_auth_mechanism_spec.hrl28
-rw-r--r--src/rabbit_auth_mechanism.erl56
-rw-r--r--src/rabbit_auth_mechanism_amqplain.erl2
-rw-r--r--src/rabbit_auth_mechanism_cr_demo.erl2
-rw-r--r--src/rabbit_auth_mechanism_plain.erl2
5 files changed, 33 insertions, 57 deletions
diff --git a/include/rabbit_auth_mechanism_spec.hrl b/include/rabbit_auth_mechanism_spec.hrl
deleted file mode 100644
index 9a2f5e05..00000000
--- a/include/rabbit_auth_mechanism_spec.hrl
+++ /dev/null
@@ -1,28 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and
-%% limitations under the License.
-%%
-%% The Original Code is RabbitMQ.
-%%
-%% The Initial Developer of the Original Code is VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--ifdef(use_specs).
-
--spec(description/0 :: () -> [{atom(), any()}]).
--spec(should_offer/1 :: (rabbit_net:socket()) -> boolean()).
--spec(init/1 :: (rabbit_net:socket()) -> any()).
--spec(handle_response/2 :: (binary(), any()) ->
- {'ok', rabbit_types:user()} |
- {'challenge', binary(), any()} |
- {'protocol_error', string(), [any()]} |
- {'refused', string(), [any()]}).
-
--endif.
diff --git a/src/rabbit_auth_mechanism.erl b/src/rabbit_auth_mechanism.erl
index 0c8251b8..eda6a743 100644
--- a/src/rabbit_auth_mechanism.erl
+++ b/src/rabbit_auth_mechanism.erl
@@ -16,31 +16,41 @@
-module(rabbit_auth_mechanism).
+-ifdef(use_specs).
+
+%% A description.
+-callback description() -> [proplist:property()].
+
+%% If this mechanism is enabled, should it be offered for a given socket?
+%% (primarily so EXTERNAL can be SSL-only)
+-callback should_offer(rabbit_net:socket()) -> boolean().
+
+%% Called before authentication starts. Should create a state
+%% object to be passed through all the stages of authentication.
+-callback init(rabbit_net:socket()) -> any().
+
+%% Handle a stage of authentication. Possible responses:
+%% {ok, User}
+%% Authentication succeeded, and here's the user record.
+%% {challenge, Challenge, NextState}
+%% Another round is needed. Here's the state I want next time.
+%% {protocol_error, Msg, Args}
+%% Client got the protocol wrong. Log and die.
+%% {refused, Msg, Args}
+%% Client failed authentication. Log and die.
+-callback handle_response(binary(), any()) ->
+ {'ok', rabbit_types:user()} |
+ {'challenge', binary(), any()} |
+ {'protocol_error', string(), [any()]} |
+ {'refused', string(), [any()]}.
+
+-else.
+
-export([behaviour_info/1]).
behaviour_info(callbacks) ->
- [
- %% A description.
- {description, 0},
-
- %% If this mechanism is enabled, should it be offered for a given socket?
- %% (primarily so EXTERNAL can be SSL-only)
- {should_offer, 1},
-
- %% Called before authentication starts. Should create a state
- %% object to be passed through all the stages of authentication.
- {init, 1},
-
- %% Handle a stage of authentication. Possible responses:
- %% {ok, User}
- %% Authentication succeeded, and here's the user record.
- %% {challenge, Challenge, NextState}
- %% Another round is needed. Here's the state I want next time.
- %% {protocol_error, Msg, Args}
- %% Client got the protocol wrong. Log and die.
- %% {refused, Msg, Args}
- %% Client failed authentication. Log and die.
- {handle_response, 2}
- ];
+ [{description, 0}, {should_offer, 1}, {init, 1}, {handle_response, 2}];
behaviour_info(_Other) ->
undefined.
+
+-endif.
diff --git a/src/rabbit_auth_mechanism_amqplain.erl b/src/rabbit_auth_mechanism_amqplain.erl
index 3de6e7a6..c0d86cd1 100644
--- a/src/rabbit_auth_mechanism_amqplain.erl
+++ b/src/rabbit_auth_mechanism_amqplain.erl
@@ -21,8 +21,6 @@
-export([description/0, should_offer/1, init/1, handle_response/2]).
--include("rabbit_auth_mechanism_spec.hrl").
-
-rabbit_boot_step({?MODULE,
[{description, "auth mechanism amqplain"},
{mfa, {rabbit_registry, register,
diff --git a/src/rabbit_auth_mechanism_cr_demo.erl b/src/rabbit_auth_mechanism_cr_demo.erl
index 64b01d8e..5df1d5d7 100644
--- a/src/rabbit_auth_mechanism_cr_demo.erl
+++ b/src/rabbit_auth_mechanism_cr_demo.erl
@@ -21,8 +21,6 @@
-export([description/0, should_offer/1, init/1, handle_response/2]).
--include("rabbit_auth_mechanism_spec.hrl").
-
-rabbit_boot_step({?MODULE,
[{description, "auth mechanism cr-demo"},
{mfa, {rabbit_registry, register,
diff --git a/src/rabbit_auth_mechanism_plain.erl b/src/rabbit_auth_mechanism_plain.erl
index 19fb5875..423170e1 100644
--- a/src/rabbit_auth_mechanism_plain.erl
+++ b/src/rabbit_auth_mechanism_plain.erl
@@ -21,8 +21,6 @@
-export([description/0, should_offer/1, init/1, handle_response/2]).
--include("rabbit_auth_mechanism_spec.hrl").
-
-rabbit_boot_step({?MODULE,
[{description, "auth mechanism plain"},
{mfa, {rabbit_registry, register,