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
A
App Blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Genesys PGR
App Blocks
Commits
1038e7d6
Commit
1038e7d6
authored
Jul 27, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test if password matches after user is created
parent
4ed845ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
security/src/main/java/org/genesys/blocks/security/service/impl/BasicUserServiceImpl.java
...ys/blocks/security/service/impl/BasicUserServiceImpl.java
+2
-3
security/src/main/java/org/genesys/blocks/security/service/impl/CustomAclServiceImpl.java
...ys/blocks/security/service/impl/CustomAclServiceImpl.java
+1
-1
security/src/test/java/org/genesys/blocks/security/component/AclAssignerTest.java
...rg/genesys/blocks/security/component/AclAssignerTest.java
+6
-4
No files found.
security/src/main/java/org/genesys/blocks/security/service/impl/BasicUserServiceImpl.java
View file @
1038e7d6
...
...
@@ -40,7 +40,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.crypto.password.NoOpPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -67,8 +66,8 @@ public abstract class BasicUserServiceImpl<R extends GrantedAuthority, T extends
private
JpaRepository
<
T
,
Long
>
_repository
;
/** The password encoder. */
@Autowired
(
required
=
false
)
protected
final
PasswordEncoder
passwordEncoder
=
NoOpPasswordEncoder
.
getInstance
()
;
@Autowired
protected
PasswordEncoder
passwordEncoder
;
/** The password policy. */
@Autowired
(
required
=
false
)
...
...
security/src/main/java/org/genesys/blocks/security/service/impl/CustomAclServiceImpl.java
View file @
1038e7d6
...
...
@@ -301,7 +301,7 @@ public class CustomAclServiceImpl implements CustomAclService {
*/
@Override
@Transactional
(
readOnly
=
true
)
@PreAuthorize
(
"
returnObject==null or
hasRole('ADMINISTRATOR') or hasPermission(#id, #className, 'ADMINISTRATION')"
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasPermission(#id, #className, 'ADMINISTRATION')"
)
public
AclObjectIdentity
getObjectIdentity
(
final
long
id
,
final
String
className
)
{
return
aclObjectIdentityPersistence
.
findByObjectIdAndClassname
(
id
,
className
);
}
...
...
security/src/test/java/org/genesys/blocks/security/component/AclAssignerTest.java
View file @
1038e7d6
...
...
@@ -15,9 +15,7 @@
*/
package
org.genesys.blocks.security.component
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
greaterThan
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
java.util.List
;
...
...
@@ -42,6 +40,7 @@ import org.junit.Test;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.test.context.transaction.AfterTransaction
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -58,7 +57,9 @@ public class AclAssignerTest extends BaseTest {
private
AclEntryPersistence
aclEntryPersistence
;
@Autowired
private
AclObjectIdentityPersistence
aclObjectIdentityPersistence
;
@Autowired
private
PasswordEncoder
passwordEncoder
;
private
TestUser
user
;
@Override
...
...
@@ -75,6 +76,7 @@ public class AclAssignerTest extends BaseTest {
@Before
public
void
setupSecurityContext
()
throws
NotUniqueUserException
,
PasswordPolicyException
,
UserException
{
user
=
testUserService
.
createUser
(
USER_EMAIL
,
USER_FULLNAME
,
"password1!"
,
AccountType
.
LOCAL
);
assertThat
(
passwordEncoder
.
matches
(
"password1!"
,
user
.
getPassword
()),
is
(
true
));
SecurityContextHolder
.
getContext
().
setAuthentication
(
new
UsernamePasswordAuthenticationToken
(
user
,
"bar"
));
}
...
...
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