use of org.simbasecurity.core.domain.UserEntity in project simba-os by cegeka.
the class RoleManagerServiceTest method setup.
@Before
public void setup() {
GlobalContext.initialize(locator);
when(locator.locate(UserValidator.class)).thenReturn(userValidator);
when(locator.locate(PasswordValidator.class)).thenReturn(passwordValidator);
when(locator.locate(ConfigurationServiceImpl.class)).thenReturn(configurationService);
UserEntity userEntity1 = new UserEntity("user-1");
UserEntity userEntity2 = new UserEntity("user-2");
ReflectionUtil.setField(entityFilterService, "filters", filterServices);
roleEntity1.addPolicy(policyEntity1);
roleEntity2.addPolicy(policyEntity2);
roleEntity3.addPolicy(policyEntity1);
roleEntity3.addPolicy(policyEntity2);
roleEntity1.addUser(userEntity1);
roleEntity2.addUser(userEntity2);
roleEntity3.addUser(userEntity1);
roleEntity3.addUser(userEntity2);
Collection<Role> roles = asList(roleEntity1, roleEntity2, roleEntity3);
when(roleRepository.findAll()).thenReturn(roles);
when(roleRepository.lookUp(roleDTO1)).thenReturn(roleEntity1);
when(roleRepository.lookUp(roleDTO2)).thenReturn(roleEntity2);
when(roleRepository.lookUp(roleDTO3)).thenReturn(roleEntity3);
when(policyRepository.findNotLinked(roleEntity1)).thenReturn(singletonList(policyEntity2));
when(policyRepository.findNotLinked(roleEntity2)).thenReturn(singletonList(policyEntity1));
when(policyRepository.findNotLinked(roleEntity3)).thenReturn(emptyList());
when(policyRepository.findForRole(roleEntity1)).thenReturn(singletonList(policyEntity1));
when(policyRepository.findForRole(roleEntity2)).thenReturn(singletonList(policyEntity2));
when(policyRepository.findForRole(roleEntity3)).thenReturn(asList(policyEntity1, policyEntity2));
when(userRepository.findNotLinked(roleEntity1)).thenReturn(singletonList(userEntity2));
when(userRepository.findNotLinked(roleEntity2)).thenReturn(singletonList(userEntity1));
when(userRepository.findNotLinked(roleEntity3)).thenReturn(emptyList());
when(userRepository.findForRole(roleEntity1)).thenReturn(singletonList(userEntity1));
when(userRepository.findForRole(roleEntity2)).thenReturn(singletonList(userEntity2));
when(userRepository.findForRole(roleEntity3)).thenReturn(asList(userEntity1, userEntity2));
}
use of org.simbasecurity.core.domain.UserEntity in project simba-os by cegeka.
the class UserDTOAssemblerTest method createUser.
private User createUser() {
User user = new UserEntity("username");
user.setFirstName("first name");
user.setName("name");
user.setStatus(Status.ACTIVE);
user.setSuccessURL("success url");
user.setLanguage(Language.en_US);
user.setChangePasswordOnNextLogon(true);
return user;
}
use of org.simbasecurity.core.domain.UserEntity in project simba-os by cegeka.
the class CreateEIDUserCommand method execute.
@Override
public State execute(ChainContext context) throws Exception {
SAMLUser samlUser = context.getSAMLUser();
User user = userService.findByName(samlUser.getInsz());
if (user == null) {
List<String> roles = configurationService.getValue(SimbaConfigurationParameter.DEFAULT_USER_ROLE);
user = new UserEntity(samlUser.getInsz());
user.setName(samlUser.getLastname());
user.setFirstName(samlUser.getFirstname());
user.setLanguage(getLanguageIfUnknownUseNL(samlUser));
user.setPasswordChangeRequired(false);
user.setChangePasswordOnNextLogon(false);
userService.create(user, roles);
audit.log(auditLogFactory.createEventForEIDSAMLResponse(context, "New user for eid created with username [" + user.getUserName() + "]"));
} else {
user.setName(samlUser.getLastname());
user.setFirstName(samlUser.getFirstname());
user.setLanguage(getLanguageIfUnknownUseNL(samlUser));
audit.log(auditLogFactory.createEventForEIDSAMLResponse(context, "Updated user with username [" + user.getUserName() + "] with new FAS data"));
}
context.setUserPrincipal(user.getUserName());
return State.CONTINUE;
}
use of org.simbasecurity.core.domain.UserEntity in project simba-os by cegeka.
the class RuleDatabaseRepositoryTest method setupWithGroups.
private ResourceRule setupWithGroups() {
User user = new UserEntity(USER_VIA_GROUP);
Role role = new RoleEntity("role2");
Group group = new GroupEntity("groupName", "cn");
Policy policy = new PolicyEntity("policy2");
ResourceRule resourceRuleEntity = new ResourceRuleEntity("resrule2");
resourceRuleEntity.setResourceName("resname2");
urlRuleEntityViaGroup = new URLRuleEntity("urlrule2");
persistAndRefresh(user, role, policy, resourceRuleEntity, urlRuleEntityViaGroup);
persistAndRefresh(user, group, role, policy, resourceRuleEntity, urlRuleEntityViaGroup);
policy.addRule(resourceRuleEntity);
policy.addRule(urlRuleEntityViaGroup);
role.addPolicy(policy);
group.addRole(role);
user.addGroup(group);
return resourceRuleEntity;
}
use of org.simbasecurity.core.domain.UserEntity in project simba-os by cegeka.
the class SessionDatabaseRepositoryTest method canFindBySSOToken.
@Test
public void canFindBySSOToken() throws Exception {
User user = new UserEntity("jos");
SSOToken ssoToken = new SSOToken("eenSsoTokentje");
SessionEntity session = new SessionEntity(user, ssoToken, "127.0.0.1", "192.168.1.1");
persistAndRefresh(user, session);
assertEquals(session, sessionDatabaseRepository.findBySSOToken(ssoToken));
}
Aggregations