+ } catch (DBusException | IOException e) {
+ logger.error("Dbus client failed", e);
+ return 3;
+ }
+ }
+
+ private static Command getCommand(Namespace ns) {
+ String commandKey = ns.getString("command");
+ final Map<String, Command> commands = Commands.getCommands();
+ if (!commands.containsKey(commandKey)) {
+ return null;
+ }
+ return commands.get(commandKey);
+ }
+
+ private static int handleCommand(Command command, Namespace ns, Signal ts, DBusConnection dBusConn) {
+ if (command instanceof ExtendedDbusCommand) {
+ return ((ExtendedDbusCommand) command).handleCommand(ns, ts, dBusConn);
+ } else if (command instanceof DbusCommand) {
+ return ((DbusCommand) command).handleCommand(ns, ts);
+ } else {
+ System.err.println("Command is not yet implemented via dbus");
+ return 1;
+ }
+ }
+
+ private static int handleCommand(Command command, Namespace ns, ProvisioningManager pm) {
+ if (command instanceof ProvisioningCommand) {
+ return ((ProvisioningCommand) command).handleCommand(ns, pm);
+ } else {
+ System.err.println("Command only works with a username");
+ return 1;
+ }
+ }
+
+ private static int handleCommand(Command command, Namespace ns, RegistrationManager m) {
+ if (command instanceof RegistrationCommand) {
+ return ((RegistrationCommand) command).handleCommand(ns, m);
+ }
+ return 1;
+ }
+
+ private static int handleCommand(Command command, Namespace ns, Manager m) {
+ if (command instanceof LocalCommand) {
+ return ((LocalCommand) command).handleCommand(ns, m);
+ } else if (command instanceof DbusCommand) {
+ return ((DbusCommand) command).handleCommand(ns, new DbusSignalImpl(m));
+ } else {
+ System.err.println("Command only works via dbus");
+ return 1;