Search in sources :

Example 1 with Guardian

use of eu.ggnet.dwoss.core.widget.auth.Guardian in project dwoss by gg-net.

the class WidgetProducers method guardian.

@Produces
public static Guardian guardian() {
    Guardian g = localDl.lookup(Guardian.class);
    LoggerFactory.getLogger(WidgetProducers.class).debug("guardian() produces " + g);
    return g;
}
Also used : Guardian(eu.ggnet.dwoss.core.widget.auth.Guardian) Produces(javax.enterprise.inject.Produces)

Example 2 with Guardian

use of eu.ggnet.dwoss.core.widget.auth.Guardian in project dwoss by gg-net.

the class DwOssApplication method start.

/**
 * Starting the Deutsche Warenwirtschaft Open Source application.
 * The startup happens through the following steps:
 * <ol>
 * <li>Parameter validation via <a href="https://jcommander.org/">JCommander</a>. The required and optional parametes are defined here
 * {@link ConnectionParameter}.</li>
 * <li>Setting the LAF for Swing components via {@link LafMenuManager#loadAndSetUserLaf() }</li>
 * <li>Displaying a placeholder main pane and the blocking login screen.
 * <ul>
 * <li>The login screen has no authentification system on visibility but the user can already type in his username and password.</li>
 * <li>The guardian is set later and only then an authentification will happen, even if the user has pressed return before.</li>
 * <li>A red/green circle in the ui displays the status of the guardian (red meaning not yet set).</li>
 * </ul>
 * </li>
 * <li>Initialize the client backend, remote connections, saft core, and preparing the main view by wrapping the javafx pane in a swing frame.
 * <ul>
 * <li>{@link #initSeContainer() }</li>
 * <li>{@link #initGlobalExceptionHandling() }</li>
 * <li>{@link #initRemoteConnection(eu.ggnet.dwoss.assembly.client.support.ConnectionParameter) }</li>
 * <li>{@link #initMainPane() }</li>
 * <li>{@link #startSaftInitMainFrameAndWrapMainPane(javax.swing.JFrame, javafx.scene.layout.Pane, eu.ggnet.dwoss.assembly.client.support.ConnectionParameter)
 * }</li>
 * </ul>
 * </li>
 * <li>Activating the authentification in the login screen by calling {@link LoginScreenController#setAndActivateGuardian(eu.ggnet.saft.experimental.auth.Guardian)
 * with the remote guardian</li>
 * <li>Start the polling of server progress {@link MonitorManager#startPolling() }</li>
 * <li>Initialize the session timeout and global keys for manual logout and relocation of windows. Ctrl+Shift+L for manual logout and Ctrl+Shift+R for
 * relocation of all windows</li>
 * </ol>
 *
 * @param primaryStage primaryStage of application.
 * @throws Exception all possible exeptions.
 */
@Override
public void start(Stage primaryStage) throws Exception {
    try {
        // Parameter discovery is done here, cause a error will be shown via Ui.
        ConnectionParameter cp = new ConnectionParameter();
        JCommander.newBuilder().addObject(cp).programName(DwOssMain.class.getName()).build().parse(getParameters().getRaw().toArray(new String[] {}));
        L.debug("start() parameters discovered: {}", cp);
        LafMenuManager.loadAndSetUserLaf();
        createAndShowMainPane(primaryStage);
        // Creating the Swing MainFrame as long as we are in the Swing mode.
        JFrame mainFrame = new JFrame();
        LoginScreenController firstLoginScreen = createAndShowFirstLoginScreen(primaryStage, mainFrame);
        CompletableFuture.runAsync(() -> {
            container = initSeContainer();
            instance = container.getBeanManager().createInstance();
            saft = instance.select(Saft.class).get();
            UiCore.initGlobal(saft);
        }).thenRun(() -> initGlobalExceptionHandling()).thenRun(() -> initRemoteConnection(cp)).thenApply(v -> initMainPane()).thenAcceptAsync(mainView -> startSaftInitMainFrameAndWrapMainPane(mainFrame, mainView, cp), java.awt.EventQueue::invokeLater).thenRunAsync(() -> firstLoginScreen.setAndActivateGuardian(Dl.local().lookup(Guardian.class))).thenRun(() -> initOnceViews()).thenRun(() -> instance.select(MonitorManager.class).get().startPolling()).thenRun(() -> initSessionTimeoutAndManualLogoutKeys()).thenRun(() -> initRelocationKeys()).handle((v, ex) -> {
            new DwFinalExceptionConsumer(null).accept(Optional.empty(), ex);
            return null;
        });
    } catch (ParameterException e) {
        // Sout is here correct.
        System.out.println(e.getMessage());
        System.out.println();
        e.getJCommander().usage();
        Alert a = new Alert(javafx.scene.control.Alert.AlertType.ERROR);
        a.setTitle("Fehler beim Start");
        a.setHeaderText("Fehler bei Start.");
        a.setContentText("Es ist ein Fehler beim Start aufgetreten. Bitte Console und/oder Logs prüfen.");
        a.show();
    }
}
Also used : EventHandler(javafx.event.EventHandler) Scene(javafx.scene.Scene) UserInfoException(eu.ggnet.dwoss.core.common.UserInfoException) ParameterException(com.beust.jcommander.ParameterException) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) StackPane(javafx.scene.layout.StackPane) eu.ggnet.dwoss.assembly.client.support(eu.ggnet.dwoss.assembly.client.support) JFXPanel(javafx.embed.swing.JFXPanel) DossierFilterView(eu.ggnet.dwoss.redtapext.ui.dbs.DossierFilterView) Application(javafx.application.Application) Parent(javafx.scene.Parent) RedTapeView(eu.ggnet.dwoss.redtapext.ui.cao.RedTapeView) FXMLLoader(javafx.fxml.FXMLLoader) MonitorManager(eu.ggnet.dwoss.assembly.client.support.monitor.MonitorManager) ImageIcon(javax.swing.ImageIcon) Dl(eu.ggnet.dwoss.core.widget.Dl) eu.ggnet.dwoss.assembly.client.support.exception(eu.ggnet.dwoss.assembly.client.support.exception) JFrame(javax.swing.JFrame) Instance(javax.enterprise.inject.Instance) Pane(javafx.scene.layout.Pane) Alert(javafx.scene.control.Alert) Modality(javafx.stage.Modality) Label(javafx.scene.control.Label) javafx.scene.input(javafx.scene.input) Logger(org.slf4j.Logger) SeContainerInitializer(javax.enterprise.inject.se.SeContainerInitializer) RemoteLookup(eu.ggnet.dwoss.core.widget.dl.RemoteLookup) CachedMandators(eu.ggnet.dwoss.mandator.spi.CachedMandators) eu.ggnet.dwoss.assembly.client.support.login(eu.ggnet.dwoss.assembly.client.support.login) Swing(eu.ggnet.saft.core.impl.Swing) JCommander(com.beust.jcommander.JCommander) IOException(java.io.IOException) WindowAdapter(java.awt.event.WindowAdapter) SearchCask(eu.ggnet.dwoss.search.ui.SearchCask) WindowEvent(java.awt.event.WindowEvent) StandardCharsets(java.nio.charset.StandardCharsets) EventType(javafx.event.EventType) Platform(javafx.application.Platform) Saft(eu.ggnet.saft.core.Saft) ConstraintViolationException(javax.validation.ConstraintViolationException) Stage(javafx.stage.Stage) Guardian(eu.ggnet.dwoss.core.widget.auth.Guardian) UiCore(eu.ggnet.saft.core.UiCore) SeContainer(javax.enterprise.inject.se.SeContainer) Optional(java.util.Optional) RawReportView(eu.ggnet.dwoss.report.ui.RawReportView) JFrame(javax.swing.JFrame) Guardian(eu.ggnet.dwoss.core.widget.auth.Guardian) ParameterException(com.beust.jcommander.ParameterException) Alert(javafx.scene.control.Alert)

Example 3 with Guardian

use of eu.ggnet.dwoss.core.widget.auth.Guardian in project dwoss by gg-net.

the class MandatorMetaDataController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    EnumSet<SalesChannel> visibleSalseChannels = EnumSet.complementOf(EnumSet.of(SalesChannel.UNKNOWN));
    defaultSalesChannelsListView.setItems(visibleSalseChannels.stream().map(s -> new SelectableSalesChannel(s)).collect(Collectors.toCollection(() -> FXCollections.observableArrayList())));
    defaultSalesChannelsListView.setCellFactory(CheckBoxListCell.forListView(SelectableSalesChannel::selectedProperty, new StringConverter<SelectableSalesChannel>() {

        @Override
        public String toString(SelectableSalesChannel t) {
            return t.getSalesChannel().description;
        }

        @Override
        public SelectableSalesChannel fromString(String string) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }));
    allowedSalesChannelsListView.setItems(visibleSalseChannels.stream().map(s -> new SelectableSalesChannel(s)).collect(Collectors.toCollection(() -> FXCollections.observableArrayList())));
    allowedSalesChannelsListView.setCellFactory(CheckBoxListCell.forListView(SelectableSalesChannel::selectedProperty, new StringConverter<SelectableSalesChannel>() {

        @Override
        public String toString(SelectableSalesChannel t) {
            return t.getSalesChannel().description;
        }

        @Override
        public SelectableSalesChannel fromString(String string) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }));
    shippingConditionComboBox.getItems().setAll(ShippingCondition.values());
    paymentConditionComboBox.getItems().setAll(PaymentCondition.values());
    paymentMethodComboBox.getItems().setAll(PaymentMethod.values());
    shippingConditionComboBox.setCellFactory((ListView<ShippingCondition> p) -> new FunctionListCell<>(i -> i.description));
    shippingConditionComboBox.setButtonCell(new FunctionListCell<>(i -> i.description));
    paymentConditionComboBox.setCellFactory((ListView<PaymentCondition> p) -> new FunctionListCell<>(i -> i.description));
    paymentConditionComboBox.setButtonCell(new FunctionListCell<>(i -> i.description));
    paymentMethodComboBox.setCellFactory((ListView<PaymentMethod> p) -> new FunctionListCell<>(i -> i.description));
    paymentMethodComboBox.setButtonCell(new FunctionListCell<>(i -> i.description));
    defaultCsd = Dl.local().lookup(CachedMandators.class).loadSalesdata();
    defaultshippingConditionTextField.setText(defaultCsd.shippingCondition().description);
    defaultpaymentConditionTextField.setText(defaultCsd.paymentCondition().description);
    defaultpaymentMethodTextField.setText(defaultCsd.paymentMethod().description);
    defaultSalesChannelsListView.getItems().forEach(i -> {
        if (defaultCsd.allowedSalesChannels().contains(i.getSalesChannel()))
            i.setSelected(true);
    });
    Guardian guardian = Dl.local().lookup(Guardian.class);
    guardian.add(new NodeEnabler(AtomicRight.UPDATE_CUSTOMER_PAYMENT_CONDITION, paymentConditionComboBox));
    guardian.add(new NodeEnabler(AtomicRight.UPDATE_CUSTOMER_PAYMENT_METHOD, paymentMethodComboBox));
    guardian.add(new NodeEnabler(AtomicRight.UPDATE_CUSTOMER_SHIPPING_CONDITION, shippingConditionComboBox));
}
Also used : java.util(java.util) javafx.beans.property(javafx.beans.property) Initializable(javafx.fxml.Initializable) javafx.scene.control(javafx.scene.control) URL(java.net.URL) CachedMandators(eu.ggnet.dwoss.mandator.spi.CachedMandators) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) FXCollections(javafx.collections.FXCollections) StringConverter(javafx.util.StringConverter) ResultProducer(eu.ggnet.saft.core.ui.ResultProducer) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) eu.ggnet.dwoss.core.common.values(eu.ggnet.dwoss.core.common.values) Consumer(java.util.function.Consumer) FXML(javafx.fxml.FXML) MandatorMetadata(eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata) AtomicRight(eu.ggnet.dwoss.rights.api.AtomicRight) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) FxController(eu.ggnet.saft.core.ui.FxController) ActionEvent(javafx.event.ActionEvent) Guardian(eu.ggnet.dwoss.core.widget.auth.Guardian) Ui(eu.ggnet.saft.core.Ui) Dl(eu.ggnet.dwoss.core.widget.Dl) Guardian(eu.ggnet.dwoss.core.widget.auth.Guardian) StringConverter(javafx.util.StringConverter)

Aggregations

Guardian (eu.ggnet.dwoss.core.widget.auth.Guardian)3 Dl (eu.ggnet.dwoss.core.widget.Dl)2 CachedMandators (eu.ggnet.dwoss.mandator.spi.CachedMandators)2 JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 eu.ggnet.dwoss.assembly.client.support (eu.ggnet.dwoss.assembly.client.support)1 eu.ggnet.dwoss.assembly.client.support.exception (eu.ggnet.dwoss.assembly.client.support.exception)1 eu.ggnet.dwoss.assembly.client.support.login (eu.ggnet.dwoss.assembly.client.support.login)1 MonitorManager (eu.ggnet.dwoss.assembly.client.support.monitor.MonitorManager)1 UserInfoException (eu.ggnet.dwoss.core.common.UserInfoException)1 eu.ggnet.dwoss.core.common.values (eu.ggnet.dwoss.core.common.values)1 RemoteLookup (eu.ggnet.dwoss.core.widget.dl.RemoteLookup)1 MandatorMetadata (eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata)1 DefaultCustomerSalesdata (eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata)1 RedTapeView (eu.ggnet.dwoss.redtapext.ui.cao.RedTapeView)1 DossierFilterView (eu.ggnet.dwoss.redtapext.ui.dbs.DossierFilterView)1 RawReportView (eu.ggnet.dwoss.report.ui.RawReportView)1 AtomicRight (eu.ggnet.dwoss.rights.api.AtomicRight)1 SearchCask (eu.ggnet.dwoss.search.ui.SearchCask)1 Saft (eu.ggnet.saft.core.Saft)1