Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
eea3adb3
Commit
eea3adb3
authored
Jul 16, 2019
by
Sascha Herzinger
Browse files
feedback by piotr
parent
7dc02a8d
Pipeline
#11785
failed with stage
in 10 minutes and 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/users/UserController.java
View file @
eea3adb3
...
...
@@ -40,7 +40,7 @@ public class UserController extends BaseController {
*/
@GetMapping
(
value
=
"/isSessionValid"
)
@PreAuthorize
(
"isAuthenticated() and authentication.name != '"
+
Configuration
.
ANONYMOUS_LOGIN
+
"'"
)
public
Object
isSessionValid
(
Authentication
authentication
)
{
public
Object
isSessionValid
()
{
return
new
TreeMap
<>();
}
...
...
web/src/main/java/lcsb/mapviewer/web/config/LdapAuthenticationProvider.java
View file @
eea3adb3
package
lcsb.mapviewer.web.config
;
import
com.unboundid.ldap.sdk.LDAPException
;
import
lcsb.mapviewer.common.Configuration
;
import
lcsb.mapviewer.model.user.User
;
import
lcsb.mapviewer.services.UserDTO
;
import
lcsb.mapviewer.services.interfaces.ILdapService
;
...
...
@@ -16,7 +15,6 @@ import org.springframework.security.core.Authentication;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.stereotype.Service
;
@Order
(
2
)
...
...
@@ -26,24 +24,21 @@ public class LdapAuthenticationProvider implements AuthenticationProvider {
private
IUserService
userService
;
private
ILdapService
ldapService
;
private
UserDetailsService
userDetailsService
;
private
PasswordEncoder
passwordEncoder
;
@Autowired
public
LdapAuthenticationProvider
(
IUserService
userService
,
ILdapService
ldapService
,
UserDetailsService
userDetailsService
,
PasswordEncoder
passwordEncoder
)
{
UserDetailsService
userDetailsService
)
{
this
.
userService
=
userService
;
this
.
ldapService
=
ldapService
;
this
.
userDetailsService
=
userDetailsService
;
this
.
passwordEncoder
=
passwordEncoder
;
}
@Override
public
Authentication
authenticate
(
Authentication
authentication
)
throws
AuthenticationException
{
String
username
=
authentication
.
getName
().
toLowerCase
();
if
(
username
.
isEmpty
())
{
throw
new
UsernameNotFound
Exception
(
"Invalid username."
);
throw
new
BadCredentials
Exception
(
"Invalid username."
);
}
boolean
ldapLoginSuccess
;
...
...
@@ -83,7 +78,6 @@ public class LdapAuthenticationProvider implements AuthenticationProvider {
}
User
newUser
=
new
User
();
newUser
.
setLogin
(
userDTO
.
getLogin
());
newUser
.
setCryptedPassword
(
passwordEncoder
.
encode
((
String
)
authentication
.
getCredentials
()));
newUser
.
setConnectedToLdap
(
true
);
newUser
.
setName
(
userDTO
.
getFirstName
());
newUser
.
setSurname
(
userDTO
.
getLastName
());
...
...
web/src/main/java/lcsb/mapviewer/web/config/LocalAuthenticationProvider.java
View file @
eea3adb3
...
...
@@ -5,6 +5,7 @@ import lcsb.mapviewer.services.interfaces.IUserService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.security.authentication.AuthenticationProvider
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.InternalAuthenticationServiceException
;
import
org.springframework.security.authentication.dao.DaoAuthenticationProvider
;
import
org.springframework.security.core.Authentication
;
...
...
@@ -45,7 +46,7 @@ public class LocalAuthenticationProvider implements AuthenticationProvider {
public
Authentication
authenticate
(
Authentication
authentication
)
throws
AuthenticationException
{
String
username
=
authentication
.
getName
();
if
(
username
.
isEmpty
())
{
throw
new
UsernameNotFound
Exception
(
"Username must not be empty."
);
throw
new
BadCredentials
Exception
(
"Username must not be empty."
);
}
User
user
=
userService
.
getUserByLogin
(
username
);
if
(
user
==
null
||
user
.
isConnectedToLdap
())
{
...
...
Piotr Gawron
@piotr.gawron
mentioned in commit
c5688502
·
Jul 16, 2019
mentioned in commit
c5688502
mentioned in commit c568850291fe9bc931c8e45d2b577eb81aa4e49e
Toggle commit list
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