Search in sources :

Example 1 with AtomicRight

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);
    }
}
Also used : Operator(eu.ggnet.dwoss.rights.ee.entity.Operator) Persona(eu.ggnet.dwoss.rights.ee.entity.Persona) AtomicRight(eu.ggnet.dwoss.rights.api.AtomicRight)

Example 2 with AtomicRight

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;
}
Also used : Operator(eu.ggnet.dwoss.rights.ee.entity.Operator) AtomicRight(eu.ggnet.dwoss.rights.api.AtomicRight)

Example 3 with AtomicRight

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());
        }
    }
}
Also used : AtomicRight(eu.ggnet.dwoss.rights.api.AtomicRight) Accessable(eu.ggnet.saft.api.auth.Accessable)

Example 4 with AtomicRight

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);
}
Also used : Operator(eu.ggnet.dwoss.rights.ee.entity.Operator) AtomicRight(eu.ggnet.dwoss.rights.api.AtomicRight) RightsAgent(eu.ggnet.dwoss.rights.ee.RightsAgent)

Example 5 with AtomicRight

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);
}
Also used : Operator(eu.ggnet.dwoss.rights.ee.entity.Operator) AtomicRight(eu.ggnet.dwoss.rights.api.AtomicRight) RightsAgent(eu.ggnet.dwoss.rights.ee.RightsAgent)

Aggregations

AtomicRight (eu.ggnet.dwoss.rights.api.AtomicRight)7 Operator (eu.ggnet.dwoss.rights.ee.entity.Operator)5 RightsAgent (eu.ggnet.dwoss.rights.ee.RightsAgent)2 Persona (eu.ggnet.dwoss.rights.ee.entity.Persona)1 Accessable (eu.ggnet.saft.api.auth.Accessable)1