use of eu.ggnet.dwoss.rights.api.AtomicRight 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.api.AtomicRight in project dwoss by gg-net.
the class RightsGeneratorOperation method make.
/**
* Generate a operator with all supplied parameters.
*
* @param password the password
* @param quickLoginKey a quicklogin key
* @param username the username and password
* @param activeRights the active rights to use
* @return the persisted operator.
*/
public Operator make(String username, String password, int quickLoginKey, Collection<AtomicRight> activeRights) {
Operator operator = new Operator();
operator.setUsername(username);
operator.setQuickLoginKey(0);
operator.setSalt(RandomStringUtils.randomAlphanumeric(6).getBytes());
operator.setPassword(AuthenticationBean.hashPassword(Objects.requireNonNull(password.toCharArray()), operator.getSalt()));
for (AtomicRight right : activeRights) {
operator.add(right);
}
em.persist(operator);
return operator;
}
use of eu.ggnet.dwoss.rights.api.AtomicRight in project dwoss by gg-net.
the class AbstractGuardian method setRights.
/**
* This method set the Current {@link AtomicRight}'s to the given one and Enables/Disables all {@link Accessable} components.
* <p>
* @param dto is a {@link Operator} that will be setted.
*/
protected void setRights(Operator dto) {
operator = dto;
quickRights.put(dto.getQuickLoginKey(), dto);
for (Accessable accessable : accessables) {
accessable.setEnabled(false);
}
rights.clear();
rights.addAll(dto.getRights());
for (Accessable accessable : accessables) {
for (AtomicRight atomicRight : dto.getRights()) {
if (accessable.getNeededRight().equals(atomicRight))
accessable.setEnabled(true);
}
}
if (!StringUtils.isBlank(dto.getUsername())) {
for (UserChangeListener listener : userChangeListeners) {
listener.loggedIn(dto.getUsername());
}
}
}
use of eu.ggnet.dwoss.rights.api.AtomicRight in project dwoss by gg-net.
the class RightsManagmentController method handleAddRightButton.
@FXML
private void handleAddRightButton() {
Operator op = userlist.getSelectionModel().getSelectedItem();
List<AtomicRight> selectedItems = new ArrayList<>(deactiveRights.getSelectionModel().getSelectedItems());
System.out.println("SelectedIt: " + selectedItems);
op.addAllRight(selectedItems);
resetDeactiveRights();
resetAllRights();
// setSelectedOperator(op);
Dl.remote().lookup(RightsAgent.class).store(op);
}
use of eu.ggnet.dwoss.rights.api.AtomicRight in project dwoss by gg-net.
the class RightsManagmentController method handleRemoveRightButton.
@FXML
private void handleRemoveRightButton() {
Operator op = userlist.getSelectionModel().getSelectedItem();
List<AtomicRight> selectedItems = new ArrayList<>(activeRights.getSelectionModel().getSelectedItems());
selectedOperator().removeAllRight(selectedItems);
resetDeactiveRights();
resetAllRights();
// setSelectedOperator(op);
Dl.remote().lookup(RightsAgent.class).store(op);
}
Aggregations