Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public AbstractUser createNewUser(NewUserRequest newUser) {
}
log.info("Renewing old user [{}]", newUser.email);
} else {
user = new User();
user = new com.netgrif.application.engine.adapter.spring.auth.domain.User();
user.setEmail(newUser.email);
user.setUsername(newUser.email);
log.info("Creating new user [{}]", newUser.email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private LoggedUser resolveLoggedUser(String existingToken) {
}

private LoggedUser createAnonymousUser() {
User anonymousUser = new User();
User anonymousUser = new com.netgrif.application.engine.adapter.spring.auth.domain.User();
anonymousUser.setState(UserState.ACTIVE);
anonymousUser = (User) userService.saveUser(anonymousUser, null);
return ActorTransformer.toLoggedUser(anonymousUser);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.netgrif.application.engine.petrinet.service;

import com.netgrif.application.engine.adapter.spring.petrinet.domain.arcs.InhibitorArc;
import com.netgrif.application.engine.adapter.spring.petrinet.domain.arcs.ReadArc;
import com.netgrif.application.engine.adapter.spring.petrinet.domain.arcs.ResetArc;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.Arc;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.InhibitorArc;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.ReadArc;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.ResetArc;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.reference.Reference;
import com.netgrif.application.engine.objects.petrinet.domain.arcs.reference.Type;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -14,15 +13,15 @@ public final class ArcFactory {
public Arc getArc(com.netgrif.application.engine.objects.importer.model.Arc arc) throws IllegalArgumentException {
switch (arc.getType()) {
case REGULAR:
return new Arc();
return new com.netgrif.application.engine.adapter.spring.petrinet.domain.arcs.Arc();
case RESET:
return new ResetArc();
case INHIBITOR:
return new InhibitorArc();
case READ:
return new ReadArc();
case VARIABLE:
Arc varArc = new Arc();
Arc varArc = new com.netgrif.application.engine.adapter.spring.petrinet.domain.arcs.Arc();
Reference ref = new Reference();
ref.setReference(String.valueOf(arc.getMultiplicity()));
varArc.setReference(ref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class PetriNetEventHandler extends AbstractMongoEventListener<PetriNet> {

@Autowired
private IElasticPetriNetService service;

@Override
public void onAfterDelete(AfterDeleteEvent<PetriNet> event) {
Document document = event.getDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import com.netgrif.application.engine.adapter.spring.petrinet.domain.roles.RoleReferencedException;
import com.netgrif.application.engine.adapter.spring.utils.PaginationProperties;
import com.netgrif.application.engine.auth.service.GroupService;
import com.netgrif.application.engine.objects.auth.domain.AbstractUser;
import com.netgrif.application.engine.objects.auth.domain.*;
import com.netgrif.application.engine.auth.service.RealmService;
import com.netgrif.application.engine.objects.auth.domain.Group;
import com.netgrif.application.engine.objects.auth.domain.LoggedUser;
import com.netgrif.application.engine.auth.service.UserService;
import com.netgrif.application.engine.objects.auth.domain.Realm;
import com.netgrif.application.engine.objects.event.events.user.UserRoleChangeEvent;
import com.netgrif.application.engine.objects.importer.model.EventPhaseType;
import com.netgrif.application.engine.objects.petrinet.domain.PetriNet;
Expand Down Expand Up @@ -121,30 +118,29 @@ public void deleteAll() {

@Override
public void assignRolesToUser(AbstractUser user, Collection<ProcessResourceId> processResourceIds, LoggedUser loggedUser) {
assignRolesToActor(user.getProcessRoles(), processResourceIds);
assignRolesToActor(user, processResourceIds);
saveUserAndReloadContext(user, loggedUser);
}

@Override
public void assignRolesToGroup(Group group, Collection<ProcessResourceId> requestedRolesIds) {
assignRolesToActor(group.getProcessRoles(), requestedRolesIds);
assignRolesToActor(group, requestedRolesIds);
groupService.save(group);
}

protected void assignRolesToActor(Collection<ProcessRole> oldActorRoles, Collection<ProcessResourceId> requestedRolesIds) {
protected void assignRolesToActor(AbstractActor abstractActor, Collection<ProcessResourceId> requestedRolesIds) {
List<ProcessRole> requestedRoles = this.findByIds(requestedRolesIds.stream().map(ProcessResourceId::toString).collect(Collectors.toSet()));
if (requestedRoles.isEmpty() && !requestedRolesIds.isEmpty())
throw new IllegalArgumentException("No process roles found.");
if (requestedRoles.size() != requestedRolesIds.size())
throw new IllegalArgumentException("Not all process roles were found!");

Set<ProcessRole> userOldRoles = new HashSet<>(oldActorRoles);
Set<ProcessRole> userOldRoles = new HashSet<>(abstractActor.getProcessRoles());
Set<ProcessRole> rolesNewToUser = getRolesNewToActor(userOldRoles, requestedRoles);
Set<ProcessRole> rolesRemovedFromUser = getRolesRemovedFromActor(userOldRoles, requestedRoles);


oldActorRoles.clear();
oldActorRoles.addAll(updateRequestedRoles(userOldRoles, rolesNewToUser, rolesRemovedFromUser));
abstractActor.clearProcessRoles();
abstractActor.addAllProcessRoles(updateRequestedRoles(userOldRoles, rolesNewToUser, rolesRemovedFromUser));
}

protected void saveUserAndReloadContext(AbstractUser user, LoggedUser loggedUser) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private AbstractUser createSuperUser() {

Optional<AbstractUser> superUser = userService.findUserByUsername(UserConstants.ADMIN_USER_USERNAME, null);
if (superUser.isEmpty()) {
User user = new User();
User user = new com.netgrif.application.engine.adapter.spring.auth.domain.User();
user.setFirstName(UserConstants.ADMIN_USER_FIRST_NAME);
user.setLastName(UserConstants.ADMIN_USER_LAST_NAME);
user.setUsername(UserConstants.ADMIN_USER_USERNAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AssignActionTest {

auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])

importHelper.createUser(new User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: USER_PASSWORD, state: UserState.ACTIVE),
importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: USER_PASSWORD, state: UserState.ACTIVE),
[auths.get("user"), auths.get("admin")] as Authority[],
// [org] as Group[],
[] as ProcessRole[])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class RemoveActionTest {

def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])

importHelper.createUser(new User(firstName: "Test", lastName : "Integration", email: USER_EMAIL, password: USER_PASSWORD, state: UserState.ACTIVE),
importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Test", lastName : "Integration", email: USER_EMAIL, password: USER_PASSWORD, state: UserState.ACTIVE),
[auths.get("user")] as Authority[],
[] as ProcessRole[])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class LoginAttemptsTest {
.build()

auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])
importHelper.createUser(new User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: USER_PASSWORD, state: UserState.ACTIVE),
importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: USER_PASSWORD, state: UserState.ACTIVE),
[auths.get("user"), auths.get("admin")] as Authority[],
[] as ProcessRole[])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SecurityContextTest {
@BeforeEach
void before() {
testHelper.truncateDbs()
user = new User()
user = new com.netgrif.application.engine.adapter.spring.auth.domain.User()
user.setUsername('test@email.com')
user.setEmail('test@email.com')
user.setCredential("password", new PasswordCredential('password', 0, true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class TaskAuthorizationServiceTest {
this.netWithUserRefs = netWithUserRefs.getNet()

def auths = importHelper.createAuthorities(["user": Authority.user])
testUser = importHelper.createUser(new User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
testUser = importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
[auths.get("user")] as Authority[],
// [org] as Group[],
[] as ProcessRole[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class UserServiceTest {
Optional<AbstractUser> userOptional = userService.findUserByUsername("dummy@netgrif.com", null)
User user = null
if (userOptional.isEmpty()) {
user = new User()
user = new com.netgrif.application.engine.adapter.spring.auth.domain.User()
user.setFirstName("Dummy")
user.setLastName("User")
user.setUsername("dummy@netgrif.com")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class WorkflowAuthorizationServiceTest {
this.netWithUserRefs = netWithUserRefs.getNet()

def auths = importHelper.createAuthorities(["user": Authority.user])
testUser = importHelper.createUser(new User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
testUser = importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
[auths.get("user")]as Authority[],
// [org] as Group[],
[] as ProcessRole[])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ElasticSearchTest {
// def org = importHelper.createGroup("Test")
def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])
// def processRoles = importHelper.getProcessRoles(net.get())
def testUser = importHelper.createUser(new User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: USER_PASSW, state: UserState.ACTIVE),
def testUser = importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: USER_PASSW, state: UserState.ACTIVE),
[auths.get("user")] as Authority[],
[net.roles.values().find { it.importId == "process_role" }] as ProcessRole[])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class FilterImportExportTest {

private User createDummyUser() {
def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])
return importHelper.createUser(new User(firstName: "Dummy", lastName: "User", email: DUMMY_USER_MAIL, username: DUMMY_USER_MAIL, password: DUMMY_USER_PASSWORD, state: UserState.ACTIVE),
return importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Dummy", lastName: "User", email: DUMMY_USER_MAIL, username: DUMMY_USER_MAIL, password: DUMMY_USER_PASSWORD, state: UserState.ACTIVE),
[auths.get("user")] as Authority[],
[] as ProcessRole[])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,21 @@ class ImpersonationServiceTest {
def authorityAnon = authorityService.getOrCreate(Authority.anonymous)
def authorityAdmin = authorityService.getOrCreate(Authority.admin)

user1 = helper.createUser(new User(firstName: "Test", lastName: "User", email: "test@netgrif.com", "username": "test@netgrif.com", password: "password", state: UserState.ACTIVE),
user1 = helper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Test", lastName: "User", email: "test@netgrif.com", "username": "test@netgrif.com", password: "password", state: UserState.ACTIVE),
[authority] as Authority[],
[] as ProcessRole[])

auth1 = new UsernamePasswordAuthenticationToken(ActorTransformer.toLoggedUser(user1), (user1 as User).password, user1.authoritySet as List<GrantedAuthority>)
auth1.setDetails(new WebAuthenticationDetails(new MockHttpServletRequest()))

user2 = helper.createUser(new User(firstName: "Test", lastName: "User2", email: "test2@netgrif.com", "username": "test2@netgrif.com", password: "password", state: UserState.ACTIVE),
user2 = helper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Test", lastName: "User2", email: "test2@netgrif.com", "username": "test2@netgrif.com", password: "password", state: UserState.ACTIVE),
[authority, authorityAnon] as Authority[],
testNet.roles.values() as ProcessRole[])

auth2 = new UsernamePasswordAuthenticationToken(ActorTransformer.toLoggedUser(user2), (user2 as User).password, user2.authoritySet as List<GrantedAuthority>)
auth2.setDetails(new WebAuthenticationDetails(new MockHttpServletRequest()))

adminUser = helper.createUser(new User(firstName: "Admin", lastName: "User", email: "admin@netgrif.com", "username": "admin@netgrif.com", password: "password", state: UserState.ACTIVE),
adminUser = helper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Admin", lastName: "User", email: "admin@netgrif.com", "username": "admin@netgrif.com", password: "password", state: UserState.ACTIVE),
[authority, authorityAdmin] as Authority[],
testNet.roles.values() as ProcessRole[])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class InsuranceTest {

def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])
def processRoles = ImportHelper.getProcessRolesByImportId(net.getNet(), ["agent": "1", "company": "2"])
importHelper.createUser(new User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Test", lastName: "Integration", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
[auths.get("user"), auths.get("admin")] as Authority[],
[processRoles.get("agent"), processRoles.get("company")] as ProcessRole[])
List<ProcessRole> roles = processRoleService.findAll(netId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class MenuImportExportTest {

private User createDummyUser() {
def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])
return importHelper.createUser(new User(firstName: "Dummy", lastName: "User", email: DUMMY_USER_MAIL, password: DUMMY_USER_PASSWORD, state: UserState.ACTIVE),
return importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Dummy", lastName: "User", email: DUMMY_USER_MAIL, password: DUMMY_USER_PASSWORD, state: UserState.ACTIVE),
[auths.get("user")] as Authority[],
[] as ProcessRole[])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class GroupServiceTest {
void groupTest() {
testHelper.truncateDbs()
def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])
importHelper.createUser(new User(firstName: "Dummy", lastName: "User", email: DUMMY_USER_MAIL, username: DUMMY_USER_MAIL, password: "password", state: UserState.ACTIVE),
importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Dummy", lastName: "User", email: DUMMY_USER_MAIL, username: DUMMY_USER_MAIL, password: "password", state: UserState.ACTIVE),
[auths.get("user")] as Authority[],
[] as ProcessRole[])
importHelper.createUser(new User(firstName: "Customer", lastName: "User", email: CUSTOMER_USER_MAIL, username: CUSTOMER_USER_MAIL, password: "password", state: UserState.ACTIVE),
importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Customer", lastName: "User", email: CUSTOMER_USER_MAIL, username: CUSTOMER_USER_MAIL, password: "password", state: UserState.ACTIVE),
[auths.get("user")] as Authority[],
[] as ProcessRole[])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ElasticSearchViewPermissionTest {

userAuthority = authorityService.getOrCreate(Authority.user)

testUser = importHelper.createUser(new User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
testUser = importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
[userAuthority] as Authority[], [] as ProcessRole[])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class QueryDSLViewPermissionTest {

userAuthority = authorityService.getOrCreate(Authority.user)

testUser = importHelper.createUser(new User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
testUser = importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Role", lastName: "User", email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
[userAuthority] as Authority[], [] as ProcessRole[])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class FileFieldTest {

def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])

def adminUser = importHelper.createUser(new User(firstName: "Admin", lastName: "User", username: UserConstants.ADMIN_USER_USERNAME, email: UserConstants.ADMIN_USER_EMAIL, password: "password", state: UserState.ACTIVE),
def adminUser = importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Admin", lastName: "User", username: UserConstants.ADMIN_USER_USERNAME, email: UserConstants.ADMIN_USER_EMAIL, password: "password", state: UserState.ACTIVE),
[auths.get("admin")] as Authority[],
// [] as Group[],
[] as ProcessRole[])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class FileListFieldTest {

def auths = importHelper.createAuthorities(["user": Authority.user, "admin": Authority.admin])

def adminUser = importHelper.createUser(new User(firstName: "Admin", lastName: "User", username: UserConstants.ADMIN_USER_USERNAME, email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
def adminUser = importHelper.createUser(new com.netgrif.application.engine.adapter.spring.auth.domain.User(firstName: "Admin", lastName: "User", username: UserConstants.ADMIN_USER_USERNAME, email: USER_EMAIL, password: "password", state: UserState.ACTIVE),
[auths.get("admin")] as Authority[],
// [] as Group[],
[] as ProcessRole[])
Expand Down
Loading
Loading