use of com.canoo.platform.client.security.Security in project dolphin-platform-examples by canoo.
the class LoginDialog method login.
private void login(final Button button) {
button.setDisable(true);
final Security security = PlatformClient.getService(Security.class);
final String user = userField.getText();
final String password = passwordField.getText();
final ExecutorService executor = PlatformClient.getClientConfiguration().getBackgroundExecutor();
executor.execute(() -> {
try {
security.login(user, password).get();
Platform.runLater(() -> {
setResult(true);
hide();
});
} catch (Exception e) {
Platform.runLater(() -> {
setResult(false);
});
} finally {
Platform.runLater(() -> {
button.setDisable(false);
});
}
});
}
use of com.canoo.platform.client.security.Security in project dolphin-platform-examples by canoo.
the class Client method main.
public static void main(String[] args) throws Exception {
final HttpClient client = PlatformClient.getService(HttpClient.class);
final String message = client.get("http://localhost:8080/api/message").withoutContent().readString().execute().get().getContent();
System.out.println(message);
final Security security = PlatformClient.getService(Security.class);
security.login("admin", "admin").get();
final String message2 = client.get("http://localhost:8080/api/secure/message").withoutContent().readString().execute().get().getContent();
System.out.println(message2);
}
Aggregations