25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

SASL errors are now atoms, not strings anymore.

SVN Revision: 1420
This commit is contained in:
Jean-Sébastien Pédron 2008-07-08 15:43:52 +00:00
parent 13b78b1ad2
commit 1a687a4f1a
6 changed files with 27 additions and 25 deletions

View File

@ -1,3 +1,9 @@
2008-07-08 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/cyrsasl.erl, src/cyrsasl_anonymous.erl, src/cyrsasl_digest.erl,
src/cyrsasl_plain.erl, src/ejabberd_c2s.erl: Errors are now atoms, not
strings anymore.
2008-07-01 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/ejabberd_sm.erl: Convert to exmpp.

View File

@ -86,14 +86,14 @@ register_mechanism(Mechanism, Module, RequirePlainPassword) ->
%% end.
check_credentials(_State, Props) ->
User = xml:get_attr_s(username, Props),
case jlib:nodeprep(User) of
error ->
{error, "not-authorized"};
"" ->
{error, "not-authorized"};
_LUser ->
ok
case proplists:get_value(username, Props) of
undefined ->
{error, 'not-authorized'};
User ->
case exmpp_stringprep:is_node(User) of
false -> {error, 'not-authorized'};
true -> ok
end
end.
listmech(Host) ->
@ -133,10 +133,10 @@ server_start(State, Mech, ClientIn) ->
mech_state = MechState},
ClientIn);
_ ->
{error, "no-mechanism"}
{error, 'no-mechanism'}
end;
false ->
{error, "no-mechanism"}
{error, 'no-mechanism'}
end.
server_step(State, ClientIn) ->

View File

@ -50,7 +50,7 @@ mech_step(State, _ClientIn) ->
%% Checks that the username is available
case ejabberd_auth:is_user_exists(User, Server) of
true -> {error, "not-authorized"};
true -> {error, 'not-authorized'};
false -> {ok, [{username, User},
{auth_module, ejabberd_auth_anonymous}]}
end.

View File

@ -39,13 +39,13 @@ mech_step(#state{step = 1, nonce = Nonce} = State, _) ->
mech_step(#state{step = 3, nonce = Nonce} = State, ClientIn) ->
case parse(ClientIn) of
bad ->
{error, "bad-protocol"};
{error, 'bad-protocol'};
KeyVals ->
UserName = xml:get_attr_s("username", KeyVals),
AuthzId = xml:get_attr_s("authzid", KeyVals),
case (State#state.get_password)(UserName) of
{false, _} ->
{error, "not-authorized", UserName};
{error, 'not-authorized', UserName};
{Passwd, AuthModule} ->
Response = response(KeyVals, UserName, Passwd,
Nonce, AuthzId, "AUTHENTICATE"),
@ -61,7 +61,7 @@ mech_step(#state{step = 3, nonce = Nonce} = State, ClientIn) ->
username = UserName,
authzid = AuthzId}};
_ ->
{error, "not-authorized", UserName}
{error, 'not-authorized', UserName}
end
end
end;
@ -73,7 +73,7 @@ mech_step(#state{step = 5,
{auth_module, AuthModule}]};
mech_step(A, B) ->
?DEBUG("SASL DIGEST: A ~p B ~p", [A,B]),
{error, "bad-protocol"}.
{error, 'bad-protocol'}.
parse(S) ->

View File

@ -51,10 +51,10 @@ mech_step(State, ClientIn) ->
{ok, [{username, User}, {authzid, AuthzId},
{auth_module, AuthModule}]};
_ ->
{error, "not-authorized", User}
{error, 'not-authorized', User}
end;
_ ->
{error, "bad-protocol"}
{error, 'bad-protocol'}
end.

View File

@ -515,15 +515,13 @@ wait_for_feature_request({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
"(~w) Failed authentication for ~s@~s",
[StateData#state.socket,
Username, StateData#state.server]),
% XXX OLD FORMAT: list_to_atom(Error).
send_element(StateData,
exmpp_server_sasl:failure(list_to_atom(Error))),
exmpp_server_sasl:failure(Error)),
{next_state, wait_for_feature_request, StateData,
?C2S_OPEN_TIMEOUT};
{error, Error} ->
% XXX OLD FORMAT: list_to_atom(Error).
send_element(StateData,
exmpp_server_sasl:failure(list_to_atom(Error))),
exmpp_server_sasl:failure(Error)),
fsm_next_state(wait_for_feature_request, StateData)
end;
{?NS_TLS, 'starttls'} when TLS == true,
@ -631,14 +629,12 @@ wait_for_sasl_response({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
"(~w) Failed authentication for ~s@~s",
[StateData#state.socket,
Username, StateData#state.server]),
% XXX OLD FORMAT: list_to_atom(Error).
send_element(StateData,
exmpp_server_sasl:failure(list_to_atom(Error))),
exmpp_server_sasl:failure(Error)),
fsm_next_state(wait_for_feature_request, StateData);
{error, Error} ->
% XXX OLD FORMAT: list_to_atom(Error).
send_element(StateData,
exmpp_server_sasl:failure(list_to_atom(Error))),
exmpp_server_sasl:failure(Error)),
fsm_next_state(wait_for_feature_request, StateData)
end;
_ ->