use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class SecurityServiceImpl method updateToken.
@Override
public void updateToken(final String series, final String token, final Date lastUsed) {
Entity persistentToken = getPersistentToken(series);
if (Objects.nonNull(persistentToken)) {
persistentToken.setField(PersistentTokenFields.TOKEN, token);
persistentToken.setField(PersistentTokenFields.LAST_USED, lastUsed);
getPersistentTokenDD().save(persistentToken);
}
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class SecurityServiceImpl method getUsers.
@Override
public List<QcadooUser> getUsers() {
List<Entity> users = dataDefinitionService.get(QcadooSecurityConstants.PLUGIN_IDENTIFIER, QcadooSecurityConstants.MODEL_USER).find().addOrder(SearchOrders.asc(UserFields.USER_NAME)).list().getEntities();
List<QcadooUser> qcadooUsers = Lists.newLinkedList();
for (Entity user : users) {
qcadooUsers.add(new QcadooUser(user));
}
return qcadooUsers;
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class GroupRolesValidationServiceTest method stubGroupRoles.
private void stubGroupRoles(Entity group, String... roles) {
List<Entity> rolesEntity = Lists.newArrayList();
for (String role : roles) {
Entity roleEntity = mock(Entity.class);
given(roleEntity.getStringField(RoleFields.IDENTIFIER)).willReturn(role);
rolesEntity.add(roleEntity);
}
given(group.getManyToManyField(GroupFields.ROLES)).willReturn(rolesEntity);
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class GroupRolesValidationServiceTest method stubCurrentUserRole.
private void stubCurrentUserRole(final String role) {
Entity roleEntity = mock(Entity.class);
given(roleEntity.getStringField(RoleFields.IDENTIFIER)).willReturn(role);
given(currentUserEntityMock.getManyToManyField(UserFields.GROUP)).willReturn(Lists.newArrayList(roleEntity));
given(securityService.hasRole(currentUserEntityMock, QcadooSecurityConstants.ROLE_SUPERADMIN)).willReturn(QcadooSecurityConstants.ROLE_SUPERADMIN.equals(role));
}
use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.
the class UserRoleValidationServiceTest method stubRoleTransition.
private void stubRoleTransition(final String from, final String to) {
Entity fromRole = mock(Entity.class);
given(fromRole.getStringField(RoleFields.IDENTIFIER)).willReturn(from);
given(existingUserGroupMock.getManyToManyField(GroupFields.ROLES)).willReturn(Lists.newArrayList(fromRole));
given(existingUserEntityMock.getBelongsToField(UserFields.GROUP)).willReturn(from == null ? null : existingUserGroupMock);
given(securityService.hasRole(existingUserEntityMock, QcadooSecurityConstants.ROLE_SUPERADMIN)).willReturn(QcadooSecurityConstants.ROLE_SUPERADMIN.equals(from));
Entity toRole = mock(Entity.class);
given(toRole.getStringField(RoleFields.IDENTIFIER)).willReturn(to);
given(userGroupMock.getManyToManyField(GroupFields.ROLES)).willReturn(Lists.newArrayList(toRole));
given(userEntityMock.getBelongsToField(UserFields.GROUP)).willReturn(to == null ? null : userGroupMock);
given(securityService.hasRole(userEntityMock, QcadooSecurityConstants.ROLE_SUPERADMIN)).willReturn(QcadooSecurityConstants.ROLE_SUPERADMIN.equals(to));
}
Aggregations