use of eu.ggnet.dwoss.rights.ee.entity.Persona in project dwoss by gg-net.
the class RightsGeneratorOperation method make.
/**
* Create the given amount of operators and personas and create a Addentional Operator with the Username "Adminuser" und clear text Password Test and All
* Rights.
* <p>
* .* @param countOfOperator
* <p>
* @param countOfOperator
* @param countOfPersona
*/
public void make(int countOfOperator, int countOfPersona) {
List<Persona> personas = new ArrayList<>();
for (int i = 0; i < countOfPersona; i++) {
Persona persona = new Persona();
persona.setName("Persona " + i);
persona.addAll(getRandomRights());
em.persist(persona);
personas.add(persona);
}
for (int j = 0; j < countOfOperator; j++) {
Operator operator = new Operator();
for (AtomicRight atomicRight : getRandomRights()) {
operator.add(atomicRight);
}
operator.setUsername("User " + j);
int till = (int) (Math.random() * countOfPersona - 1);
for (Persona persona : personas.subList(0, till)) {
operator.add(persona);
}
operator.setSalt(RandomStringUtils.randomAlphanumeric(6).getBytes());
operator.setPassword(AuthenticationBean.hashPassword(RandomStringUtils.randomAlphanumeric(15).toCharArray(), operator.getSalt()));
operator.setQuickLoginKey((int) (Math.random() * 999));
em.persist(operator);
}
}
use of eu.ggnet.dwoss.rights.ee.entity.Persona in project dwoss by gg-net.
the class RightsManagmentController method handleAddPersonaButton.
@FXML
private void handleAddPersonaButton() {
Operator op = userlist.getSelectionModel().getSelectedItem();
List<Persona> selectedItems = new ArrayList<>(deactivePersonas.getSelectionModel().getSelectedItems());
op.addAllPersona(selectedItems);
resetDeactivePersonas();
resetDeactiveRights();
resetAllRights();
// setSelectedOperator(op);
Dl.remote().lookup(RightsAgent.class).store(op);
}
use of eu.ggnet.dwoss.rights.ee.entity.Persona in project dwoss by gg-net.
the class RightsManagmentController method handleRemovePersonaButton.
@FXML
private void handleRemovePersonaButton() {
Operator op = userlist.getSelectionModel().getSelectedItem();
List<Persona> selectedItems = new ArrayList<>(activePersonas.getSelectionModel().getSelectedItems());
op.removeAllPersona(selectedItems);
List<Persona> removed = new ArrayList<>(allPersonas);
removed.removeAll(op.getPersonas());
resetDeactivePersonas();
resetDeactiveRights();
resetAllRights();
// setSelectedOperator(op);
Dl.remote().lookup(RightsAgent.class).store(op);
}
use of eu.ggnet.dwoss.rights.ee.entity.Persona in project dwoss by gg-net.
the class PersonaOperatorIT method testDuplicateRemoval.
/**
* Test, that duplicate Rights to Persona and Operator are only keept on the persona.
*/
@Test
public void testDuplicateRemoval() {
assertThat(agent).as("RightsAgent").isNotNull();
Operator op = new Operator("TestUser");
Persona p = new Persona("Testpersona");
p.add(CREATE_ANNULATION_INVOICE);
p = agent.store(p);
op.add(p);
op = agent.store(op);
// Now we have one operator with one persona with one right.
// adding the same right to the operator
op.add(CREATE_ANNULATION_INVOICE);
// This should clear the duplicated right.
op = agent.store(op);
assertThat(op.getRights()).describedAs("The Operator, that should not have any right, cause its duplicate of the persona.").doesNotContain(CREATE_ANNULATION_INVOICE);
}
Aggregations