- m = new Manager(username, dataPath);
- ts = m;
- try {
- m.init();
- } catch (Exception e) {
- System.err.println("Error loading state file: " + e.getMessage());
- return 2;
+ if (username == null) {
+ pm = new ProvisioningManager(dataPath, ServiceConfig.createDefaultServiceConfiguration(BaseConfig.USER_AGENT), BaseConfig.USER_AGENT);
+ ts = null;
+ } else {
+ try {
+ m = Manager.init(username, dataPath, ServiceConfig.createDefaultServiceConfiguration(BaseConfig.USER_AGENT), BaseConfig.USER_AGENT);
+ } catch (AuthorizationFailedException e) {
+ if (!"register".equals(ns.getString("command"))) {
+ // Register command should still be possible, if current authorization fails
+ System.err.println("Authorization failed, was the number registered elsewhere?");
+ return 2;
+ }
+ } catch (Throwable e) {
+ System.err.println("Error loading state file: " + e.getMessage());
+ return 2;
+ }
+ ts = m;