use of eu.ggnet.saft.core.auth.Guardian in project dwoss by gg-net.
the class AutoLoginLogoutHandler method showAuthenticator.
@Override
public void showAuthenticator() {
// When the Dialog is already open, return.
if (dialog != null)
return;
Guardian accessCos = Dl.local().lookup(Guardian.class);
accessCos.logout();
dialog = new AutoLogoutDialog(UiCore.getMainFrame(), accessCos.getOnceLoggedInUsernames());
dialog.setVisible(true);
dialog = null;
}
use of eu.ggnet.saft.core.auth.Guardian in project dwoss by gg-net.
the class ConsumerFactoryOfStockTransactions method of.
@Override
public List<DescriptiveConsumer<PicoUnit>> of(PicoUnit t) {
StockAgent stockAgent = Dl.remote().lookup(StockAgent.class);
StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(t.uniqueUnitId);
if (su == null || su.isInTransaction())
return Collections.EMPTY_LIST;
Guardian guardian = Dl.local().lookup(Guardian.class);
if (!guardian.hasRight(CREATE_TRANSACTION_FOR_SINGLE_UNIT))
return Collections.EMPTY_LIST;
return stockAgent.findAll(Stock.class).stream().filter(s -> !s.equals(su.getStock())).map(destination -> {
return new DescriptiveConsumer<>("Umfuhr von " + su.getStock().getName() + " nach " + destination.getName(), (PicoUnit t1) -> {
Ui.exec(() -> {
Ui.build().dialog().eval(() -> new CreateQuestionModel(su, destination, "Umfuhr direkt durch Nutzer erzeugt"), () -> new CreateQuestionView()).opt().map(v -> ReplyUtil.wrap(() -> Dl.remote().lookup(StockTransactionProcessor.class).perpareTransfer(v.stockUnits, v.destination.getId(), Dl.local().lookup(Guardian.class).getUsername(), v.comment))).filter(Ui.failure()::handle).ifPresent(u -> Ui.build().alert("Umfuhr angelegt"));
});
});
}).collect(Collectors.toList());
}
use of eu.ggnet.saft.core.auth.Guardian in project dwoss by gg-net.
the class CreateSimpleActionTryout method tryout.
@Test
public void tryout() throws InterruptedException {
JPanel p = new JPanel();
JButton b = new JButton("Press to close");
b.setPreferredSize(new Dimension(200, 50));
CountDownLatch l = new CountDownLatch(1);
b.addActionListener(e -> {
l.countDown();
});
p.add(new JButton(new CreateSimpleAction()));
p.add(b);
Dl.remote().add(StockAgent.class, new StockAgent() {
@Override
public <T> List<T> findAll(Class<T> entityClass) {
if (entityClass.equals(Stock.class))
return (List<T>) Arrays.asList(new Stock(0, "Rotes Lager"), new Stock(1, "Blaues Lager"));
return null;
}
@Override
public List<StockUnit> findStockUnitsByRefurbishIdEager(List<String> refurbishIds) {
if (refurbishIds.contains("1")) {
Stock s = new Stock(0, "Lager1");
StockUnit s1 = new StockUnit("1", "Gerät Eins", 1);
s1.setStock(s);
return Arrays.asList(s1);
}
return Collections.EMPTY_LIST;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public StockUnit findStockUnitByUniqueUnitIdEager(Integer uniqueUnitId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockUnit findStockUnitByRefurbishIdEager(String refurbishId) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<StockTransaction> findStockTransactionEager(StockTransactionType type, StockTransactionStatusType statusType, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T persist(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T merge(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> void delete(T t) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public StockTransaction findOrCreateRollInTransaction(int stockId, String userName, String comment) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> long count(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Dl.remote().add(StockTransactionProcessor.class, new StockTransactionProcessor() {
@Override
public SortedMap<Integer, String> perpareTransfer(List<StockUnit> stockUnits, int destinationStockId, String arranger, String comment) throws UserInfoException {
SortedMap<Integer, String> r = new TreeMap<>();
r.put(1, "1");
return r;
}
// <editor-fold defaultstate="collapsed" desc="Unused Methodes">
@Override
public List<Integer> rollIn(List<StockTransaction> detachtedTransactions, String arranger) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void cancel(StockTransaction transaction, String arranger, String comment) throws UserInfoException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void commission(List<StockTransaction> transactions, String picker, String deliverer) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void receive(List<StockTransaction> transactions, String deliverer, String reciever) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeFromPreparedTransaction(String refurbishId, String arranger, String comment) throws UserInfoException {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Guardian guardianMock = mock(Guardian.class);
given(guardianMock.getUsername()).willAnswer(i -> "Testuser");
Dl.local().add(Guardian.class, guardianMock);
UiCore.startSwing(() -> p);
l.await();
}
use of eu.ggnet.saft.core.auth.Guardian in project dwoss by gg-net.
the class ShowRightsAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Ui.exec(() -> {
Ui.build().fx().show(() -> {
StringBuilder sb = new StringBuilder();
Guardian accessCos = Dl.local().lookup(Guardian.class);
sb.append("<html><body><u>Benutzer:</u> <b>").append(accessCos.getUsername()).append("</b><br /><u>Berechtigungen</u><ul>");
for (Authorisation authorisation : accessCos.getRights()) {
sb.append("<li>").append(authorisation.toName()).append("</li>");
}
sb.append("</ul></body></html>");
return sb.toString();
}, () -> new HtmlPane());
});
}
Aggregations