Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
32b6937e
Commit
32b6937e
authored
Aug 31, 2015
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #286 from guusdk/OF-939
OF-939: Should have safeguards against runtime exceptions.
parents
01fcd6e3
906583ec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
22 deletions
+42
-22
ScramSha1SaslServer.java
...a/org/jivesoftware/openfire/sasl/ScramSha1SaslServer.java
+42
-22
No files found.
src/java/org/jivesoftware/openfire/sasl/ScramSha1SaslServer.java
View file @
32b6937e
...
...
@@ -104,8 +104,10 @@ public class ScramSha1SaslServer implements SaslServer {
*/
@Override
public
byte
[]
evaluateResponse
(
final
byte
[]
response
)
throws
SaslException
{
try
{
byte
[]
challenge
;
switch
(
state
)
{
switch
(
state
)
{
case
INITIAL:
challenge
=
generateServerFirstMessage
(
response
);
state
=
State
.
IN_PROGRESS
;
...
...
@@ -115,7 +117,8 @@ public class ScramSha1SaslServer implements SaslServer {
state
=
State
.
COMPLETE
;
break
;
case
COMPLETE:
if
(
response
==
null
||
response
.
length
==
0
)
{
if
(
response
==
null
||
response
.
length
==
0
)
{
challenge
=
new
byte
[
0
];
break
;
}
...
...
@@ -124,6 +127,9 @@ public class ScramSha1SaslServer implements SaslServer {
}
return
challenge
;
}
catch
(
RuntimeException
ex
)
{
throw
new
SaslException
(
"Unexpected exception while evaluating SASL response."
,
ex
);
}
}
/**
...
...
@@ -182,8 +188,14 @@ public class ScramSha1SaslServer implements SaslServer {
try
{
String
authMessage
=
clientFirstMessageBare
+
","
+
serverFirstMessage
+
","
+
clientFinalMessageWithoutProof
;
byte
[]
storedKey
=
getStoredKey
(
username
);
byte
[]
storedKey
=
getStoredKey
(
username
);
if
(
storedKey
==
null
)
{
throw
new
SaslException
(
"No stored key for user '"
+
username
+
"'"
);
}
byte
[]
serverKey
=
getServerKey
(
username
);
if
(
serverKey
==
null
)
{
throw
new
SaslException
(
"No server key for user '"
+
username
+
"'"
);
}
byte
[]
clientSignature
=
ScramUtils
.
computeHmac
(
storedKey
,
authMessage
);
byte
[]
serverSignature
=
ScramUtils
.
computeHmac
(
serverKey
,
authMessage
);
...
...
@@ -328,15 +340,23 @@ public class ScramSha1SaslServer implements SaslServer {
* Retrieve the server key from the database for a given username.
*/
private
byte
[]
getServerKey
(
final
String
username
)
throws
UserNotFoundException
{
return
DatatypeConverter
.
parseBase64Binary
(
UserManager
.
getUserProvider
().
loadUser
(
username
).
getServerKey
());
final
String
serverKey
=
UserManager
.
getUserProvider
().
loadUser
(
username
).
getServerKey
();
if
(
serverKey
==
null
)
{
return
null
;
}
else
{
return
DatatypeConverter
.
parseBase64Binary
(
serverKey
);
}
}
/**
* Retrieve the stored key from the database for a given username.
*/
private
byte
[]
getStoredKey
(
final
String
username
)
throws
UserNotFoundException
{
return
DatatypeConverter
.
parseBase64Binary
(
UserManager
.
getUserProvider
().
loadUser
(
username
).
getStoredKey
());
final
String
storedKey
=
UserManager
.
getUserProvider
().
loadUser
(
username
).
getStoredKey
();
if
(
storedKey
==
null
)
{
return
null
;
}
else
{
return
DatatypeConverter
.
parseBase64Binary
(
storedKey
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment