Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Middleware
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ADAS
HEAppE
Middleware
Commits
17bdfa7d
Commit
17bdfa7d
authored
Feb 05, 2019
by
Vaclav Svaton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UserAndLimitationManagement fix
parent
c10f565c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
BusinessLogicTier/Logic/UserAndLimitationManagement/UserAndLimitationManagementLogic.cs
...dLimitationManagement/UserAndLimitationManagementLogic.cs
+21
-5
DomainObjects/UserAndLimitationManagement/AdaptorUser.cs
DomainObjects/UserAndLimitationManagement/AdaptorUser.cs
+1
-1
WebServices/WebServices.csproj.user
WebServices/WebServices.csproj.user
+1
-1
No files found.
BusinessLogicTier/Logic/UserAndLimitationManagement/UserAndLimitationManagementLogic.cs
View file @
17bdfa7d
...
...
@@ -18,8 +18,10 @@ namespace HaaSMiddleware.BusinessLogicTier.Logic.UserAndLimitationManagement {
internal
class
UserAndLimitationManagementLogic
:
IUserAndLimitationManagementLogic
{
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
private
readonly
IUnitOfWork
unitOfWork
;
private
const
int
cSaltBytes
=
12
;
private
const
int
cHashBytes
=
20
;
internal
UserAndLimitationManagementLogic
(
IUnitOfWork
unitOfWork
)
{
internal
UserAndLimitationManagementLogic
(
IUnitOfWork
unitOfWork
)
{
this
.
unitOfWork
=
unitOfWork
;
}
...
...
@@ -90,10 +92,24 @@ namespace HaaSMiddleware.BusinessLogicTier.Logic.UserAndLimitationManagement {
}
private
string
AuthenticateUserWithPassword
(
AdaptorUser
user
,
PasswordCredentials
credentials
)
{
if
(
user
.
Password
==
credentials
.
Password
)
return
CreateSessionCode
(
user
).
UniqueCode
;
log
.
Error
(
"Authentication of user "
+
user
.
Username
+
" was not successful due to wrong credentials."
);
throw
new
InvalidAuthenticationCredentialsException
(
"Authentication of user "
+
user
.
Username
+
" was not successful due to wrong credentials."
);
//get the bytes
byte
[]
hashBytes
=
Convert
.
FromBase64String
(
user
.
Password
);
//extract salt
byte
[]
salt
=
new
byte
[
cSaltBytes
];
Array
.
Copy
(
hashBytes
,
0
,
salt
,
0
,
cSaltBytes
);
//create password hash
var
pbkdf2
=
new
Rfc2898DeriveBytes
(
credentials
.
Password
,
salt
);
byte
[]
hash
=
pbkdf2
.
GetBytes
(
cHashBytes
);
//verify password
for
(
int
i
=
0
;
i
<
cHashBytes
;
i
++)
{
if
(
hashBytes
[
i
+
cSaltBytes
]
!=
hash
[
i
])
{
log
.
Error
(
"Authentication of user "
+
user
.
Username
+
" was not successful due to wrong credentials."
);
throw
new
InvalidAuthenticationCredentialsException
(
"Authentication of user "
+
user
.
Username
+
" was not successful due to wrong credentials."
);
}
}
return
CreateSessionCode
(
user
).
UniqueCode
;
}
public
IList
<
ResourceUsage
>
GetCurrentUsageAndLimitationsForUser
(
AdaptorUser
loggedUser
)
{
...
...
DomainObjects/UserAndLimitationManagement/AdaptorUser.cs
View file @
17bdfa7d
...
...
@@ -12,7 +12,7 @@ namespace HaaSMiddleware.DomainObjects.UserAndLimitationManagement {
[
StringLength
(
50
)]
public
string
Username
{
get
;
set
;
}
[
StringLength
(
3
0
)]
[
StringLength
(
5
0
)]
public
string
Password
{
get
;
set
;
}
[
Column
(
TypeName
=
"text"
)]
...
...
WebServices/WebServices.csproj.user
View file @
17bdfa7d
...
...
@@ -2,7 +2,7 @@
<Project
ToolsVersion=
"12.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<NameOfLastUsedPublishProfile>
Local
</NameOfLastUsedPublishProfile>
<LastActiveSolutionConfig>
Release
|Any CPU
</LastActiveSolutionConfig>
<LastActiveSolutionConfig>
Debug
|Any CPU
</LastActiveSolutionConfig>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
...
...
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